Skip to content

Commit

Permalink
Allows developers to configure user pools for email/phone based signu…
Browse files Browse the repository at this point in the history
…p and sign-in.
  • Loading branch information
sstevenkang committed Jul 17, 2017
1 parent 8ec3dc6 commit 4865cfa
Show file tree
Hide file tree
Showing 13 changed files with 206 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,9 @@
{"shape":"TooManyRequestsException"},
{"shape":"LimitExceededException"},
{"shape":"UserNotFoundException"},
{"shape":"InvalidSmsRoleAccessPolicyException"},
{"shape":"InvalidEmailRoleAccessPolicyException"},
{"shape":"InvalidSmsRoleTrustRelationshipException"},
{"shape":"InternalErrorException"}
],
"documentation":"<p>Resets the specified user's password in a user pool as an administrator. Works on any user.</p> <p>When a developer calls this API, the current password is invalidated, so it must be changed. If a user tries to sign in after the API is called, the app will get a PasswordResetRequiredException exception back and should direct the user down the flow to reset the password, which is the same as the forgot password flow. In addition, if the user pool has phone verification selected and a verified phone number exists for the user, or if email verification is selected and a verified email exists for the user, calling this API will also result in sending a message to the end user with the code to change their password.</p> <p>Requires developer credentials.</p>"
Expand Down Expand Up @@ -1872,11 +1875,11 @@
},
"AuthFlow":{
"shape":"AuthFlowType",
"documentation":"<p>The authentication flow for this call to execute. The API action will depend on this value. For example:</p> <ul> <li> <p> <code>REFRESH_TOKEN_AUTH</code> will take in a valid refresh token and return new tokens.</p> </li> <li> <p> <code>USER_SRP_AUTH</code> will take in <code>USERNAME</code> and <code>SRPA</code> and return the SRP variables to be used for next challenge execution.</p> </li> </ul> <p>Valid values include:</p> <ul> <li> <p> <code>USER_SRP_AUTH</code>: Authentication flow for the Secure Remote Password (SRP) protocol.</p> </li> <li> <p> <code>REFRESH_TOKEN_AUTH</code>/<code>REFRESH_TOKEN</code>: Authentication flow for refreshing the access token and ID token by supplying a valid refresh token.</p> </li> <li> <p> <code>CUSTOM_AUTH</code>: Custom authentication flow.</p> </li> <li> <p> <code>ADMIN_NO_SRP_AUTH</code>: Non-SRP authentication flow; you can pass in the USERNAME and PASSWORD directly if the flow is enabled for calling the app client.</p> </li> </ul>"
"documentation":"<p>The authentication flow for this call to execute. The API action will depend on this value. For example:</p> <ul> <li> <p> <code>REFRESH_TOKEN_AUTH</code> will take in a valid refresh token and return new tokens.</p> </li> <li> <p> <code>USER_SRP_AUTH</code> will take in <code>USERNAME</code> and <code>SRP_A</code> and return the SRP variables to be used for next challenge execution.</p> </li> </ul> <p>Valid values include:</p> <ul> <li> <p> <code>USER_SRP_AUTH</code>: Authentication flow for the Secure Remote Password (SRP) protocol.</p> </li> <li> <p> <code>REFRESH_TOKEN_AUTH</code>/<code>REFRESH_TOKEN</code>: Authentication flow for refreshing the access token and ID token by supplying a valid refresh token.</p> </li> <li> <p> <code>CUSTOM_AUTH</code>: Custom authentication flow.</p> </li> <li> <p> <code>ADMIN_NO_SRP_AUTH</code>: Non-SRP authentication flow; you can pass in the USERNAME and PASSWORD directly if the flow is enabled for calling the app client.</p> </li> </ul>"
},
"AuthParameters":{
"shape":"AuthParametersType",
"documentation":"<p>The authentication parameters. These are inputs corresponding to the <code>AuthFlow</code> that you are invoking. The required values depend on the value of <code>AuthFlow</code>:</p> <ul> <li> <p>For <code>USER_SRP_AUTH</code>: <code>USERNAME</code> (required), <code>SRPA</code> (required), <code>SECRET_HASH</code> (required if the app client is configured with a client secret), <code>DEVICE_KEY</code> </p> </li> <li> <p>For <code>REFRESH_TOKEN_AUTH/REFRESH_TOKEN</code>: <code>USERNAME</code> (required), <code>SECRET_HASH</code> (required if the app client is configured with a client secret), <code>REFRESH_TOKEN</code> (required), <code>DEVICE_KEY</code> </p> </li> <li> <p>For <code>ADMIN_NO_SRP_AUTH</code>: <code>USERNAME</code> (required), <code>SECRET_HASH</code> (if app client is configured with client secret), <code>PASSWORD</code> (required), <code>DEVICE_KEY</code> </p> </li> <li> <p>For <code>CUSTOM_AUTH</code>: <code>USERNAME</code> (required), <code>SECRET_HASH</code> (if app client is configured with client secret), <code>DEVICE_KEY</code> </p> </li> </ul>"
"documentation":"<p>The authentication parameters. These are inputs corresponding to the <code>AuthFlow</code> that you are invoking. The required values depend on the value of <code>AuthFlow</code>:</p> <ul> <li> <p>For <code>USER_SRP_AUTH</code>: <code>USERNAME</code> (required), <code>SRP_A</code> (required), <code>SECRET_HASH</code> (required if the app client is configured with a client secret), <code>DEVICE_KEY</code> </p> </li> <li> <p>For <code>REFRESH_TOKEN_AUTH/REFRESH_TOKEN</code>: <code>USERNAME</code> (required), <code>SECRET_HASH</code> (required if the app client is configured with a client secret), <code>REFRESH_TOKEN</code> (required), <code>DEVICE_KEY</code> </p> </li> <li> <p>For <code>ADMIN_NO_SRP_AUTH</code>: <code>USERNAME</code> (required), <code>SECRET_HASH</code> (if app client is configured with client secret), <code>PASSWORD</code> (required), <code>DEVICE_KEY</code> </p> </li> <li> <p>For <code>CUSTOM_AUTH</code>: <code>USERNAME</code> (required), <code>SECRET_HASH</code> (if app client is configured with client secret), <code>DEVICE_KEY</code> </p> </li> </ul>"
},
"ClientMetadata":{
"shape":"ClientMetadataType",
Expand Down Expand Up @@ -2829,6 +2832,10 @@
"shape":"AliasAttributesListType",
"documentation":"<p>Attributes supported as an alias for this user pool. Possible values: <b>phone_number</b>, <b>email</b>, or <b>preferred_username</b>.</p>"
},
"UsernameAttributes":{
"shape":"UsernameAttributesListType",
"documentation":"<p>Specifies whether email addresses or phone numbers can be specified as usernames when a user signs up.</p>"
},
"SmsVerificationMessage":{
"shape":"SmsVerificationMessageType",
"documentation":"<p>A string representing the SMS verification message.</p>"
Expand Down Expand Up @@ -3692,11 +3699,11 @@
"members":{
"AuthFlow":{
"shape":"AuthFlowType",
"documentation":"<p>The authentication flow for this call to execute. The API action will depend on this value. For example: </p> <ul> <li> <p> <code>REFRESH_TOKEN_AUTH</code> will take in a valid refresh token and return new tokens.</p> </li> <li> <p> <code>USER_SRP_AUTH</code> will take in USERNAME and SRPA and return the SRP variables to be used for next challenge execution.</p> </li> </ul> <p>Valid values include:</p> <ul> <li> <p> <code>USER_SRP_AUTH</code>: Authentication flow for the Secure Remote Password (SRP) protocol.</p> </li> <li> <p> <code>REFRESH_TOKEN_AUTH</code>/<code>REFRESH_TOKEN</code>: Authentication flow for refreshing the access token and ID token by supplying a valid refresh token.</p> </li> <li> <p> <code>CUSTOM_AUTH</code>: Custom authentication flow.</p> </li> </ul> <p> <code>ADMIN_NO_SRP_AUTH</code> is not a valid value.</p>"
"documentation":"<p>The authentication flow for this call to execute. The API action will depend on this value. For example: </p> <ul> <li> <p> <code>REFRESH_TOKEN_AUTH</code> will take in a valid refresh token and return new tokens.</p> </li> <li> <p> <code>USER_SRP_AUTH</code> will take in <code>USERNAME</code> and <code>SRP_A</code> and return the SRP variables to be used for next challenge execution.</p> </li> </ul> <p>Valid values include:</p> <ul> <li> <p> <code>USER_SRP_AUTH</code>: Authentication flow for the Secure Remote Password (SRP) protocol.</p> </li> <li> <p> <code>REFRESH_TOKEN_AUTH</code>/<code>REFRESH_TOKEN</code>: Authentication flow for refreshing the access token and ID token by supplying a valid refresh token.</p> </li> <li> <p> <code>CUSTOM_AUTH</code>: Custom authentication flow.</p> </li> </ul> <p> <code>ADMIN_NO_SRP_AUTH</code> is not a valid value.</p>"
},
"AuthParameters":{
"shape":"AuthParametersType",
"documentation":"<p>The authentication parameters. These are inputs corresponding to the <code>AuthFlow</code> that you are invoking. The required values depend on the value of <code>AuthFlow</code>:</p> <ul> <li> <p>For <code>USER_SRP_AUTH</code>: <code>USERNAME</code> (required), <code>SRPA</code> (required), <code>SECRET_HASH</code> (required if the app client is configured with a client secret), <code>DEVICE_KEY</code> </p> </li> <li> <p>For <code>REFRESH_TOKEN_AUTH/REFRESH_TOKEN</code>: <code>USERNAME</code> (required), <code>SECRET_HASH</code> (required if the app client is configured with a client secret), <code>REFRESH_TOKEN</code> (required), <code>DEVICE_KEY</code> </p> </li> <li> <p>For <code>CUSTOM_AUTH</code>: <code>USERNAME</code> (required), <code>SECRET_HASH</code> (if app client is configured with client secret), <code>DEVICE_KEY</code> </p> </li> </ul>"
"documentation":"<p>The authentication parameters. These are inputs corresponding to the <code>AuthFlow</code> that you are invoking. The required values depend on the value of <code>AuthFlow</code>:</p> <ul> <li> <p>For <code>USER_SRP_AUTH</code>: <code>USERNAME</code> (required), <code>SRP_A</code> (required), <code>SECRET_HASH</code> (required if the app client is configured with a client secret), <code>DEVICE_KEY</code> </p> </li> <li> <p>For <code>REFRESH_TOKEN_AUTH/REFRESH_TOKEN</code>: <code>USERNAME</code> (required), <code>SECRET_HASH</code> (required if the app client is configured with a client secret), <code>REFRESH_TOKEN</code> (required), <code>DEVICE_KEY</code> </p> </li> <li> <p>For <code>CUSTOM_AUTH</code>: <code>USERNAME</code> (required), <code>SECRET_HASH</code> (if app client is configured with client secret), <code>DEVICE_KEY</code> </p> </li> </ul>"
},
"ClientMetadata":{
"shape":"ClientMetadataType",
Expand Down Expand Up @@ -5471,6 +5478,10 @@
"shape":"AliasAttributesListType",
"documentation":"<p>Specifies the attributes that are aliased in a user pool.</p>"
},
"UsernameAttributes":{
"shape":"UsernameAttributesListType",
"documentation":"<p>Specifies whether email addresses or phone numbers can be specified as usernames when a user signs up.</p>"
},
"SmsVerificationMessage":{
"shape":"SmsVerificationMessageType",
"documentation":"<p>The contents of the SMS verification message.</p>"
Expand Down Expand Up @@ -5572,6 +5583,17 @@
},
"documentation":"<p>The user type.</p>"
},
"UsernameAttributeType":{
"type":"string",
"enum":[
"phone_number",
"email"
]
},
"UsernameAttributesListType":{
"type":"list",
"member":{"shape":"UsernameAttributeType"}
},
"UsernameExistsException":{
"type":"structure",
"members":{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public partial class AdminInitiateAuthRequest : AmazonCognitoIdentityProviderReq
/// </para>
/// </li> <li>
/// <para>
/// <code>USER_SRP_AUTH</code> will take in <code>USERNAME</code> and <code>SRPA</code>
/// <code>USER_SRP_AUTH</code> will take in <code>USERNAME</code> and <code>SRP_A</code>
/// and return the SRP variables to be used for next challenge execution.
/// </para>
/// </li> </ul>
Expand Down Expand Up @@ -105,7 +105,7 @@ internal bool IsSetAuthFlow()
/// </para>
/// <ul> <li>
/// <para>
/// For <code>USER_SRP_AUTH</code>: <code>USERNAME</code> (required), <code>SRPA</code>
/// For <code>USER_SRP_AUTH</code>: <code>USERNAME</code> (required), <code>SRP_A</code>
/// (required), <code>SECRET_HASH</code> (required if the app client is configured with
/// a client secret), <code>DEVICE_KEY</code>
/// </para>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public partial class CreateUserPoolRequest : AmazonCognitoIdentityProviderReques
private string _smsAuthenticationMessage;
private SmsConfigurationType _smsConfiguration;
private string _smsVerificationMessage;
private List<string> _usernameAttributes = new List<string>();
private Dictionary<string, string> _userPoolTags = new Dictionary<string, string>();

/// <summary>
Expand Down Expand Up @@ -322,6 +323,25 @@ internal bool IsSetSmsVerificationMessage()
return this._smsVerificationMessage != null;
}

/// <summary>
/// Gets and sets the property UsernameAttributes.
/// <para>
/// Specifies whether email addresses or phone numbers can be specified as usernames when
/// a user signs up.
/// </para>
/// </summary>
public List<string> UsernameAttributes
{
get { return this._usernameAttributes; }
set { this._usernameAttributes = value; }
}

// Check to see if UsernameAttributes property is set
internal bool IsSetUsernameAttributes()
{
return this._usernameAttributes != null && this._usernameAttributes.Count > 0;
}

/// <summary>
/// Gets and sets the property UserPoolTags.
/// <para>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public partial class InitiateAuthRequest : AmazonCognitoIdentityProviderRequest
/// </para>
/// </li> <li>
/// <para>
/// <code>USER_SRP_AUTH</code> will take in USERNAME and SRPA and return the SRP variables
/// to be used for next challenge execution.
/// <code>USER_SRP_AUTH</code> will take in <code>USERNAME</code> and <code>SRP_A</code>
/// and return the SRP variables to be used for next challenge execution.
/// </para>
/// </li> </ul>
/// <para>
Expand Down Expand Up @@ -97,7 +97,7 @@ internal bool IsSetAuthFlow()
/// </para>
/// <ul> <li>
/// <para>
/// For <code>USER_SRP_AUTH</code>: <code>USERNAME</code> (required), <code>SRPA</code>
/// For <code>USER_SRP_AUTH</code>: <code>USERNAME</code> (required), <code>SRP_A</code>
/// (required), <code>SECRET_HASH</code> (required if the app client is configured with
/// a client secret), <code>DEVICE_KEY</code>
/// </para>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ public override AmazonServiceException UnmarshallException(JsonUnmarshallerConte
{
return new InternalErrorException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
}
if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidEmailRoleAccessPolicyException"))
{
return new InvalidEmailRoleAccessPolicyException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
}
if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidLambdaResponseException"))
{
return new InvalidLambdaResponseException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
Expand All @@ -73,6 +77,14 @@ public override AmazonServiceException UnmarshallException(JsonUnmarshallerConte
{
return new InvalidParameterException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
}
if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidSmsRoleAccessPolicyException"))
{
return new InvalidSmsRoleAccessPolicyException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
}
if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidSmsRoleTrustRelationshipException"))
{
return new InvalidSmsRoleTrustRelationshipException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
}
if (errorResponse.Code != null && errorResponse.Code.Equals("LimitExceededException"))
{
return new LimitExceededException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,17 @@ public IRequest Marshall(CreateUserPoolRequest publicRequest)
context.Writer.Write(publicRequest.SmsVerificationMessage);
}

if(publicRequest.IsSetUsernameAttributes())
{
context.Writer.WritePropertyName("UsernameAttributes");
context.Writer.WriteArrayStart();
foreach(var publicRequestUsernameAttributesListValue in publicRequest.UsernameAttributes)
{
context.Writer.Write(publicRequestUsernameAttributesListValue);
}
context.Writer.WriteArrayEnd();
}

if(publicRequest.IsSetUserPoolTags())
{
context.Writer.WritePropertyName("UserPoolTags");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,12 @@ public UserPoolType Unmarshall(JsonUnmarshallerContext context)
unmarshalledObject.Status = unmarshaller.Unmarshall(context);
continue;
}
if (context.TestExpression("UsernameAttributes", targetDepth))
{
var unmarshaller = new ListUnmarshaller<string, StringUnmarshaller>(StringUnmarshaller.Instance);
unmarshalledObject.UsernameAttributes = unmarshaller.Unmarshall(context);
continue;
}
if (context.TestExpression("UserPoolTags", targetDepth))
{
var unmarshaller = new DictionaryUnmarshaller<string, string, StringUnmarshaller, StringUnmarshaller>(StringUnmarshaller.Instance, StringUnmarshaller.Instance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public partial class UserPoolType
private string _smsConfigurationFailure;
private string _smsVerificationMessage;
private StatusType _status;
private List<string> _usernameAttributes = new List<string>();
private Dictionary<string, string> _userPoolTags = new Dictionary<string, string>();

/// <summary>
Expand Down Expand Up @@ -467,6 +468,25 @@ internal bool IsSetStatus()
return this._status != null;
}

/// <summary>
/// Gets and sets the property UsernameAttributes.
/// <para>
/// Specifies whether email addresses or phone numbers can be specified as usernames when
/// a user signs up.
/// </para>
/// </summary>
public List<string> UsernameAttributes
{
get { return this._usernameAttributes; }
set { this._usernameAttributes = value; }
}

// Check to see if UsernameAttributes property is set
internal bool IsSetUsernameAttributes()
{
return this._usernameAttributes != null && this._usernameAttributes.Count > 0;
}

/// <summary>
/// Gets and sets the property UserPoolTags.
/// <para>
Expand Down
Loading

0 comments on commit 4865cfa

Please sign in to comment.