From b5802588857ba9c286cfd4ffdaae3044d12305c8 Mon Sep 17 00:00:00 2001 From: Amanpal Singh <87360222+aman-alfresco@users.noreply.github.com> Date: Mon, 9 Dec 2024 12:47:40 +0530 Subject: [PATCH] ADST-566 (#86) * Integrate Auth0 using app auth * Integrate Auth0 using app auth * added check for the scope * optmize code * fixed code error * udpate condition for keycloak --- auth/src/main/java/com/alfresco/auth/AuthConfig.kt | 7 +++++++ .../java/com/alfresco/auth/ui/AuthenticationActivity.kt | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/auth/src/main/java/com/alfresco/auth/AuthConfig.kt b/auth/src/main/java/com/alfresco/auth/AuthConfig.kt index 2c5181b..8a1ca3a 100644 --- a/auth/src/main/java/com/alfresco/auth/AuthConfig.kt +++ b/auth/src/main/java/com/alfresco/auth/AuthConfig.kt @@ -75,3 +75,10 @@ enum class AuthTypeProvider { NEW_IDP, NONE; } + +enum class IdentityProvider { + KEYCLOAK, + AUTH0; + + fun value() = name.lowercase() +} diff --git a/auth/src/main/java/com/alfresco/auth/ui/AuthenticationActivity.kt b/auth/src/main/java/com/alfresco/auth/ui/AuthenticationActivity.kt index f1e79bd..e864812 100644 --- a/auth/src/main/java/com/alfresco/auth/ui/AuthenticationActivity.kt +++ b/auth/src/main/java/com/alfresco/auth/ui/AuthenticationActivity.kt @@ -14,6 +14,7 @@ import com.alfresco.auth.AuthInterceptor import com.alfresco.auth.AuthType import com.alfresco.auth.Credentials import com.alfresco.auth.DiscoveryService +import com.alfresco.auth.IdentityProvider import com.alfresco.auth.data.LiveEvent import com.alfresco.auth.data.MutableLiveEvent import com.alfresco.auth.data.OAuth2Data @@ -55,10 +56,9 @@ abstract class AuthenticationViewModel : ViewModel() { discoveryService = DiscoveryService(context, authConfig) val oAuth2Data = checkAppConfigOAuthType(discoveryService, endpoint) - val clientID = oAuth2Data?.clientId - val secret = oAuth2Data?.secret + val authType = oAuth2Data?.authType - if (clientID == "alfresco" && secret.isNullOrEmpty()) { + if (authType.isNullOrEmpty() || authType.lowercase() == IdentityProvider.KEYCLOAK.value()) { val authType = withContext(Dispatchers.IO) { discoveryService.getAuthType(endpoint) } onResult(authType, oAuth2Data) } else {