Skip to content

Commit

Permalink
Fix ADFS token caching
Browse files Browse the repository at this point in the history
  • Loading branch information
chlowell authored and bgavrilMS committed Oct 24, 2023
1 parent af6aed9 commit 22d8300
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions apps/confidential/confidential_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ func TestADFSTokenCaching(t *testing.T) {
AccessToken: accesstokens.TokenResponse{
AccessToken: "at1",
RefreshToken: "rt",
TokenType: "Bearer",
TokenType: "bearer",
ExpiresOn: internalTime.DurationTime{T: time.Now().Add(time.Hour)},
ExtExpiresOn: internalTime.DurationTime{T: time.Now().Add(time.Hour)},
GrantedScopes: accesstokens.Scopes{Slice: tokenScope},
Expand Down Expand Up @@ -415,7 +415,7 @@ func TestADFSTokenCaching(t *testing.T) {

// simulate authenticating a different user
fakeAT.AccessToken.AccessToken = "at2"
fakeAT.AccessToken.TokenType = "Bearer"
fakeAT.AccessToken.TokenType = "bearer"
fakeAT.AccessToken.IDToken.Name = "B"
fakeAT.AccessToken.IDToken.PreferredUsername = "B"
fakeAT.AccessToken.IDToken.Subject = "B"
Expand Down
2 changes: 1 addition & 1 deletion apps/internal/base/internal/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ func (m *Manager) readAccessToken(homeID string, envAliases []string, realm, cli
// an issue, however if it does become a problem then we know where to look.
for k, at := range m.contract.AccessTokens {
if at.HomeAccountID == homeID && at.Realm == realm && at.ClientID == clientID {
if (at.TokenType == tokenType && at.AuthnSchemeKeyID == authnSchemeKeyID) || (at.TokenType == "" && (tokenType == "" || tokenType == "Bearer")) {
if (strings.EqualFold(at.TokenType, tokenType) && at.AuthnSchemeKeyID == authnSchemeKeyID) || (at.TokenType == "" && (tokenType == "" || tokenType == "Bearer")) {
if checkAlias(at.Environment, envAliases) && isMatchingScopes(scopes, at.Scopes) {
m.contractMu.RUnlock()
if needsUpgrade(k) {
Expand Down

0 comments on commit 22d8300

Please sign in to comment.