@@ -21,6 +21,7 @@ import org.glassfish.jersey.internal.inject.AbstractBinder
2121import org.radarbase.authorizer.api.RestSourceClientMapper
2222import org.radarbase.authorizer.api.RestSourceUserMapper
2323import org.radarbase.authorizer.config.AuthorizerConfig
24+ import org.radarbase.authorizer.config.OAuthVersion
2425import org.radarbase.authorizer.config.RestSourceClients
2526import org.radarbase.authorizer.doa.RegistrationRepository
2627import org.radarbase.authorizer.doa.RestSourceUserRepository
@@ -48,21 +49,15 @@ class AuthorizerResourceEnhancer(
4849 private val restSourceClients = RestSourceClients (
4950 config.restSourceClients
5051 .map { it.withEnv() }
51- .map {
52- when {
53- it.sourceType == GARMIN_AUTH && it.oauthVersion.equals(" oauth2" , ignoreCase = true ) ->
54- it.copy(usesPkce = true )
55- it.sourceType == GOOGLE_AUTH ->
56- it.copy(usesPkce = true )
57- else -> it
58- }
59- }
6052 .onEach {
6153 requireNotNull(it.clientId) { " Client ID of ${it.sourceType} is missing" }
6254 requireNotNull(it.clientSecret) { " Client secret of ${it.sourceType} is missing" }
6355 },
6456 )
6557
58+ private val garminUsesOauth2 = restSourceClients.clients
59+ .firstOrNull { it.sourceType == GARMIN_AUTH }?.oauthVersion == OAuthVersion .OAUTH2
60+
6661 override val classes: Array <Class <* >>
6762 get() = listOfNotNull(
6863 Filters .cache,
@@ -114,9 +109,7 @@ class AuthorizerResourceEnhancer(
114109 bind(DelegatedRestSourceAuthorizationService ::class .java)
115110 .to(RestSourceAuthorizationService ::class .java)
116111
117- // Bind Garmin service based on configured oauthVersion: "oauth2" → PKCE flow, "oauth1" → legacy flow.
118- val garminUsesPkce = restSourceClients.clients.firstOrNull { it.sourceType == GARMIN_AUTH }?.usesPkce == true
119- if (garminUsesPkce) {
112+ if (garminUsesOauth2) {
120113 bind(GarminOAuth2AuthorizationService ::class .java)
121114 .to(RestSourceAuthorizationService ::class .java)
122115 .named(GARMIN_AUTH )
0 commit comments