fix: removeUserinfoScopes return new slice (without manipulating passed one) (#110)
This commit is contained in:
parent
8a35b89815
commit
1132c9d93d
1 changed files with 10 additions and 9 deletions
|
@ -155,15 +155,16 @@ func CreateIDToken(ctx context.Context, issuer string, request IDTokenRequest, v
|
|||
}
|
||||
|
||||
func removeUserinfoScopes(scopes []string) []string {
|
||||
for i := len(scopes) - 1; i >= 0; i-- {
|
||||
if scopes[i] == oidc.ScopeProfile ||
|
||||
scopes[i] == oidc.ScopeEmail ||
|
||||
scopes[i] == oidc.ScopeAddress ||
|
||||
scopes[i] == oidc.ScopePhone {
|
||||
|
||||
scopes[i] = scopes[len(scopes)-1]
|
||||
scopes[len(scopes)-1] = ""
|
||||
scopes = scopes[:len(scopes)-1]
|
||||
newScopeList := make([]string, 0, len(scopes))
|
||||
for _, scope := range scopes {
|
||||
switch scope {
|
||||
case oidc.ScopeProfile,
|
||||
oidc.ScopeEmail,
|
||||
oidc.ScopeAddress,
|
||||
oidc.ScopePhone:
|
||||
continue
|
||||
default:
|
||||
newScopeList = append(newScopeList, scope)
|
||||
}
|
||||
}
|
||||
return scopes
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue