mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
Refactor: pass in claim type into security.DecodeJwt
This commit is contained in:
parent
d156d410ef
commit
fcc09cef6f
|
@ -57,9 +57,9 @@ func GetJwt(r *http.Request) EncodedJwt {
|
|||
return EncodedJwt(tokenStr)
|
||||
}
|
||||
|
||||
func DecodeJwt(signingKey SigningKey, tokenString EncodedJwt) (token *jwt.Token, err error) {
|
||||
func DecodeJwt(signingKey SigningKey, tokenString EncodedJwt, claims jwt.Claims) (token *jwt.Token, err error) {
|
||||
// check exp, nbf
|
||||
return jwt.ParseWithClaims(string(tokenString), &SeaweedFileIdClaims{}, func(token *jwt.Token) (interface{}, error) {
|
||||
return jwt.ParseWithClaims(string(tokenString), claims, func(token *jwt.Token) (interface{}, error) {
|
||||
if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok {
|
||||
return nil, fmt.Errorf("unknown token method")
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ func (vs *VolumeServer) maybeCheckJwtAuthorization(r *http.Request, vid, fid str
|
|||
return false
|
||||
}
|
||||
|
||||
token, err := security.DecodeJwt(signingKey, tokenStr)
|
||||
token, err := security.DecodeJwt(signingKey, tokenStr, &security.SeaweedFileIdClaims{})
|
||||
if err != nil {
|
||||
glog.V(1).Infof("jwt verification error from %s: %v", r.RemoteAddr, err)
|
||||
return false
|
||||
|
|
Loading…
Reference in a new issue