@@ -28,9 +28,11 @@ import org.radarbase.authorizer.doa.RestSourceUserRepositoryImpl
2828import org.radarbase.authorizer.service.DelegatedRestSourceAuthorizationService
2929import org.radarbase.authorizer.service.DelegatedRestSourceAuthorizationService.Companion.FITBIT_AUTH
3030import org.radarbase.authorizer.service.DelegatedRestSourceAuthorizationService.Companion.GARMIN_AUTH
31+ import org.radarbase.authorizer.service.DelegatedRestSourceAuthorizationService.Companion.GOOGLE_AUTH
3132import org.radarbase.authorizer.service.DelegatedRestSourceAuthorizationService.Companion.OURA_AUTH
3233import org.radarbase.authorizer.service.GarminOAuth2AuthorizationService
3334import org.radarbase.authorizer.service.GarminOauth1AuthorizationService
35+ import org.radarbase.authorizer.service.GoogleHealthAuthorizationService
3436import org.radarbase.authorizer.service.OAuth2RestSourceAuthorizationService
3537import org.radarbase.authorizer.service.OuraAuthorizationService
3638import org.radarbase.authorizer.service.RegistrationService
@@ -46,21 +48,21 @@ class AuthorizerResourceEnhancer(
4648 private val restSourceClients = RestSourceClients (
4749 config.restSourceClients
4850 .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+ }
4960 .onEach {
5061 requireNotNull(it.clientId) { " Client ID of ${it.sourceType} is missing" }
5162 requireNotNull(it.clientSecret) { " Client secret of ${it.sourceType} is missing" }
5263 },
5364 )
5465
55- /* *
56- * Maps a source type to its configured OAuth version (e.g., "oauth1" or "oauth2").
57- * This is used to conditionally bind the correct authorization service implementation.
58- * Configure via the `oauthVersion` field in `authorizer.yml` under each `restSourceClients` entry.
59- */
60- private val sourceTypeOauthMap: Map <String , String > = config.restSourceClients.associate {
61- it.sourceType to it.oauthVersion.lowercase()
62- }
63-
6466 override val classes: Array <Class <* >>
6567 get() = listOfNotNull(
6668 Filters .cache,
@@ -112,8 +114,9 @@ class AuthorizerResourceEnhancer(
112114 bind(DelegatedRestSourceAuthorizationService ::class .java)
113115 .to(RestSourceAuthorizationService ::class .java)
114116
115- // Bind Garmin service based on a configured oauthVersion: "oauth2" → PKCE flow, "oauth1" → legacy flow.
116- if (sourceTypeOauthMap[GARMIN_AUTH ].equals(" oauth2" , ignoreCase = true )) {
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) {
117120 bind(GarminOAuth2AuthorizationService ::class .java)
118121 .to(RestSourceAuthorizationService ::class .java)
119122 .named(GARMIN_AUTH )
@@ -134,5 +137,10 @@ class AuthorizerResourceEnhancer(
134137 .to(RestSourceAuthorizationService ::class .java)
135138 .named(OURA_AUTH )
136139 .`in `(Singleton ::class .java)
140+
141+ bind(GoogleHealthAuthorizationService ::class .java)
142+ .to(RestSourceAuthorizationService ::class .java)
143+ .named(GOOGLE_AUTH )
144+ .`in `(Singleton ::class .java)
137145 }
138146}
0 commit comments