forked from aws-samples/bedrock-claude-chat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
auth.ts
45 lines (39 loc) · 1.2 KB
/
auth.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { CfnOutput, Duration } from "aws-cdk-lib";
import { UserPool, UserPoolClient, CfnUserPoolGroup } from "aws-cdk-lib/aws-cognito";
import { Construct } from "constructs";
export interface AuthProps {}
export class Auth extends Construct {
readonly userPool: UserPool;
readonly client: UserPoolClient;
constructor(scope: Construct, id: string, props?: AuthProps) {
super(scope, id);
const userPool = new UserPool(this, "UserPool", {
passwordPolicy: {
requireUppercase: true,
requireSymbols: true,
requireDigits: true,
minLength: 8,
},
selfSignUpEnabled: true,
signInAliases: {
username: false,
email: true,
},
});
const client = userPool.addClient(`Client`, {
idTokenValidity: Duration.days(1),
authFlows: {
userPassword: true,
userSrp: true,
},
});
this.client = client;
this.userPool = userPool;
new CfnOutput(this, "UserPoolId", { value: userPool.userPoolId });
new CfnOutput(this, "UserPoolClientId", { value: client.userPoolClientId });
new CfnUserPoolGroup(this, "AdminGroup", {
groupName: "admin",
userPoolId: userPool.userPoolId,
});
}
}