|
|
@ -1,7 +1,9 @@
|
|
|
|
package jwt
|
|
|
|
package jwt
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
|
|
|
|
"git.noahlan.cn/noahlan/ntool/ndef"
|
|
|
|
"git.noahlan.cn/noahlan/ntool/nrandom"
|
|
|
|
"git.noahlan.cn/noahlan/ntool/nrandom"
|
|
|
|
|
|
|
|
"git.noahlan.cn/noahlan/ntool/nstr"
|
|
|
|
"github.com/golang-jwt/jwt/v5"
|
|
|
|
"github.com/golang-jwt/jwt/v5"
|
|
|
|
"strconv"
|
|
|
|
"strconv"
|
|
|
|
"time"
|
|
|
|
"time"
|
|
|
@ -28,6 +30,10 @@ func WithOption(key string, val any) Option {
|
|
|
|
return Option{key, val}
|
|
|
|
return Option{key, val}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func WithRoles(codes []string) Option {
|
|
|
|
|
|
|
|
return WithOption(KeyRoles, nstr.JoinAny(ndef.CommaStr, codes))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func WithID(id string) Option {
|
|
|
|
func WithID(id string) Option {
|
|
|
|
return WithOption("jti", id)
|
|
|
|
return WithOption("jti", id)
|
|
|
|
}
|
|
|
|
}
|
|
|
|