amplify-backend
amplify-backend copied to clipboard
native support for custom attributes on auth
Environment information
System:
OS: macOS 14.4.1
CPU: (8) arm64 Apple M1
Memory: 210.19 MB / 16.00 GB
Shell: /opt/homebrew/bin/fish
Binaries:
Node: 20.11.1 - ~/.local/share/nvm/v20.11.1/bin/node
Yarn: 1.22.19 - ~/.local/share/nvm/v20.11.1/bin/yarn
npm: 10.2.4 - ~/.local/share/nvm/v20.11.1/bin/npm
pnpm: 8.15.4 - ~/Library/pnpm/pnpm
NPM Packages:
@aws-amplify/backend: 1.0.2
@aws-amplify/backend-cli: 1.0.3
aws-amplify: 6.3.2
aws-cdk: 2.141.0
aws-cdk-lib: 2.141.0
typescript: 5.4.5
AWS environment variables:
AWS_STS_REGIONAL_ENDPOINTS = regional
AWS_NODEJS_CONNECTION_REUSE_ENABLED = 1
AWS_SDK_LOAD_CONFIG = 1
No CDK environment variables
Description
Followup on issue: https://github.com/aws-amplify/amplify-backend/issues/1511
we currently need to modify the cfnUserPool schema to add a custom property on the backend. would be great if we could add this on defineAuth directly.
marking as a feature request
we could do something like
import { defineAuth } from "@aws-amplify/backend"
export const auth = defineAuth({
loginWith: {
email: true,
},
userAttributes: {
"custom:favorite_color": {
required: true,
},
},
})
The AWS CDK Congito user pool takes separate parameters for standardAttributes and customAttributes.
I think there are a few approaches that might be easier than allowing user attribute keys prefixed with custom:
- Allow a user attributes key
customthat is an object of user attributes. This is how the AttributeMapping interface in CDK does it for identity providers
Example:
const userAttributes = {
email: {
required: true,
mutable: true,
},
custom: {
myCustomAttribute: {
required: false,
mutable: true,
},
},
}
- Create a separate, optional auth prop for
customAttributesthat then gets passed directly to the CDK prop for custom attributes
@josefaidt if you are open to either of these I can work on a PR.
Hey @ataylorme :wave: sorry I missed this message! This is now available with @aws-amplify/[email protected]
closing