-
Notifications
You must be signed in to change notification settings - Fork 167
breaking : Moved the useDPoP method in the WebAuthProvider class to the login builder class
#914
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
Changes from all commits
fb019c7
c8eb947
507f0c9
dfe218c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,10 +27,9 @@ import kotlin.coroutines.resumeWithException | |
| * | ||
| * It uses an external browser by sending the [android.content.Intent.ACTION_VIEW] intent. | ||
| */ | ||
| public object WebAuthProvider : SenderConstraining<WebAuthProvider> { | ||
| public object WebAuthProvider { | ||
| private val TAG: String? = WebAuthProvider::class.simpleName | ||
| private const val KEY_BUNDLE_OAUTH_MANAGER_STATE = "oauth_manager_state" | ||
| private var dPoP : DPoP? = null | ||
|
|
||
| private val callbacks = CopyOnWriteArraySet<Callback<Credentials, AuthenticationException>>() | ||
|
|
||
|
|
@@ -49,12 +48,6 @@ public object WebAuthProvider : SenderConstraining<WebAuthProvider> { | |
| callbacks -= callback | ||
| } | ||
|
|
||
| // Public methods | ||
| public override fun useDPoP(context: Context): WebAuthProvider { | ||
| dPoP = DPoP(context) | ||
| return this | ||
| } | ||
|
|
||
| /** | ||
| * Initialize the WebAuthProvider instance for logging out the user using an account. Additional settings can be configured | ||
| * in the LogoutBuilder, like changing the scheme of the return to URL. | ||
|
|
@@ -119,7 +112,7 @@ public object WebAuthProvider : SenderConstraining<WebAuthProvider> { | |
| } | ||
| } | ||
|
|
||
| internal fun onRestoreInstanceState(bundle: Bundle) { | ||
| internal fun onRestoreInstanceState(bundle: Bundle, context: Context) { | ||
| if (managerInstance == null) { | ||
| val stateJson = bundle.getString(KEY_BUNDLE_OAUTH_MANAGER_STATE).orEmpty() | ||
| if (stateJson.isNotBlank()) { | ||
|
|
@@ -138,7 +131,8 @@ public object WebAuthProvider : SenderConstraining<WebAuthProvider> { | |
| callback.onFailure(error) | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| context | ||
| ) | ||
| } | ||
| } | ||
|
|
@@ -305,14 +299,15 @@ public object WebAuthProvider : SenderConstraining<WebAuthProvider> { | |
| } | ||
| } | ||
|
|
||
| public class Builder internal constructor(private val account: Auth0) { | ||
| public class Builder internal constructor(private val account: Auth0) : SenderConstraining<Builder> { | ||
| private val values: MutableMap<String, String> = mutableMapOf() | ||
| private val headers: MutableMap<String, String> = mutableMapOf() | ||
| private var pkce: PKCE? = null | ||
| private var issuer: String? = null | ||
| private var scheme: String = "https" | ||
| private var redirectUri: String? = null | ||
| private var invitationUrl: String? = null | ||
| private var dPoP: DPoP? = null | ||
| private var ctOptions: CustomTabsOptions = CustomTabsOptions.newBuilder().build() | ||
| private var leeway: Int? = null | ||
| private var launchAsTwa: Boolean = false | ||
|
|
@@ -548,6 +543,18 @@ public object WebAuthProvider : SenderConstraining<WebAuthProvider> { | |
| return this | ||
| } | ||
|
|
||
| /** | ||
| * Enable DPoP (Demonstrating Proof-of-Possession) for this authentication request. | ||
| * DPoP binds access tokens to the client's cryptographic key, providing enhanced security. | ||
| * | ||
| * @param context the Android context used to access the keystore for DPoP key management | ||
| * @return the current builder instance | ||
| */ | ||
| public override fun useDPoP(context: Context): Builder { | ||
| dPoP = DPoP(context) | ||
| return this | ||
| } | ||
|
Comment on lines
+553
to
+556
|
||
|
|
||
| /** | ||
| * Request user Authentication. The result will be received in the callback. | ||
| * An error is raised if there are no browser applications installed in the device, or if | ||
|
|
||
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.
Now that DPoP is scoped to the Builder (no longer on the singleton), the DPoP state won't survive process death. OAuthManager.toState() doesn't persist DPoP, and fromState() restores without it — so a DPoP-enabled login will silently resume without DPoP proofs if the OS kills the activity mid-redirect.
Please add a dpoPEnabled: Boolean flag to OAuthManagerState, persist it in toState(), and reconstruct DPoP(context) in fromState() when the flag is true. No need to serialize the DPoP instance itself (it holds a Context).
Please:
1>Add dpoPEnabled: Boolean = false to OAuthManagerState
2>Set it in toState() based on dPoP != null
3>In fromState(), if dpoPEnabled == true, pass DPoP(context) to the reconstructed OAuthManager
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.
Addressed this