Add SignJwt to Provider

This commit is contained in:
Melon 2022-12-09 13:22:10 +00:00
parent c1712f1c1d
commit b859e3a63a
Signed by: melon
GPG Key ID: 6C9D970C50D26A25
2 changed files with 5 additions and 0 deletions

View File

@ -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
} }

View File

@ -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