Skip to content

Conversation

@RawanMatar89
Copy link

@RawanMatar89 RawanMatar89 commented Feb 10, 2025

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:

Before After (both) After (SSO only)
b1 a1 a2

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Feb 10, 2025
@openedx-webhooks
Copy link

openedx-webhooks commented Feb 10, 2025

Thanks for the pull request, @RawanMatar89!

This repository is currently maintained by @openedx/openedx-mobile-maintainers.

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 approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To 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:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where 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:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@RawanMatar89 RawanMatar89 marked this pull request as ready for review February 10, 2025 08:42
@mphilbrick211 mphilbrick211 added the needs test run Author's first PR to this repository, awaiting test authorization from Axim label Feb 11, 2025
Copy link

@github-advanced-security github-advanced-security bot left a 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.

@e0d
Copy link

e0d commented Feb 14, 2025

@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:

#371

@xitij2000 can you chime in here?

@mphilbrick211 mphilbrick211 removed the needs test run Author's first PR to this repository, awaiting test authorization from Axim label Feb 14, 2025
@xitij2000
Copy link
Contributor

@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:

#371

@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.

@OmarIthawi
Copy link
Member

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?

@volodymyr-chekyrta
Copy link
Contributor

volodymyr-chekyrta commented Mar 14, 2025

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.
It may be a good discussion for the Mobile: Product SubGroup Meeting.

@RawanMatar89
Copy link
Author

RawanMatar89 commented Apr 8, 2025

Plan for this PR:

  • Resolve Conflicts: First, I will address the existing conflicts in this PR to ensure everything is aligned correctly.
  • Revert Web base LMS Auth PR: To maintain consistency between Android and iOS code, I will re the changes from Web base LMS Auth PR for now.
  • Cover Missing Cases: After the rollback, I will review the changes from Web base LMS Auth PR and ensure that any cases not already covered in our PR are addressed.

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.

cc: @xijit and @valimir

@mphilbrick211 mphilbrick211 added the needs test run Author's first PR to this repository, awaiting test authorization from Axim label May 12, 2025
@mphilbrick211 mphilbrick211 moved this from Waiting on Author to Needs Tests Run or CLA Signed in Contributions May 12, 2025
@mphilbrick211 mphilbrick211 removed the needs test run Author's first PR to this repository, awaiting test authorization from Axim label May 15, 2025
@mphilbrick211 mphilbrick211 moved this from Needs Tests Run or CLA Signed to Ready for Review in Contributions May 15, 2025
@mphilbrick211 mphilbrick211 requested a review from a team May 15, 2025 18:20
@RawanMatar89
Copy link
Author

dears, This PR is now ready for review.
Just to highlight, the approach used here is more advanced than the one in the reverted PR. With our implementation, both default and browser-based login options can coexist and be supported simultaneously. In contrast, the previous approach only allowed one login method to be available at a time.
Looking forward to your feedback!

@volodymyr-chekyrta , @xitij2000 , @valimir

@mphilbrick211
Copy link

Hi @openedx/openedx-mobile-maintainers! Would someone be able to please take a look at this?

@mphilbrick211
Copy link

Hi @openedx/openedx-mobile-maintainers! Would someone be able to please take a look at this?

Friendly ping on this @openedx/openedx-mobile-maintainers

@mphilbrick211 mphilbrick211 added the inactive PR author has been unresponsive for several months label Sep 16, 2025
@volodymyr-chekyrta
Copy link
Contributor

@RawanMatar89, could you please resolve conflicts on this PR? We will take it to review.
@IvanStepanok @PavloNetrebchuk fyi

@mphilbrick211 mphilbrick211 removed the inactive PR author has been unresponsive for several months label Sep 24, 2025
@OmarIthawi
Copy link
Member

@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.

 into SAML_SSO

# Conflicts:
#	app/src/main/java/org/openedx/app/AppActivity.kt
#	auth/build.gradle
#	auth/src/main/java/org/openedx/auth/presentation/sso/BrowserAuthHelper.kt
#	build.gradle
#	gradle/wrapper/gradle-wrapper.properties
@RawanMatar89 RawanMatar89 changed the title feat: add single sing on by saml feat: add single sign on by saml Sep 29, 2025
@RawanMatar89
Copy link
Author

@volodymyr-chekyrta, @OmarIthawi
Thanks for the reminder! I’ve resolved all conflicts, and the PR is now ready for review.

Copy link
Contributor

@IvanStepanok IvanStepanok left a 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,

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() }
so the very first onPageFinished can throw an NPE, and even when it doesn’t we concatenate header/payload/signature without the separating dot.
val jwtToken = getCookie(url, "edx-jwt-cookie-header-payload") + getCookie(url, "edx-jwt-cookie-signature")
onWebPageUpdated(jwtToken)
SSOWebContentFragment treats any non-empty result as success and pops the stack,
if (token.isNotEmpty()){
setFragmentResult("requestKey", bundleOf("bundleKey" to token))
requireActivity().supportFragmentManager.popBackStack()
and SignInFragment then hands ssoLogin the requestKey instead of the token from the bundle.
setFragmentResultListener("requestKey") { requestKey, bundle ->
viewModel.ssoLogin(token = requestKey)
Combined, this means ssoLogin ends up with garbage and the SSO attempt can never finish successfully.

}
if (state.isSSOLoginEnabled) {
Spacer(modifier = Modifier.height(18.dp))
if (state.isLoginRegistrationFormEnabled) {
Copy link
Contributor

Choose a reason for hiding this comment

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

if (!state.isLoginRegistrationFormEnabled) {

According to iOS implementation we need to hide this title in case when isLoginRegistrationFormEnabled = true
Screenshot 2025-10-02 at 16 37 16 Screenshot 2025-10-02 at 16 36 55

buttonWidth
.testTag("btn_sso")
.fillMaxWidth(),
text = stringResource(id = coreR.string.core_sso_sign_in),
Copy link
Contributor

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
Copy link
Contributor

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)


Copy link
Contributor

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")
Copy link
Contributor

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
Copy link
Contributor

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?

@mphilbrick211 mphilbrick211 moved this from Ready for Review to In Eng Review in Contributions Nov 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open-source-contribution PR author is not from Axim or 2U

Projects

Status: In Eng Review

Development

Successfully merging this pull request may close these issues.

8 participants