mirror of
https://github.com/1f349/mjwt.git
synced 2024-12-22 07:24:05 +00:00
Add SignJwt to Provider
This commit is contained in:
parent
c1712f1c1d
commit
b859e3a63a
1
mjwt.go
1
mjwt.go
@ -12,6 +12,7 @@ var ErrClaimTypeMismatch = errors.New("claim type mismatch")
|
|||||||
|
|
||||||
type Provider interface {
|
type Provider interface {
|
||||||
GenerateJwt(sub, id string, dur time.Duration, claims Claims) (string, error)
|
GenerateJwt(sub, id string, dur time.Duration, claims Claims) (string, error)
|
||||||
|
SignJwt(claims jwt.Claims) (string, error)
|
||||||
VerifyJwt(token string, claims baseTypeClaim) (*jwt.Token, error)
|
VerifyJwt(token string, claims baseTypeClaim) (*jwt.Token, error)
|
||||||
Issuer() string
|
Issuer() string
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,10 @@ func (d *defaultMJwtVerifier) GenerateJwt(_, _ string, _ time.Duration, _ Claims
|
|||||||
return "", ErrCannotGenerateMJwtToken
|
return "", ErrCannotGenerateMJwtToken
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *defaultMJwtVerifier) SignJwt(_ jwt.Claims) (string, error) {
|
||||||
|
return "", ErrCannotGenerateMJwtToken
|
||||||
|
}
|
||||||
|
|
||||||
func (d *defaultMJwtVerifier) VerifyJwt(token string, claims baseTypeClaim) (*jwt.Token, error) {
|
func (d *defaultMJwtVerifier) VerifyJwt(token string, claims baseTypeClaim) (*jwt.Token, error) {
|
||||||
withClaims, err := jwt.ParseWithClaims(token, claims, func(token *jwt.Token) (interface{}, error) {
|
withClaims, err := jwt.ParseWithClaims(token, claims, func(token *jwt.Token) (interface{}, error) {
|
||||||
return d.pub, nil
|
return d.pub, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user