mirror of
https://github.com/1f349/mjwt.git
synced 2024-12-22 07:24:05 +00:00
Separate generate and sign methods for raw jwt.Claims
This commit is contained in:
parent
3312a37264
commit
c1712f1c1d
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -25,7 +25,10 @@ func NewMJwtSigner(issuer string, key *rsa.PrivateKey) Provider {
|
|||||||
func (d *defaultMJwtSigner) Issuer() string { return d.issuer }
|
func (d *defaultMJwtSigner) Issuer() string { return d.issuer }
|
||||||
|
|
||||||
func (d *defaultMJwtSigner) GenerateJwt(sub, id string, dur time.Duration, claims Claims) (string, error) {
|
func (d *defaultMJwtSigner) GenerateJwt(sub, id string, dur time.Duration, claims Claims) (string, error) {
|
||||||
wrapped := wrapClaims[Claims](d, sub, id, dur, claims)
|
return d.SignJwt(wrapClaims[Claims](d, sub, id, dur, claims))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *defaultMJwtSigner) SignJwt(wrapped jwt.Claims) (string, error) {
|
||||||
token := jwt.NewWithClaims(jwt.SigningMethodRS512, wrapped)
|
token := jwt.NewWithClaims(jwt.SigningMethodRS512, wrapped)
|
||||||
return token.SignedString(d.key)
|
return token.SignedString(d.key)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user