Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( SignKey string = "gwt_sign_key" ExpiresTime int = 259200 )
一些常量
Functions ¶
func ParsePKCS8PrivateKeyJwt ¶
func ParsePKCS8PrivateKeyJwt(privateKey string, issuer string, expiresAt time.Time) (tokenStr string, err error)
对应java版本
PrivateKey priKey = KeyFactory.
getInstance("RSA").
generatePrivate(
new PKCS8EncodedKeySpec(
(new BASE64Decoder()).decodeBuffer(privateKey)
)
);
Algorithm algorithm = Algorithm.RSA256((RSAPublicKey)null, (RSAPrivateKey)priKey);
return JWT.create().withIssuer(issuer).withExpiresAt(expireAt).withPayload(payload).sign(algorithm);
ParsePKCS8PrivateKeyJwt 根据pkcs8 私钥生成对应jwt token @param privateKey 私钥 @param payload 负载,可为空 @param issuer jwt颁发者标识 @param expireAt jwt过期时间
Types ¶
type CustomClaims ¶
type CustomClaims struct {
Data json.RawMessage
jwt.StandardClaims
}
CustomClaims Structured version of Claims Section, as referenced at https://tools.ietf.org/html/rfc7519#section-4.1 See examples for how to use this with your own claim types
func (CustomClaims) CreateToken ¶
func (claims CustomClaims) CreateToken(ctx context.Context) (string, error)
CreateToken 生成一个token
func (CustomClaims) ParseToken ¶
func (CustomClaims) ParseToken(ctx context.Context, tokenString string) (*CustomClaims, error)
ParseToken 解析Token
func (*CustomClaims) RefreshToken ¶
RefreshToken 更新token
Click to show internal directories.
Click to hide internal directories.