
Javascript Object Signing and Encryption (JOSE)
coding一月 14, 20211mins
Spring Security OAuth2 Java
JWTH1
JWTs can be represented as either JSON Web Signature (JWS) [3] or a JSON Web Encryption (JWE) [4] objects.
- Claims within a JWS can be read as they are simply base64-encoded (but carry with them a signature for authentication).
- Claims in a JWE on the other hand, are encrypted and as such, are entirely opaque to clients using them as their means of authentication and authorization.
Javascript Object Signing and Encryption (JOSE) - jose 0.1 documentation
javascript
import joseclaims = {'iss': 'http://www.example.com','exp': int(time()) + 3600,'sub': 42,}jwk = {'k': 'password'}jws = jose.sign(claims, jwk, alg='HS256')# JWS(header='eyJhbGciOiAiSFMyNTYifQ',# payload='eyJpc3MiOiAiaHR0cDovL3d3dy5leGFtcGxlLmNvbSIsICJzdWIiOiA0MiwgImV4cCI6IDEzOTU2NzQ0Mjd9',# signature='WYApAiwiKd-eDClA1fg7XFrnfHzUTgrmdRQY4M19Vr8')# issue the compact serialized version to the clients. this is what will be# transported along with requests to target systems.jwt = jose.serialize_compact(jws)# 'eyJhbGciOiAiSFMyNTYifQ.eyJpc3MiOiAiaHR0cDovL3d3dy5leGFtcGxlLmNvbSIsICJzdWIiOiA0MiwgImV4cCI6IDEzOTU2NzQ0Mjd9.WYApAiwiKd-eDClA1fg7XFrnfHzUTgrmdRQY4M19Vr8'jose.verify(jose.deserialize_compact(jwt), jwk, 'HS256')# JWT(header={u'alg': u'HS256'}, claims={u'iss': u'http://www.example.com', u'sub': 42, u'exp': 1395674427})
ImplmeentationH1
- Java Nimbus
评论
新的评论
上一篇
Plain JDBC Transaction Manager
要使用Spring的事务管理来处理普通的JDBC调用,不能直接从 Datasource 中获取 Connection ,需要使用 DataSourceUtils.getConnection This transaction manager also supports dire…
下一篇
Spring JCache
There are two ways to customize the underlying javax.cache.cacheManager: Caches can be created on startup by setting the spring.cache.cach…
