Gathering detailed insights and metrics for @aws-amplify/auth-construct-alpha
Gathering detailed insights and metrics for @aws-amplify/auth-construct-alpha
Gathering detailed insights and metrics for @aws-amplify/auth-construct-alpha
Gathering detailed insights and metrics for @aws-amplify/auth-construct-alpha
npm install @aws-amplify/auth-construct-alpha
Typescript
Module System
Node Version
NPM Version
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
This package vends an L3 CDK Construct that enables faster, easier and secure app authentication and authorization powered by Amazon Cognito. Amplify Auth lets you quickly set up secure authentication flows with a fully-managed user directory. Control what users have access to in your mobile and web apps with Amplify Auth's built-in authorization capabilities.
The primary way to use this construct is to invoke it with a configuration object. You can declare the individual settings for your authentication by passing them as properties to the AmplifyAuth construct.
Note: only a single instance of the AmplifyAuth
construct can be invoked within a CDK synthesis at this point in time.
In this example, you will create a simple stack with email login enabled (by default). Deploying this will create a UserPool, UserPoolClient, IdentityPool, and Authenticated/Unauthenticated IAM Roles.
1import { App, Stack } from 'aws-cdk-lib'; 2import { AmplifyAuth } from '@aws-amplify/auth-construct-alpha'; 3 4const app = new App(); 5const stack = new Stack(app, 'AuthStack'); 6 7new AmplifyAuth(stack, 'Auth');
In this example, you will create a simple stack with email login enabled and with customized multi factor authentication (MFA) settings.
1import { App, Stack } from 'aws-cdk-lib'; 2import { AmplifyAuth } from '@aws-amplify/auth-construct-alpha'; 3 4const app = new App(); 5const stack = new Stack(app, 'AuthStack'); 6 7new AmplifyAuth(stack, 'Auth', { 8 loginWith: { 9 email: true, 10 }, 11 multifactor: { 12 mode: 'OPTIONAL', 13 sms: { 14 smsMessage: (code: string) => `Your verification code is ${code}`, 15 }, 16 totp: false, 17 }, 18});
In this example, you will create a stack with email, phone, and external login providers. Additionally, you can customize the email and phone verification messages.
1import { App, Stack, SecretValue } from 'aws-cdk-lib'; 2import { AmplifyAuth } from '@aws-amplify/auth-construct-alpha'; 3 4const app = new App(); 5const stack = new Stack(app, 'AuthStack'); 6 7new AmplifyAuth(stack, 'Auth', { 8 loginWith: { 9 email: { 10 verificationEmailStyle: 'CODE', 11 verificationEmailBody: (code: string) => 12 `Your verification code is ${code}.`, 13 verificationEmailSubject: 'My custom email subject', 14 }, 15 phone: { 16 verificationMessage: (code: string) => 17 `Your verification code is ${code}.`, 18 }, 19 externalProviders: { 20 google: { 21 clientId: 'googleClientId', 22 // see https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.SecretValue.html 23 clientSecret: SecretValue.unsafePlainText('googleClientSecret'), 24 }, 25 facebook: { 26 clientId: 'facebookClientId', 27 clientSecret: 'facebookClientSecret', 28 }, 29 signInWithApple: { 30 clientId: 'appleClientId', 31 keyId: 'appleKeyId', 32 privateKey: 'applePrivateKey', 33 teamId: 'appleTeamId', 34 }, 35 loginWithAmazon: { 36 clientId: 'amazonClientId', 37 clientSecret: 'amazonClientSecret', 38 }, 39 oidc: { 40 clientId: 'oidcClientId', 41 clientSecret: 'oidcClientSecret', 42 issuerUrl: 'oidcIssuerUrl', 43 name: 'oidcProviderName', 44 }, 45 saml: { 46 name: 'samlProviderName', 47 metadata: { 48 metadataContent: 'samlMetadataContent', 49 metadataType: 'FILE', 50 }, 51 }, 52 }, 53 }, 54});
In this example, you will customize the set of attributes that are required for every user in the UserPool.
1import { App, Stack } from 'aws-cdk-lib';
2import { AmplifyAuth } from '@aws-amplify/auth-construct-alpha';
3
4const app = new App();
5const stack = new Stack(app, 'AuthStack');
6
7new AmplifyAuth(stack, 'Auth', {
8 loginWith: { email: true },
9 userAttributes: {
10 address: {
11 mutable: false,
12 },
13 familyName: {
14 required: true,
15 },
16 },
17});
No vulnerabilities found.
No security vulnerabilities found.