Skip to content

Commit 0b696f9

Browse files
committed
initial commit
1 parent 2d03e06 commit 0b696f9

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/credentials/sso/DiskCache.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class DiskCache(
101101
clientRegistrationCache(ssoRegion).tryDeleteIfExists()
102102
}
103103

104-
override fun loadClientRegistration(cacheKey: ClientRegistrationCacheKey): ClientRegistration? {
104+
override fun loadClientRegistration(cacheKey: ClientRegistrationCacheKey, source: String): ClientRegistration? {
105105
LOG.info { "loadClientRegistration for $cacheKey" }
106106
val inputStream = clientRegistrationCache(cacheKey).tryInputStreamIfExists()
107107
if (inputStream == null) {

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/credentials/sso/SsoAccessTokenProvider.kt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ class SsoAccessTokenProvider(
194194

195195
@Deprecated("Device authorization grant flow is deprecated")
196196
private fun registerDAGClient(): ClientRegistration {
197-
loadDagClientRegistration()?.let {
197+
loadDagClientRegistration(SourceOf)?.let {
198198
return it
199199
}
200200

@@ -505,6 +505,11 @@ class SsoAccessTokenProvider(
505505
}
506506
}
507507

508+
enum class SourceOfLoadRegistration{
509+
REGISTER_CLIENT,
510+
REFRESH_TOKEN,
511+
}
512+
508513
private enum class RefreshCredentialStage {
509514
VALIDATE_REFRESH_TOKEN,
510515
LOAD_REGISTRATION,
@@ -514,13 +519,13 @@ class SsoAccessTokenProvider(
514519
SAVE_TOKEN,
515520
}
516521

517-
private fun loadDagClientRegistration(): ClientRegistration? =
518-
cache.loadClientRegistration(dagClientRegistrationCacheKey)?.let {
522+
private fun loadDagClientRegistration(source: String): ClientRegistration? =
523+
cache.loadClientRegistration(dagClientRegistrationCacheKey, source)?.let {
519524
return it
520525
}
521526

522-
private fun loadPkceClientRegistration(): PKCEClientRegistration? =
523-
cache.loadClientRegistration(pkceClientRegistrationCacheKey)?.let {
527+
private fun loadPkceClientRegistration(source: String): PKCEClientRegistration? =
528+
cache.loadClientRegistration(pkceClientRegistrationCacheKey, source)?.let {
524529
return it as PKCEClientRegistration
525530
}
526531

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/credentials/sso/SsoCache.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface SsoCache {
77
fun invalidateClientRegistration(ssoRegion: String)
88
fun invalidateAccessToken(ssoUrl: String)
99

10-
fun loadClientRegistration(cacheKey: ClientRegistrationCacheKey): ClientRegistration?
10+
fun loadClientRegistration(cacheKey: ClientRegistrationCacheKey, source: String): ClientRegistration?
1111
fun saveClientRegistration(cacheKey: ClientRegistrationCacheKey, registration: ClientRegistration)
1212
fun invalidateClientRegistration(cacheKey: ClientRegistrationCacheKey)
1313

0 commit comments

Comments
 (0)