-
Notifications
You must be signed in to change notification settings - Fork 45
feat: add single sign on by saml #420
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
base: develop
Are you sure you want to change the base?
Conversation
|
Thanks for the pull request, @RawanMatar89! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
detekt found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
|
@RawanMatar89 it looks like there are some failing tests and checks, can you have a look. We can review this when the checks are passing. I also want to make sure we ensure this work meshes will with this: @xitij2000 can you chime in here? |
I am currently unable to test the code or have a deeper look; however, I do see some overlap. #371 adds a web-browser based flow that will initiate an OAuth flow with the LMS, delegating the actual login mechanism to whatever IdPs are set up at the LMS including any SAML-based ones. So from what I understand, what this PR is doing is already possible using the existing code. |
@xitij2000 good note that what I was thinking of when I looked at your WebView code. For a background, the original work has been done in the iOS app and is already merged since July 2024: This PR has gone stale a bit due to the review process and our internal prioritizations. My recommendation is to keep the iOS and the Android in a very similar flow in regards to backend integration and YAML configurations. @e0d @volodymyr-chekyrta How do you recommend going on with this? |
Good question. I would like to see a similar approach and feature flags for both platforms. |
|
Plan for this PR:
This approach will help keep both the Android and iOS code versions in sync while maintaining any necessary improvements from Web base LMS Auth PR work. |
|
dears, This PR is now ready for review. |
|
Hi @openedx/openedx-mobile-maintainers! Would someone be able to please take a look at this? |
Friendly ping on this @openedx/openedx-mobile-maintainers |
|
@RawanMatar89, could you please resolve conflicts on this PR? We will take it to review. |
|
@RawanMatar89 another ping for the rebase and conflict fixing. This is still on our plate and we'll push for it to get merged. Thanks @mphilbrick211 and @volodymyr-chekyrta for reviving it. |
|
@volodymyr-chekyrta, @OmarIthawi |
IvanStepanok
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m worried about the SSO login flow here. In SSOWebContentScreen we read cookies without null checks and immediately split them,
openedx-app-android/core/src/main/java/org/openedx/core/ui/SSOWebContentScreen.kt
Lines 171 to 176 in 2207571
| fun getCookie(siteName: String?, cookieName: String?): String? { | |
| var cookieValue: String? = "" | |
| val cookieManager = CookieManager.getInstance() | |
| val cookies = cookieManager.getCookie(siteName) | |
| val temp = cookies.split(";".toRegex()).dropLastWhile { it.isEmpty() } |
openedx-app-android/core/src/main/java/org/openedx/core/ui/SSOWebContentScreen.kt
Lines 125 to 126 in 2207571
| val jwtToken = getCookie(url, "edx-jwt-cookie-header-payload") + getCookie(url, "edx-jwt-cookie-signature") | |
| onWebPageUpdated(jwtToken) |
Lines 43 to 45 in 2207571
| if (token.isNotEmpty()){ | |
| setFragmentResult("requestKey", bundleOf("bundleKey" to token)) | |
| requireActivity().supportFragmentManager.popBackStack() |
openedx-app-android/auth/src/main/java/org/openedx/auth/presentation/signin/SignInFragment.kt
Lines 47 to 48 in 2207571
| setFragmentResultListener("requestKey") { requestKey, bundle -> | |
| viewModel.ssoLogin(token = requestKey) |
| } | ||
| if (state.isSSOLoginEnabled) { | ||
| Spacer(modifier = Modifier.height(18.dp)) | ||
| if (state.isLoginRegistrationFormEnabled) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| buttonWidth | ||
| .testTag("btn_sso") | ||
| .fillMaxWidth(), | ||
| text = stringResource(id = coreR.string.core_sso_sign_in), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are ignoring SSO_BUTTON_TITLE parameter on config file here
| } | ||
|
|
||
| viewModel { (courseId: String?, infoType: String?, authCode: String) -> | ||
| val lang = Resources.getSystem().configuration.locales[0].language |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lang is lowercased here but in
SSO_BUTTON_TITLE:
AR: "الدخول عبر SSO"
EN: "Sign in with SSO"
parameters are uppercased. Can’t check this because in current implementation we are ignoring SSO_BUTTON_TITLE
| fun ssoLogin(token: String) { | ||
| logEvent(AuthAnalyticsEvent.USER_SIGN_IN_CLICKED) | ||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to add the same logic as on default Login where we have a clean calendar and synchronize FCM if users are changed.
| _uiState.update { it.copy(showProgress = true) } | ||
| viewModelScope.launch { | ||
| try { | ||
| interactor.ssoLogin("JWT $token") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cant check this, but looks like we will return here duplicates of "JWT". Like "JWTJWT token1323231232".
| if (preferencesManager.accessToken.isBlank() || | ||
| preferencesManager.refreshToken.isBlank()){ | ||
| preferencesManager.accessToken = jwtToken | ||
| preferencesManager.refreshToken = jwtToken |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to update accessTokenExpiresAt here?


Describtion:
as in iOS, we added a new button in sign in view named "Sign in with SSO" to be use for opening single sign on web view
TODO:
Screenshots: