aboutsummaryrefslogtreecommitdiffstats
path: root/services/auth/oauth2.go
diff options
context:
space:
mode:
Diffstat (limited to 'services/auth/oauth2.go')
-rw-r--r--services/auth/oauth2.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/services/auth/oauth2.go b/services/auth/oauth2.go
index 523998a634..d0aec085b1 100644
--- a/services/auth/oauth2.go
+++ b/services/auth/oauth2.go
@@ -27,10 +27,15 @@ var (
// CheckOAuthAccessToken returns uid of user from oauth token
func CheckOAuthAccessToken(ctx context.Context, accessToken string) int64 {
- // JWT tokens require a "."
+ if !setting.OAuth2.Enabled {
+ return 0
+ }
+
+ // JWT tokens require a ".", if the token isn't like that, return early
if !strings.Contains(accessToken, ".") {
return 0
}
+
token, err := oauth2_provider.ParseToken(accessToken, oauth2_provider.DefaultSigningKey)
if err != nil {
log.Trace("oauth2.ParseToken: %v", err)