Skip to content

add auth required attributes mapping #8263

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

Merged
merged 1 commit into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,7 @@
"frontend",
"frontends",
"fullheight",
"fullname",
"Gapi",
"ge",
"geo_point",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,103 @@ export const auth = defineAuth({

User attributes are defined as [Cognito Standard Attributes](https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-attributes.html#cognito-user-pools-standard-attributes). Attributes can be configured to be _required_ for user sign-up in addition to whether the values are _mutable_. When configuring your resource to allow your users to login with `email`, an email must be specified for user sign-up and cannot be changed later. However additional attributes can be configured to be optional, and mutable after sign-up.

```ts title="amplify/auth/resource.ts"
import { defineAuth } from "@aws-amplify/backend";

export const auth = defineAuth({
loginWith: {
email: true,
},
userAttributes: {
// Maps to Cognito standard attribute 'address'
address: {
mutable: true,
required: true,
},
// Maps to Cognito standard attribute 'birthdate'
birthdate: {
mutable: true,
required: false,
},
// Maps to Cognito standard attribute 'email'
email: {
mutable: true,
required: true,
},
// Maps to Cognito standard attribute 'family_name'
familyName: {
mutable: true,
required: false,
},
// Maps to Cognito standard attribute 'gender'
gender: {
mutable: true,
required: false,
},
// Maps to Cognito standard attribute 'given_name'
givenName: {
mutable: true,
required: false,
},
// Maps to Cognito standard attribute 'locale'
locale: {
mutable: true,
required: false,
},
// Maps to Cognito standard attribute 'middle_name'
middleName: {
mutable: true,
required: false,
},
// Maps to Cognito standard attribute 'name'
fullname: {
mutable: true,
required: false,
},
// Maps to Cognito standard attribute 'nickname'
nickname: {
mutable: true,
required: false,
},
// Maps to Cognito standard attribute 'phone_number'
phoneNumber: {
mutable: true,
required: false,
},
// Maps to Cognito standard attribute 'picture'
profilePicture: {
mutable: true,
required: false,
},
// Maps to Cognito standard attribute 'preferred_username'
preferredUsername: {
mutable: true,
required: false,
},
// Maps to Cognito standard attribute 'profile'
profilePage: {
mutable: true,
required: false,
},
// Maps to Cognito standard attribute 'zoneinfo'
timezone: {
mutable: true,
required: false,
},
// Maps to Cognito standard attribute 'updated_at'
lastUpdateTime: {
mutable: true,
required: false,
},
// Maps to Cognito standard attribute 'website'
website: {
mutable: true,
required: false,
},
},
});
```

## Custom attributes

In addition to the provided standard attributes, you can configure [Custom Attributes](https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-attributes.html#user-pool-settings-custom-attributes). These are attributes that are typically unique to your use case, such as a tenant ID or a user's display name. Custom attributes are identified by the `custom:` prefix:
Expand Down
Loading