-
Notifications
You must be signed in to change notification settings - Fork 46
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?
Changes from all commits
eb3f8a9
135a305
6a4500c
fa5f13a
2207571
316ebc4
4e1ce2c
e2badfd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
|
|
||
| import android.os.Bundle | ||
| import android.view.LayoutInflater | ||
| import android.view.View | ||
| import android.view.ViewGroup | ||
| import androidx.compose.runtime.LaunchedEffect | ||
| import androidx.compose.runtime.collectAsState | ||
|
|
@@ -11,6 +12,7 @@ | |
| import androidx.compose.ui.platform.ViewCompositionStrategy | ||
| import androidx.core.os.bundleOf | ||
| import androidx.fragment.app.Fragment | ||
| import androidx.fragment.app.setFragmentResultListener | ||
| import org.koin.androidx.viewmodel.ext.android.viewModel | ||
| import org.koin.core.parameter.parametersOf | ||
| import org.openedx.auth.data.model.AuthType | ||
|
|
@@ -25,8 +27,7 @@ | |
| private val viewModel: SignInViewModel by viewModel { | ||
| parametersOf( | ||
| requireArguments().getString(ARG_COURSE_ID, ""), | ||
| requireArguments().getString(ARG_INFO_TYPE, ""), | ||
| requireArguments().getString(ARG_AUTH_CODE, ""), | ||
| requireArguments().getString(ARG_INFO_TYPE, "") | ||
| ) | ||
| } | ||
|
|
||
|
|
@@ -44,16 +45,15 @@ | |
| val appUpgradeEvent by viewModel.appUpgradeEvent.observeAsState(null) | ||
|
|
||
| if (appUpgradeEvent == null) { | ||
| if (viewModel.authCode != "" && !state.loginFailure && !state.loginSuccess) { | ||
| viewModel.signInAuthCode(viewModel.authCode) | ||
| } | ||
|
|
||
| LoginScreen( | ||
Check warningCode scanning / detekt Reports methods that have an empty first line. Warning
First line in a method block should not be empty
|
||
| windowSize = windowSize, | ||
| state = state, | ||
| uiMessage = uiMessage, | ||
| onEvent = { event -> | ||
| when (event) { | ||
| is AuthEvent.SignIn -> viewModel.login(event.login, event.password) | ||
| is AuthEvent.SsoSignIn -> viewModel.ssoClicked(parentFragmentManager) | ||
| is AuthEvent.SocialSignIn -> viewModel.socialAuth( | ||
| this@SignInFragment, | ||
| event.authType | ||
|
|
@@ -63,10 +63,6 @@ | |
| viewModel.navigateToForgotPassword(parentFragmentManager) | ||
| } | ||
|
|
||
| AuthEvent.SignInBrowser -> { | ||
| viewModel.signInBrowser(requireActivity()) | ||
| } | ||
|
|
||
| AuthEvent.RegisterClick -> { | ||
| viewModel.navigateToSignUp(parentFragmentManager) | ||
| } | ||
|
|
@@ -97,16 +93,21 @@ | |
| } | ||
| } | ||
|
|
||
| override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
| super.onViewCreated(view, savedInstanceState) | ||
| setFragmentResultListener("requestKey") { _, bundle -> | ||
| val token = bundle.getString("bundleKey") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please move "requestKey" and "bundleKey" to companion object. Reuse it for SSOWebContentFragment.kt too |
||
| viewModel.ssoLogin(token = "$token") | ||
| } | ||
| } | ||
| companion object { | ||
| private const val ARG_COURSE_ID = "courseId" | ||
| private const val ARG_INFO_TYPE = "info_type" | ||
| private const val ARG_AUTH_CODE = "auth_code" | ||
| fun newInstance(courseId: String?, infoType: String?, authCode: String? = null): SignInFragment { | ||
| fun newInstance(courseId: String?, infoType: String?): SignInFragment { | ||
| val fragment = SignInFragment() | ||
| fragment.arguments = bundleOf( | ||
| ARG_COURSE_ID to courseId, | ||
| ARG_INFO_TYPE to infoType, | ||
| ARG_AUTH_CODE to authCode, | ||
| ARG_INFO_TYPE to infoType | ||
| ) | ||
| return fragment | ||
| } | ||
|
|
@@ -115,9 +116,9 @@ | |
|
|
||
| internal sealed interface AuthEvent { | ||
| data class SignIn(val login: String, val password: String) : AuthEvent | ||
| data class SsoSignIn(val jwtToken: String) : AuthEvent | ||
| data class SocialSignIn(val authType: AuthType) : AuthEvent | ||
| data class OpenLink(val links: Map<String, String>, val link: String) : AuthEvent | ||
| object SignInBrowser : AuthEvent | ||
| object RegisterClick : AuthEvent | ||
| object ForgotPasswordClick : AuthEvent | ||
| object BackClick : AuthEvent | ||
|
|
||
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