Skip to content

Commit daea3f6

Browse files
rlatapy-lunaminbi
authored andcommitted
Add support of idp_identifier field for /oauth/authorization endpoint
1 parent 99cc184 commit daea3f6

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

aws-android-sdk-cognitoauth/src/main/java/com/amazonaws/mobileconnectors/cognitoauth/Auth.java

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ public final class Auth {
5454
*/
5555
private final String identityProvider;
5656

57+
/**
58+
* Idp indentifier for provider mapping
59+
*/
60+
private final String idpIdentifier;
61+
5762
/**
5863
* This identifies the settings for additional userPool features.
5964
*/
@@ -137,7 +142,8 @@ private Auth(final Context context,
137142
final Set<String> scopes,
138143
final AuthHandler userHandler,
139144
final boolean advancedSecurityDataCollectionFlag,
140-
final String identityProvider) {
145+
final String identityProvider,
146+
final String idpIdentifier) {
141147
this.context = context;
142148
this.appWebDomain = appWebDomain;
143149
this.appId = appId;
@@ -151,6 +157,7 @@ private Auth(final Context context,
151157
this.userPoolId = userPoolId;
152158
this.advancedSecurityDataCollectionFlag = advancedSecurityDataCollectionFlag;
153159
this.identityProvider = identityProvider;
160+
this.idpIdentifier = idpIdentifier;
154161
getCurrentUser();
155162
}
156163

@@ -210,6 +217,11 @@ public static final class Builder {
210217
*/
211218
private String mIdentityProvider;
212219

220+
/**
221+
* Idp identifier for the userPool.
222+
*/
223+
private String mIdpIdentifier;
224+
213225
/**
214226
* Flag indicating if data collection for advanced security mode is enabled.
215227
* By default this is enabled.
@@ -373,6 +385,20 @@ public Builder setIdentityProvider(final String mIdentityProvider) {
373385
return this;
374386
}
375387

388+
/**
389+
* Sets the idp identifier. This will change the hosted UI behavior to go directly to the corresponding provider
390+
* <p>
391+
* Optional. Set idp identifier for provider mapping.
392+
* </p>
393+
* @param mIdpIdentifier Required: Scopes as a {@link Set<String>}.
394+
* @return A reference to this builder.
395+
*/
396+
@SuppressWarnings("checkstyle:hiddenfield")
397+
public Builder setIdpIdentifier(final String mIdpIdentifier) {
398+
this.mIdpIdentifier = mIdpIdentifier;
399+
return this;
400+
}
401+
376402
/**
377403
* Instantiates {@link Auth} with the set options.
378404
* @return {@link Auth}.
@@ -389,7 +415,8 @@ public Auth build() {
389415
this.mScopes,
390416
this.mUserHandler,
391417
this.mAdvancedSecurityDataCollectionFlag,
392-
this.mIdentityProvider);
418+
this.mIdentityProvider,
419+
this.mIdpIdentifier);
393420
}
394421

395422

@@ -524,6 +551,13 @@ public String getIdentityProvider() {
524551
return identityProvider;
525552
}
526553

554+
/**
555+
* @return Identity Provider set for this {@link Auth} instance.
556+
*/
557+
public String getIdpIdentifier() {
558+
return idpIdentifier;
559+
}
560+
527561
/**
528562
* Use this method to get tokens for a user, the tokens are returned though the callback.
529563
* {@link AuthHandler#onSuccess(AuthUserSession)}.

aws-android-sdk-cognitoauth/src/main/java/com/amazonaws/mobileconnectors/cognitoauth/AuthClient.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,10 @@ private void launchCognitoAuth(final String redirectUri, final Set<String> token
483483
if (!TextUtils.isEmpty(pool.getIdentityProvider())) {
484484
builder.appendQueryParameter(ClientConstants.DOMAIN_QUERY_PARAM_IDENTITY_PROVIDER, pool.getIdentityProvider());
485485
}
486+
//check if idp identifier set as param.
487+
if (!TextUtils.isEmpty(pool.getIdpIdentifier())) {
488+
builder.appendQueryParameter(ClientConstants.DOMAIN_QUERY_PARAM_IDP_IDENTIFIER, pool.getIdpIdentifier());
489+
}
486490

487491
// Convert scopes into a string of comma separated values.
488492
final int noOfScopes = tokenScopes.size();

aws-android-sdk-cognitoauth/src/main/java/com/amazonaws/mobileconnectors/cognitoauth/util/ClientConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public abstract class ClientConstants {
4646
public static final String DOMAIN_QUERY_PARAM_STATE = "state";
4747
public static final String DOMAIN_QUERY_PARAM_USERCONTEXTDATA = "userContextData";
4848
public static final String DOMAIN_QUERY_PARAM_IDENTITY_PROVIDER = "identity_provider";
49+
public static final String DOMAIN_QUERY_PARAM_IDP_IDENTIFIER = "idp_identifier";
4950
public static final String DOMAIN_SCHEME = "https";
5051
public static final String SESSION_TYPE_JWT = "JWT";
5152
public static final String TOKEN_AUTH_TYPE_CODE = "code";

0 commit comments

Comments
 (0)