Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: really assign string scp claim #6336

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion flyteadmin/auth/authzserver/claims_verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func verifyClaims(expectedAudience sets.String, claimsRaw map[string]interface{}
case []interface{}:
scopes = sets.NewString(interfaceSliceToStringSlice(sct)...)
case string:
sets.NewString(fmt.Sprintf("%v", scopesClaim))
scopes = sets.NewString(fmt.Sprintf("%v", scopesClaim))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing variable assignment for scopes

The variable assignment for scopes is missing in the original code. The fix correctly assigns the result of sets.NewString(fmt.Sprintf("%v", scopesClaim)) to the scopes variable. Without this assignment, the scopes variable would remain empty in the string case branch, potentially causing authorization issues.

Code suggestion
Check the AI-generated fix before applying
Suggested change
scopes = sets.NewString(fmt.Sprintf("%v", scopesClaim))
scopes = sets.NewString(fmt.Sprintf("%v", scopesClaim))

Code Review Run #541a27


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

default:
return nil, fmt.Errorf("failed getting scope claims due to unknown type %T with value %v", sct, sct)
}
Expand Down
1 change: 1 addition & 0 deletions flyteadmin/auth/authzserver/claims_verifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func Test_verifyClaims(t *testing.T) {
t.Run("String scope", func(t *testing.T) {
identityCtx, err := verifyClaims(sets.NewString("https://myserver", "https://myserver2"),
map[string]interface{}{
"client_id": "my-client",
"aud": []string{"https://myserver"},
"scp": "all",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use something other than the default all scope so its clear that it was not injected.

})
Expand Down
Loading