MCPcopy Create free account
hub / github.com/SpectoLabs/hoverfly / IsJwtTokenValid

Function IsJwtTokenValid

core/authentication/auth_service.go:66–82  ·  view source on GitHub ↗
(token string, ab backends.Authentication, secret []byte, exp int)

Source from the content-addressed store, hash-verified

64}
65
66func IsJwtTokenValid(token string, ab backends.Authentication, secret []byte, exp int) bool {
67 authBackend := InitJWTAuthenticationBackend(ab, secret, exp)
68
69 jwtToken, err := jwt.Parse(token, func(token *jwt.Token) (interface{}, error) {
70 if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok {
71 return nil, fmt.Errorf("Unexpected signing method: %v", token.Header["alg"])
72 } else {
73 return authBackend.SecretKey, nil
74 }
75 })
76
77 if err == nil && jwtToken.Valid && !authBackend.IsInBlacklist(token) {
78 return true
79 } else {
80 return false
81 }
82}
83
84func RefreshToken(requestUser *backends.User, ab backends.Authentication, secret []byte, exp int) []byte {
85 authBackend := InitJWTAuthenticationBackend(ab, secret, exp)

Callers 2

NewProxyFunction · 0.92

Calls 2

IsInBlacklistMethod · 0.80

Tested by

no test coverage detected