-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Allow mutable requiredAttributes in Cognito User Pools #7752
Comments
Copied from #7754 (review) Is this a feature that Cognito supports? I couldn't find any documentation that states that standard attributes can be marked mutable or immutable and Cognito on the AWS console doesn't show these options either. |
Hi @nija-at , Well I'm not sure about the docs for the Cognito. But the UserPool Cloudformation resource treats the user schema as generic Attributes, AFAIK the CDK and cfn resource are just treating the attributes as generic attributes, whereas the console actually makes a difference between the standard attributes and the custom attributes. The cfn resource of the UserPool "shortly" explains the schema as all attributes can be set as mutable or not. I discover this while working in a web app. Since the user count would be low we went for using Cognito and Amplify's Auth library (only that lib the rest is CDK) to handle the communication with the Cognito. The flow was:
The error I get:
I know is long way to test it out but for me to help in the process I created a quick vue-client using CDK to set up a Congito pool and client using the amplify lib to handle the login and set password. feel free to test it out with that code :) Usage of the client: |
I've taken the liberty to implement a preview, refer to #7752 Any feedback is welcome! BREAKING CHANGE: `requiredAttributes` on `UserPool` construct is now replaced with `standardAttributes` with a slightly modified signature. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Merged - 1fabd98 |
At the moment the L2 Construct for Cognito's User pools allow specifying required and custom attributes.
For simple use cases, the required attributes offer the complete information about a user.
The difference now is that the requiredAttributes are configured at the moment only with a boolean flag, and therefore they default to
false
, as it has to be explicitly specified that an attribute is mutable in order for the field to be modified.https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cognito-userpool-schemaattribute.html
Use Case
For fields like full name, address, gender, TZ, etc... this are the essential attributes of a user and can be changed over time.
Supporting mutable attributes even for the requiredAttributes will allow this to happen.
And also a WIP PR for adding support for AppClients to read and write attributes is in the way.
Related issues:
Proposed Solution
At the moment Cognito User pools offer mutable customAttributes.
Sadly there's only a way to be backwards compatible is by allowing
boolean
or theStandardAttribute
then rendering the RequiredAttributes accordingly, if boolean then as it is today else use the configured props.Else introducing a breaking change by removing the
boolean
type.Ofc, the requiredAttributes, if specified, they'll always be set as
required === true
.And maybe the rename of the
ICustomAttribute
toIAttribute
would fit now more?An alternative would be to change the UserPool props to have only one set of "attributes" and within there we can mix required and custom attributes, after all they're all attributes.
Then only for the required attributes we add the
require
propertyThis is a 🚀 Feature Request
The text was updated successfully, but these errors were encountered: