Skip to content
Snippets Groups Projects
Commit 60a07523 authored by Jano Hendriks's avatar Jano Hendriks
Browse files

Add function to get user and provider ID from JWT

parent 4d617af2
No related branches found
No related tags found
No related merge requests found
......@@ -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
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment