Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ef004d34 authored by Fahim Salam Chowdhury's avatar Fahim Salam Chowdhury 👽 Committed by Vincent Bourgmayer
Browse files

6287 feature openid support for murena account

parent 0685b179
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -6,6 +6,9 @@ stages:

before_script:
  - echo email.key=$PEPPER >> local.properties
  - echo MURENA_CLIENT_ID=$MURENA_CLIENT_ID >> local.properties
  - echo MURENA_CLIENT_SECRET=$MURENA_CLIENT_SECRET >> local.properties
  - echo MURENA_REDIRECT_URI=$MURENA_REDIRECT_URI >> local.properties
  - echo GOOGLE_CLIENT_ID=$GOOGLE_CLIENT_ID >> local.properties
  - echo GOOGLE_REDIRECT_URI=$GOOGLE_REDIRECT_URI >> local.properties
  - echo YAHOO_CLIENT_ID=$YAHOO_CLIENT_ID >> local.properties
+6 −1
Original line number Diff line number Diff line
@@ -108,6 +108,10 @@ android {
    }

    defaultConfig {
        buildConfigField "String", "MURENA_CLIENT_ID", "\"${retrieveKey("MURENA_CLIENT_ID")}\""
        buildConfigField "String", "MURENA_CLIENT_SECRET", "\"${retrieveKey("MURENA_CLIENT_SECRET")}\""
        buildConfigField "String", "MURENA_REDIRECT_URI", "\"${retrieveKey("MURENA_REDIRECT_URI")}\""

        buildConfigField "String", "GOOGLE_CLIENT_ID", "\"${retrieveKey("GOOGLE_CLIENT_ID")}\""
        buildConfigField "String", "GOOGLE_REDIRECT_URI", "\"${retrieveKey("GOOGLE_REDIRECT_URI")}\""

@@ -115,7 +119,8 @@ android {

	    manifestPlaceholders = [
                'appAuthRedirectScheme':  applicationId,
                "googleAuthRedirectScheme": retrieveKey("GOOGLE_REDIRECT_URI")
                "googleAuthRedirectScheme": retrieveKey("GOOGLE_REDIRECT_URI"),
                "murenaAuthRedirectScheme": retrieveKey("MURENA_REDIRECT_URI")
        ]
    }

+1 −0
Original line number Diff line number Diff line
@@ -677,6 +677,7 @@

                <data android:scheme="${appAuthRedirectScheme}" />
                <data android:scheme="${googleAuthRedirectScheme}" />
                <data android:scheme="${murenaAuthRedirectScheme}" />
            </intent-filter>

        </activity>
+11 −0
Original line number Diff line number Diff line
@@ -33,6 +33,17 @@ import at.bitfire.davdroid.BuildConfig;
 */
public class IdentityProvider {

    public static final IdentityProvider MURENA = new IdentityProvider(
            "https://accounts.eeo.one/auth/realms/eeo.one/.well-known/openid-configuration",
            null,
            null,
            BuildConfig.MURENA_CLIENT_ID,
            BuildConfig.MURENA_CLIENT_SECRET,
            BuildConfig.MURENA_REDIRECT_URI + ":/redirect",
            "openid address profile email phone roles offline_access web-origins microprofile-jwt",
            null
    );

    public static final IdentityProvider GOOGLE = new IdentityProvider(
            "https://accounts.google.com/.well-known/openid-configuration",
            null,
+27 −4
Original line number Diff line number Diff line
@@ -156,10 +156,9 @@ class HttpClient private constructor(
            }

            // use account settings for authentication and cookies
            if (accountSettings != null)
                addAuthentication(null, accountSettings.credentials(), authStateCallback = { authState: AuthState ->
                    accountSettings.credentials(Credentials(authState = authState))
                })
            if (accountSettings != null) {
                addAuthentication(accountSettings)
            }
        }

        constructor(context: Context, host: String?, credentials: Credentials?) : this(context) {
@@ -167,6 +166,30 @@ class HttpClient private constructor(
                addAuthentication(host, credentials)
        }

        private fun addAuthentication(accountSettings: AccountSettings) {
            val credential = accountSettings.credentials()

            addAuthentication(
                null,
                credential,
                authStateCallback = { authState: AuthState ->
                    updateCredentials(accountSettings, authState, credential.clientSecret)
                })
        }

        private fun updateCredentials(
            accountSettings: AccountSettings,
            authState: AuthState,
            clientSecret: String?
        ) {
            accountSettings.credentials(
                Credentials(
                    authState = authState,
                    clientSecret = clientSecret
                )
            )
        }

        fun addAuthentication(host: String?, credentials: Credentials, insecurePreemptive: Boolean = false, authStateCallback: BearerAuthInterceptor.AuthStateUpdateCallback? = null): Builder {
            if (credentials.userName != null && credentials.password != null) {
                val authHandler = BasicDigestAuthHandler(UrlUtils.hostToDomain(host), credentials.userName, credentials.password, insecurePreemptive)
Loading