8000 feat: add oauth2 token exchange by code-asher · Pull Request #12196 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

feat: add oauth2 token exchange #12196

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

Merged
merged 11 commits into from
Feb 20, 2024
Prev Previous commit
Next Next commit
Check indexes in dbmem
Might have no match, and a -1 will panic.
  • Loading branch information
code-asher committed Feb 20, 2024
commit 73552bcb9f5beb10436dd57234dce5db75802990
5 changes: 3 additions & 2 deletions coderd/database/dbmem/dbmem.go
Original file line number Diff line number Diff line change
Expand Up @@ -1300,7 +1300,8 @@ func (q *FakeQuerier) DeleteOAuth2ProviderAppTokensByAppAndUserID(_ context.Cont
keyIdx := slices.IndexFunc(q.apiKeys, func(key database.APIKey) bool {
return key.ID == token.APIKeyID
})
if q.oauth2ProviderAppSecrets[secretIdx].AppID == arg.AppID && q.apiKeys[keyIdx].UserID == arg.UserID {
if secretIdx != -1 && q.oauth2ProviderAppSecrets[secretIdx].AppID == arg.AppID &&
keyIdx != -1 && q.apiKeys[keyIdx].UserID == arg.UserID {
keyIDsToDelete = append(keyIDsToDelete, token.APIKeyID)
} else {
tokens = append(tokens, token)
Expand Down Expand Up @@ -2370,7 +2371,7 @@ func (q *FakeQuerier) GetOAuth2ProviderAppsByUserID(_ context.Context, userID uu
keyIdx := slices.IndexFunc(q.apiKeys, func(key database.APIKey) bool {
return key.ID == token.APIKeyID
})
if q.apiKeys[keyIdx].UserID == userID {
if keyIdx != -1 && q.apiKeys[keyIdx].UserID == userID {
tokens = append(tokens, token)
}
}
Expand Down
0