diff --git a/auth/jwt.go b/auth/jwt.go index 705995f10d58febd74d6512373ab859f79b019b8..55824e254b55e6e2eb4d97d8db95b18e158877b5 100644 --- a/auth/jwt.go +++ b/auth/jwt.go @@ -141,3 +141,18 @@ func GetUserIDFromJWTWithoutValidation(jsonWebTokenString string) string { } return jsonWebToken.UserID } + +// GetUserAndProviderIDFromJWTWithoutValidation gets the userID and providerID from the jsonWebTokenString without validating the +// signature. Successful execution of this function DOES NOT indicate that the JWT is valid in any way. +func GetUserAndProviderIDFromJWTWithoutValidation(jsonWebTokenString string) (string, int64) { + token, _, err := jwt.NewParser().ParseUnverified(jsonWebTokenString, jwt.MapClaims{}) + if err != nil { + return "", 0 + } + + jsonWebToken, err := getJsonWebTokenFromTokenClaims(token, false) + if err != nil { + return "", 0 + } + return jsonWebToken.UserID, jsonWebToken.ProviderID +}