-
Notifications
You must be signed in to change notification settings - Fork 50
Expose a JavaScript API in brokered Webviews to facilitate Improved Same Device NumberMatch , Fixes AB#3203956 #2617
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
c4d3c81
add javascript api
fadidurah 1ffa139
changelog
fadidurah 243ccd7
dev
fadidurah ccfe0d2
comments
fadidurah 2945a5f
adjust api
fadidurah 2bd13c0
move some parameters around
fadidurah f478f41
comment out test code
fadidurah caf538c
remove helper method
fadidurah 5d26097
dev
fadidurah ee7a7c7
dev
fadidurah 8ae18e1
update to new JSON Schema
fadidurah bb18c6d
add check for ests url
fadidurah b8ee1ea
Merge branch 'dev' of https://github.com/AzureAD/microsoft-authentica…
fadidurah 0415ee7
update to DTO
fadidurah ab0a914
merge dev
fadidurah 9fe183c
spotbug fix
fadidurah 0f43c26
address comments, update js exposure
fadidurah b254993
adjust to comments, nonnull serialization
fadidurah c54ac38
Merge branch 'dev' of https://github.com/AzureAD/microsoft-authentica…
fadidurah 56ff04d
remove small detail
fadidurah 0e092e3
Merge branch 'dev' of https://github.com/AzureAD/microsoft-authentica…
fadidurah File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
...java/com/microsoft/identity/common/internal/numberMatch/NumberMatchJavaScriptInterface.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // All rights reserved. | ||
| // | ||
| // This code is licensed under the MIT License. | ||
| // | ||
| // Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| // of this software and associated documentation files(the "Software"), to deal | ||
| // in the Software without restriction, including without limitation the rights | ||
| // to use, copy, modify, merge, publish, distribute, sublicense, and / or sell | ||
| // copies of the Software, and to permit persons to whom the Software is | ||
| // furnished to do so, subject to the following conditions : | ||
| // | ||
| // The above copyright notice and this permission notice shall be included in | ||
| // all copies or substantial portions of the Software. | ||
| // | ||
| // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| // THE SOFTWARE. | ||
| package com.microsoft.identity.common.internal.numberMatch | ||
|
|
||
| import android.webkit.JavascriptInterface | ||
| import com.microsoft.identity.common.logging.Logger | ||
| import com.microsoft.identity.common.nativeauth.internal.commands.GetAuthMethodsCommand | ||
|
|
||
| /** | ||
| * Java Script API to be exposed as part of brokered WebView requests. | ||
| * Will be used by AuthUX as part of number match feature. | ||
| * When authenticator is installed, and phone uses MFA or PSI in an interactive flow, a number | ||
| * matching challenge is issued, where used is given a number and asked to open authenticator and check | ||
| * for the same number in authenticator UI. This feature cuts out one UI step, where this API is used to | ||
| * supply the number match value and store it in ephemeral storage (kept as long as current broker | ||
| * process is alive), where Authenticator can call a broker API to fetch the number match, and immediately | ||
| * prompt user for consent, rather than first asking them to check the number match. | ||
| */ | ||
| class NumberMatchJavaScriptInterface { | ||
|
|
||
| // Store number matches in a static hash map | ||
| // No need to persist this storage beyond the current broker process, but we need to keep them | ||
|
fadidurah marked this conversation as resolved.
|
||
| // long enough for AuthApp to call the broker api to fetch the number match | ||
| companion object { | ||
| val TAG = NumberMatchJavaScriptInterface::class.java.simpleName | ||
| val numberMatchMap: HashMap<String?, String?> = HashMap() | ||
|
fadidurah marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| /** | ||
| * Method to add a key:value pair of sessionID:numberMatch to static hashmap. This hashmap will be accessed | ||
| * by broker api to get the number match for a particular sessionID. | ||
| */ | ||
| @JavascriptInterface | ||
| fun postCodeMatch(sessionID : String?, numberMatch : String?) { | ||
|
fadidurah marked this conversation as resolved.
Outdated
|
||
| // If both parameters are non-null, add a new entry to the hashmap | ||
| if (sessionID != null && numberMatch != null) { | ||
| val methodTag = "$TAG:postCodeMatch" | ||
| Logger.info( | ||
| methodTag, | ||
| "Adding entry in NumberMatch hashmap for session ID: $sessionID" | ||
| ) | ||
| numberMatchMap[sessionID] = numberMatch | ||
| } | ||
|
|
||
| // If either parameter is null, do nothing | ||
| } | ||
|
|
||
| /** | ||
| * Clear existing number match key:value pairs | ||
| */ | ||
| fun clearNumberMatchMap() { | ||
| numberMatchMap.clear() | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.