Skip to content
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

Adding WebAuthn query parameter switch to msalTestApp #1888

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion common
Submodule common updated 0 files
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public class AcquireTokenFragment extends Fragment {
private EditText mClaims;
private Button mAddDeviceIdClaimButton;
private Button mAddNgcMfaClaimButton;
private Switch mWebauthnQueryParameter;
private Switch mEnablePII;
private Switch mForceRefresh;
private Switch mEnableNewBrokerDiscovery;
Expand Down Expand Up @@ -153,6 +154,7 @@ public void onClick(View v) {
}
});

mWebauthnQueryParameter = view.findViewById(R.id.webauthnQueryParameter);
mEnablePII = view.findViewById(enablePII);
mForceRefresh = view.findViewById(R.id.forceRefresh);
mSelectAccount = view.findViewById(R.id.select_user);
Expand Down Expand Up @@ -582,6 +584,7 @@ private RequestOptions getCurrentRequestOptions() {
final String scopes = mScope.getText().toString();
final String extraScopesToConsent = mExtraScope.getText().toString();
final String claims = mClaims.getText().toString();
final boolean webauthnQueryParameter = mWebauthnQueryParameter.isChecked();
final boolean enablePII = mEnablePII.isChecked();
final boolean forceRefresh = mForceRefresh.isChecked();
final String authority = mAuthority.getText().toString();
Expand All @@ -601,6 +604,7 @@ private RequestOptions getCurrentRequestOptions() {
scopes,
extraScopesToConsent,
claims,
webauthnQueryParameter,
enablePII,
forceRefresh,
authority,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@
import com.microsoft.identity.client.exception.MsalException;
import com.microsoft.identity.client.exception.MsalServiceException;
import com.microsoft.identity.client.exception.MsalUiRequiredException;
import com.microsoft.identity.common.internal.fido.FidoConstants;
import com.microsoft.identity.common.java.util.StringUtil;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;

/// Acting as a bridge between the result of MsalWrapper's results and the outside world.
interface INotifyOperationResultCallback<T> {
Expand Down Expand Up @@ -121,6 +125,16 @@ private AcquireTokenParameters.Builder getAcquireTokenParametersBuilder(@NonNull
builder.withClaims(ClaimsRequest.getClaimsRequestFromJsonString(requestOptions.getClaims()));
}

if (requestOptions.isWebauthnQueryParameter()) {
final List<Map.Entry<String, String>> extraQueryParameters = new ArrayList<>();
extraQueryParameters.add(
new AbstractMap.SimpleEntry<>(
FidoConstants.WEBAUTHN_QUERY_PARAMETER_FIELD,
FidoConstants.WEBAUTHN_QUERY_PARAMETER_VALUE
));
builder.withAuthorizationQueryStringParameters(extraQueryParameters);
}

if (requestOptions.getAuthScheme() == Constants.AuthScheme.POP) {
try {
builder.withAuthenticationScheme(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class RequestOptions {
private final String mScopes;
private final String mExtraScope;
private final String mClaims;
private final boolean mWebauthnQueryParameter;
private final boolean mEnablePII;
private final boolean mForceRefresh;
private final String mAuthority;
Expand Down
21 changes: 21 additions & 0 deletions testapps/testapp/src/main/res/layout/fragment_acquire.xml
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,27 @@
android:textSize="12sp" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:weightSum="5">

<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4"
android:text="@string/webauthn_query_parameters" />

<Switch
android:id="@+id/webauthnQueryParameter"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down
1 change: 1 addition & 0 deletions testapps/testapp/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,5 @@
<string name="clear_active_broker_cache">Clear Active Broker Cache</string>
<string name="current_cached_active_broker">Cached Active Broker</string>
<string name="none">None</string>
<string name="webauthn_query_parameters">WebAuthn Query Parameter</string>
</resources>