Skip to content

Commit ec9a066

Browse files
authored
Merge pull request #8620 from vector-im/feature/bma/oidcSessionEnd
Feature/bma/OIDC session end
2 parents 1f41c54 + 52a0693 commit ec9a066

21 files changed

+148
-20
lines changed

changelog.d/8616.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
If an external account manager is configured on the server, use it to delete other sessions and hide the multi session deletion.

matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/homeserver/HomeServerCapabilities.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ data class HomeServerCapabilities(
8585
* External account management url for use with MSC3824 delegated OIDC, provided in Wellknown.
8686
*/
8787
val externalAccountManagementUrl: String? = null,
88+
89+
/**
90+
* Authentication issuer for use with MSC3824 delegated OIDC, provided in Wellknown.
91+
*/
92+
val authenticationIssuer: String? = null,
8893
) {
8994

9095
enum class RoomCapabilitySupport {
@@ -141,6 +146,8 @@ data class HomeServerCapabilities(
141146
return cap?.preferred ?: cap?.support?.lastOrNull()
142147
}
143148

149+
val delegatedOidcAuthEnabled: Boolean = authenticationIssuer != null
150+
144151
companion object {
145152
const val MAX_UPLOAD_FILE_SIZE_UNKNOWN = -1L
146153
const val ROOM_CAP_KNOCK = "knock"

matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/DefaultAuthenticationService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ internal class DefaultAuthenticationService @Inject constructor(
298298
}
299299

300300
// If an m.login.sso flow is present that is flagged as being for MSC3824 OIDC compatibility then we only return that flow
301-
val oidcCompatibilityFlow = loginFlowResponse.flows.orEmpty().firstOrNull { it.type == "m.login.sso" && it.delegatedOidcCompatibilty == true }
301+
val oidcCompatibilityFlow = loginFlowResponse.flows.orEmpty().firstOrNull { it.type == "m.login.sso" && it.delegatedOidcCompatibility == true }
302302
val flows = if (oidcCompatibilityFlow != null) listOf(oidcCompatibilityFlow) else loginFlowResponse.flows
303303

304304
val supportsGetLoginTokenFlow = loginFlowResponse.flows.orEmpty().firstOrNull { it.type == "m.login.token" && it.getLoginToken == true } != null

matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/data/LoginFlowResponse.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ internal data class LoginFlow(
5151
* See [MSC3824](https://github.com/matrix-org/matrix-spec-proposals/pull/3824)
5252
*/
5353
@Json(name = "org.matrix.msc3824.delegated_oidc_compatibility")
54-
val delegatedOidcCompatibilty: Boolean? = null,
54+
val delegatedOidcCompatibility: Boolean? = null,
5555

5656
/**
5757
* Whether a login flow of type m.login.token could accept a token issued using /login/get_token.

matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmSessionStoreMigration.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo049
6969
import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo050
7070
import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo051
7171
import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo052
72+
import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo053
7273
import org.matrix.android.sdk.internal.util.Normalizer
7374
import org.matrix.android.sdk.internal.util.database.MatrixRealmMigration
7475
import javax.inject.Inject
@@ -77,7 +78,7 @@ internal class RealmSessionStoreMigration @Inject constructor(
7778
private val normalizer: Normalizer
7879
) : MatrixRealmMigration(
7980
dbName = "Session",
80-
schemaVersion = 52L,
81+
schemaVersion = 53L,
8182
) {
8283
/**
8384
* Forces all RealmSessionStoreMigration instances to be equal.
@@ -139,5 +140,6 @@ internal class RealmSessionStoreMigration @Inject constructor(
139140
if (oldVersion < 50) MigrateSessionTo050(realm).perform()
140141
if (oldVersion < 51) MigrateSessionTo051(realm).perform()
141142
if (oldVersion < 52) MigrateSessionTo052(realm).perform()
143+
if (oldVersion < 53) MigrateSessionTo053(realm).perform()
142144
}
143145
}

matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/HomeServerCapabilitiesMapper.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ internal object HomeServerCapabilitiesMapper {
4949
canRemotelyTogglePushNotificationsOfDevices = entity.canRemotelyTogglePushNotificationsOfDevices,
5050
canRedactRelatedEvents = entity.canRedactEventWithRelations,
5151
externalAccountManagementUrl = entity.externalAccountManagementUrl,
52+
authenticationIssuer = entity.authenticationIssuer,
5253
)
5354
}
5455

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2023 The Matrix.org Foundation C.I.C.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.matrix.android.sdk.internal.database.migration
18+
19+
import io.realm.DynamicRealm
20+
import org.matrix.android.sdk.internal.database.model.HomeServerCapabilitiesEntityFields
21+
import org.matrix.android.sdk.internal.extensions.forceRefreshOfHomeServerCapabilities
22+
import org.matrix.android.sdk.internal.util.database.RealmMigrator
23+
24+
internal class MigrateSessionTo053(realm: DynamicRealm) : RealmMigrator(realm, 53) {
25+
override fun doMigrate(realm: DynamicRealm) {
26+
realm.schema.get("HomeServerCapabilitiesEntity")
27+
?.addField(HomeServerCapabilitiesEntityFields.AUTHENTICATION_ISSUER, String::class.java)
28+
?.forceRefreshOfHomeServerCapabilities()
29+
}
30+
}

matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/HomeServerCapabilitiesEntity.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ internal open class HomeServerCapabilitiesEntity(
3636
var canRemotelyTogglePushNotificationsOfDevices: Boolean = false,
3737
var canRedactEventWithRelations: Boolean = false,
3838
var externalAccountManagementUrl: String? = null,
39+
var authenticationIssuer: String? = null,
3940
) : RealmObject() {
4041

4142
companion object

matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/homeserver/GetHomeServerCapabilitiesTask.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ internal class DefaultGetHomeServerCapabilitiesTask @Inject constructor(
165165
Timber.v("Extracted integration config : $config")
166166
realm.insertOrUpdate(config)
167167
}
168+
homeServerCapabilitiesEntity.authenticationIssuer = getWellknownResult.wellKnown.unstableDelegatedAuthConfig?.issuer
168169
homeServerCapabilitiesEntity.externalAccountManagementUrl = getWellknownResult.wellKnown.unstableDelegatedAuthConfig?.accountManagementUrl
169170
}
170171

vector/src/main/java/im/vector/app/features/settings/devices/DevicesViewEvents.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,6 @@ sealed class DevicesViewEvents : VectorViewEvents {
5050
data class ShowManuallyVerify(val cryptoDeviceInfo: CryptoDeviceInfo) : DevicesViewEvents()
5151

5252
object PromptResetSecrets : DevicesViewEvents()
53+
54+
data class OpenBrowser(val url: String) : DevicesViewEvents()
5355
}

0 commit comments

Comments
 (0)