Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/bma/OIDC session end #8620

Merged
merged 8 commits into from Sep 12, 2023
Merged

Feature/bma/OIDC session end #8620

merged 8 commits into from Sep 12, 2023

Conversation

bmarty
Copy link
Member

@bmarty bmarty commented Aug 22, 2023

Type of change

Content

If an external account manager is configured on the server, use it to delete other session.

Note that the session Id is provided, but the web page does not use it. This is out of scope of this PR to fix that.

Also in this case, hide the delete all other sessions menu entries.

Motivation and context

Closes #8616

Screenshots / GIFs

Tests

  • Tested OK with my account on element.io.

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

@bmarty bmarty requested a review from hughns August 22, 2023 10:43
Copy link
Member

@hughns hughns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments inline.

Also, as per internal discussion, we might need to change the wording/have an interstitial after pressing Sign Out.

if (otherDevices.isNullOrEmpty()) {
hideOtherSessionsView()
} else {
views.deviceListHeaderOtherSessions.isVisible = true
val colorDestructive = colorProvider.getColorFromAttribute(R.attr.colorError)
val multiSignoutItem = views.deviceListHeaderOtherSessions.menu.findItem(R.id.otherSessionsHeaderMultiSignout)
// Hide multi signout if we have an external account manager
multiSignoutItem.isVisible = state.externalAccountManagementUrl == null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because delegated OIDC can be enabled on the homeserver, but the homeserver does not have to provide an external account managemnt URL this should be tried to a new property like HomeServerCapabilities.delegatedOidcAuthEnabled.

See https://github.com/vector-im/element-android/pull/8627/files#r1305379005 for more context.

views.deviceListHeaderCurrentSession.isVisible = true
val colorDestructive = colorProvider.getColorFromAttribute(R.attr.colorError)
val signoutSessionItem = views.deviceListHeaderCurrentSession.menu.findItem(R.id.currentSessionHeaderSignout)
signoutSessionItem.setTextColor(colorDestructive)
val signoutOtherSessionsItem = views.deviceListHeaderCurrentSession.menu.findItem(R.id.currentSessionHeaderSignoutOtherSessions)
signoutOtherSessionsItem.setTextColor(colorDestructive)
signoutOtherSessionsItem.isVisible = hasOtherDevices
// Hide signout other sessions if we have an external account manager
signoutOtherSessionsItem.isVisible = hasOtherDevices && state.externalAccountManagementUrl == null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto should be linked to HomeServerCapabilities.delegatedOidcAuthEnabled.

@@ -103,10 +103,15 @@ class OtherSessionsFragment :
val nbDevices = viewState.devices()?.size ?: 0
stringProvider.getQuantityString(R.plurals.device_manager_other_sessions_multi_signout_all, nbDevices, nbDevices)
}
multiSignoutItem.isVisible = if (viewState.isSelectModeEnabled) {
viewState.devices.invoke()?.any { it.isSelected }.orFalse()
multiSignoutItem.isVisible = if (viewState.externalAccountManagementUrl != null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto should be linked to HomeServerCapabilities.delegatedOidcAuthEnabled.

We do not need an external account management URL, which is optional, but we need to know if account management is delegate to Oidc.
@bmarty
Copy link
Member Author

bmarty commented Aug 31, 2023

@hughns I have updated the PR, but I do not understand, on my emulator, the Realm migration is running well, but then the field in the Realm entity are always null. Even when reverting the change (and doing a fresh install), the code does not work. Can you try on your side with the latest version from this branch? Thanks.

@sonarcloud
Copy link

sonarcloud bot commented Aug 31, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

0.0% 0.0% Coverage
18.2% 18.2% Duplication

warning The version of Java (11.0.20.1) you have used to run this analysis is deprecated and we will stop accepting it soon. Please update to at least Java 17.
Read more here

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@hughns
Copy link
Member

hughns commented Sep 1, 2023

@hughns I have updated the PR, but I do not understand, on my emulator, the Realm migration is running well, but then the field in the Realm entity are always null. Even when reverting the change (and doing a fresh install), the code does not work. Can you try on your side with the latest version from this branch? Thanks.

I don't have an existing install to test with, but I've done a new install and it is working for me as I would expect. 🤷‍♂️

@bmarty
Copy link
Member Author

bmarty commented Sep 12, 2023

OK, let's merge this then.

@bmarty bmarty merged commit ec9a066 into develop Sep 12, 2023
15 of 17 checks passed
@bmarty bmarty deleted the feature/bma/oidcSessionEnd branch September 12, 2023 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EA: Link to MAS for sign-out of other devices in MSC3824 OIDC-aware mode
2 participants