From cfcbdba1f89e87c1a7e9d037159cccfe49816260 Mon Sep 17 00:00:00 2001 From: harryzcy Date: Tue, 6 Sep 2022 23:42:15 -0400 Subject: [PATCH] Update the types for ApiTokenScope in context --- services/auth/basic.go | 4 ++-- services/auth/httpsign.go | 2 +- services/auth/oauth2.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/services/auth/basic.go b/services/auth/basic.go index 2e873daac7..5011a64e02 100644 --- a/services/auth/basic.go +++ b/services/auth/basic.go @@ -82,7 +82,7 @@ func (b *Basic) Verify(req *http.Request, w http.ResponseWriter, store DataStore } store.GetData()["IsApiToken"] = true - store.GetData()["ApiTokenScope"] = auth_model.AccessTokenScopeAll + store.GetData()["ApiTokenScope"] = auth_model.AccessTokenScope(auth_model.AccessTokenScopeAll) return u } @@ -101,7 +101,7 @@ func (b *Basic) Verify(req *http.Request, w http.ResponseWriter, store DataStore } store.GetData()["IsApiToken"] = true - store.GetData()["ApiTokenScope"] = auth_model.AccessTokenScopeAll + store.GetData()["ApiTokenScope"] = auth_model.AccessTokenScope(auth_model.AccessTokenScopeAll) return u } else if !auth_model.IsErrAccessTokenNotExist(err) && !auth_model.IsErrAccessTokenEmpty(err) { log.Error("GetAccessTokenBySha: %v", err) diff --git a/services/auth/httpsign.go b/services/auth/httpsign.go index 98226906d0..f800a509d9 100644 --- a/services/auth/httpsign.go +++ b/services/auth/httpsign.go @@ -81,7 +81,7 @@ func (h *HTTPSign) Verify(req *http.Request, w http.ResponseWriter, store DataSt } store.GetData()["IsApiToken"] = true - store.GetData()["ApiTokenScope"] = auth_model.AccessTokenScopeAll + store.GetData()["ApiTokenScope"] = auth_model.AccessTokenScope(auth_model.AccessTokenScopeAll) log.Trace("HTTP Sign: Logged in user %-v", u) diff --git a/services/auth/oauth2.go b/services/auth/oauth2.go index f3dc1e4013..ba68e35d6a 100644 --- a/services/auth/oauth2.go +++ b/services/auth/oauth2.go @@ -89,7 +89,7 @@ func (o *OAuth2) userIDFromToken(req *http.Request, store DataStore) int64 { uid := CheckOAuthAccessToken(tokenSHA) if uid != 0 { store.GetData()["IsApiToken"] = true - store.GetData()["ApiTokenScope"] = auth_model.AccessTokenScopeAll // fallback to all + store.GetData()["ApiTokenScope"] = auth_model.AccessTokenScope(auth_model.AccessTokenScopeAll) // fallback to all } return uid }