Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit 8f01728

Browse files
committed
Make old tokens scopes backwards compatible
1 parent d29b7b2 commit 8f01728

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

cmd/frontend/graphqlbackend/graphqlbackend.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"github.com/sourcegraph/sourcegraph/internal/actor"
2626
"github.com/sourcegraph/sourcegraph/internal/api"
2727
"github.com/sourcegraph/sourcegraph/internal/auth"
28+
"github.com/sourcegraph/sourcegraph/internal/authz"
2829
"github.com/sourcegraph/sourcegraph/internal/cloneurls"
2930
"github.com/sourcegraph/sourcegraph/internal/conf"
3031
"github.com/sourcegraph/sourcegraph/internal/database"
@@ -859,7 +860,9 @@ func (v *authzDirectiveVisitor) Before(ctx context.Context, directive *gqltypes.
859860
if scopesAttr, ok := directive.Arguments.Get("scopes"); ok {
860861
a := actor.FromContext(ctx)
861862
// only care about token based auth and non-internal tokens for now
862-
if a.FromToken && !a.Internal {
863+
isUserAll := a.Scopes[authz.ScopeUserAll]
864+
isSiteAdminSudo := a.Scopes[authz.ScopeSiteAdminSudo]
865+
if a.FromToken && !a.Internal && !(isUserAll || isSiteAdminSudo) {
863866
requiredScopes := scopesAttr.Deserialize(nil).([]interface{})
864867
if len(requiredScopes) < 1 {
865868
return errors.Errorf("Authorization required, but no scopes are given in graphql schema")

0 commit comments

Comments
 (0)