History

fix: handle array policies in JWT claim (#10041)

PR #10014 was not complete as only handled policy claims partially.

Harshavardhana committed 6 years ago

Commit 369a8761 parent 778e9c85 files · +90 −27Browse files

Showing the changes to cmd/auth-handler.go (1 of 5 files). Show all

Unified · Split

cmd/auth-handler.go+4−3
@@ -213,15 +213,15 @@ func getClaimsFromToken(r *http.Request, token string) (map[string]interface{}, · 212 unmodified lines
213213
214214 if globalPolicyOPA == nil {
215215 // If OPA is not set and if ldap claim key is set, allow the claim.
216− if _, ok := claims.Lookup(ldapUser); ok {
216+ if _, ok := claims.MapClaims[ldapUser]; ok {
217217 return claims.Map(), nil
218218 }
219219
220220 // If OPA is not set, session token should
221221 // have a policy and its mandatory, reject
222222 // requests without policy claim.
223− _, pokOpenID := claims.Lookup(iamPolicyClaimNameOpenID())
224− _, pokSA := claims.Lookup(iamPolicyClaimNameSA())
223+ _, pokOpenID := claims.MapClaims[iamPolicyClaimNameOpenID()]
224+ _, pokSA := claims.MapClaims[iamPolicyClaimNameSA()]
225225 if !pokOpenID && !pokSA {
226226 return nil, errAuthentication
227227 }
@@ -360,6 +360,7 @@ func checkRequestAuthTypeToAccessKey(ctx context.Context, r *http.Request, actio · 132 unmodified lines
360360 // Request is allowed return the appropriate access key.
361361 return cred.AccessKey, owner, ErrNone
362362 }
363+
363364 return cred.AccessKey, owner, ErrAccessDenied
364365 }
365366

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t