Skip to content

Commit c0be6aa

Browse files
Merge master into feature/emr
2 parents 7933978 + 96ce5ae commit c0be6aa

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

packages/core/src/auth/sso/cache.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { getLogger } from '../../shared/logger/logger'
1010
import fs from '../../shared/fs/fs'
1111
import { createDiskCache, KeyedCache, mapCache } from '../../shared/utilities/cacheUtils'
1212
import { stripUndefined } from '../../shared/utilities/collectionUtils'
13-
import { getMissingProps, hasProps, selectFrom } from '../../shared/utilities/tsUtils'
13+
import { hasProps, selectFrom } from '../../shared/utilities/tsUtils'
1414
import { SsoToken, ClientRegistration } from './model'
1515
import { DevSettings } from '../../shared/settings'
1616
import { onceChanged } from '../../shared/utilities/functionUtils'
@@ -79,6 +79,11 @@ export function getTokenCache(directory = getCacheDir()): KeyedCache<SsoAccess>
7979
}
8080

8181
function read(data: StoredToken): SsoAccess {
82+
// Validate data is not missing. Since the input data is passed directly from whatever is on disk.
83+
if (!hasProps(data, 'accessToken')) {
84+
throw new ToolkitError(`SSO cache data looks malformed`)
85+
}
86+
8287
const registration = hasProps(data, 'clientId', 'clientSecret', 'registrationExpiresAt')
8388
? {
8489
...selectFrom(data, 'clientId', 'clientSecret', 'scopes', 'startUrl'),
@@ -93,12 +98,6 @@ export function getTokenCache(directory = getCacheDir()): KeyedCache<SsoAccess>
9398

9499
stripUndefined(token)
95100

96-
// Validate data is not missing.
97-
const missingProps = getMissingProps(token, 'accessToken', 'refreshToken')
98-
if (missingProps.length > 0) {
99-
throw new ToolkitError(`SSO cache data unexpectedly missing props: ${JSON.stringify(missingProps)}`)
100-
}
101-
102101
return {
103102
token,
104103
registration,

packages/core/src/test/credentials/sso/cache.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ describe('SSO Cache', function () {
2727
const validToken = {
2828
accessToken: 'longstringofrandomcharacters',
2929
expiresAt: new Date(Date.now() + hourInMs),
30-
refreshToken: 'dummyRefreshToken',
3130
} as SsoToken
3231

3332
beforeEach(async function () {

packages/core/src/test/credentials/sso/ssoAccessTokenProvider.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ describe('SsoAccessTokenProvider', function () {
4545
return {
4646
accessToken: 'dummyAccessToken',
4747
expiresAt: new clock.Date(clock.Date.now() + timeDelta),
48-
refreshToken: 'dummyRefreshToken',
4948
...extras,
5049
}
5150
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "Auth: SSO failed to missing refreshToken"
4+
}

0 commit comments

Comments
 (0)