@fy-stack/auth-construct 0.0.124 → 0.0.126
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
1
|
-
# auth-construct
|
|
2
1
|
|
|
3
|
-
|
|
2
|
+
# Auth Construct Documentation
|
|
4
3
|
|
|
5
|
-
##
|
|
4
|
+
## `AuthConstruct`
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
The `AuthConstruct` class is a custom AWS CDK construct that sets up authentication infrastructure using Amazon Cognito. It creates a user pool, a user pool domain, and a user pool client with configurable authentication flows and token validity. Additionally, it can create user groups within the user pool. This construct implements the `Attachable` and `Grantable` interfaces.
|
|
7
|
+
|
|
8
|
+
- **Properties**
|
|
9
|
+
- `userPool: cognito.UserPool`
|
|
10
|
+
- The Cognito user pool created by this construct.
|
|
11
|
+
- `domain: cognito.UserPoolDomain`
|
|
12
|
+
- The domain associated with the user pool.
|
|
13
|
+
- `client: cognito.UserPoolClient`
|
|
14
|
+
- The client application for the user pool.
|
|
15
|
+
|
|
16
|
+
- **Constructor**
|
|
17
|
+
- `constructor(scope: Construct, id: string, props: AuthConstructProps)`
|
|
18
|
+
- Initializes the authentication construct with a unique identifier and configuration options defined by `AuthConstructProps`.
|
|
19
|
+
- **Parameters**
|
|
20
|
+
- `scope`: The scope in which this construct is defined.
|
|
21
|
+
- `id`: The unique identifier for this construct.
|
|
22
|
+
- `props`: Properties required to set up the authentication construct.
|
|
@@ -3,15 +3,22 @@ import * as cognito from 'aws-cdk-lib/aws-cognito';
|
|
|
3
3
|
import * as iam from 'aws-cdk-lib/aws-iam';
|
|
4
4
|
import { Construct } from 'constructs';
|
|
5
5
|
import { AuthConstructProps } from './types';
|
|
6
|
+
/**
|
|
7
|
+
* AuthConstruct is a construct that sets up an authentication infrastructure
|
|
8
|
+
* using Amazon Cognito. It creates a user pool, a domain for the user pool,
|
|
9
|
+
* and a client for the user pool with configurable authentication flows and
|
|
10
|
+
* token validity. Additionally, it can create user groups within the user pool.
|
|
11
|
+
*
|
|
12
|
+
* It extends the Construct class and implements the {@link Attachable `Attachable`} and {@link Grantable `Grantable`} interfaces.
|
|
13
|
+
*/
|
|
6
14
|
export declare class AuthConstruct extends Construct implements Attachable, Grantable {
|
|
7
15
|
userPool: cognito.UserPool;
|
|
8
|
-
domain
|
|
16
|
+
domain?: cognito.UserPoolDomain;
|
|
9
17
|
client: cognito.UserPoolClient;
|
|
10
18
|
constructor(scope: Construct, id: string, props: AuthConstructProps);
|
|
11
19
|
attachable(): {
|
|
12
20
|
arn: string;
|
|
13
21
|
id: string;
|
|
14
|
-
domainName: string;
|
|
15
22
|
clientId: string;
|
|
16
23
|
clientSecret: string;
|
|
17
24
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-construct.d.ts","sourceRoot":"","sources":["../../src/lib/auth-construct.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAExD,OAAO,KAAK,OAAO,MAAM,yBAAyB,CAAC;AACnD,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE7C,qBAAa,aAAc,SAAQ,SAAU,YAAW,UAAU,EAAE,SAAS;IACpE,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC;IAC3B,MAAM,EAAE,OAAO,CAAC,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"auth-construct.d.ts","sourceRoot":"","sources":["../../src/lib/auth-construct.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAExD,OAAO,KAAK,OAAO,MAAM,yBAAyB,CAAC;AACnD,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE7C;;;;;;;GAOG;AACH,qBAAa,aAAc,SAAQ,SAAU,YAAW,UAAU,EAAE,SAAS;IACpE,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC;IAC3B,MAAM,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC;IAChC,MAAM,EAAE,OAAO,CAAC,cAAc,CAAC;gBAE1B,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,kBAAkB;IA2CnE,UAAU;;;;;;IAeV,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,UAAU;CAGhC"}
|
|
@@ -4,8 +4,15 @@ exports.AuthConstruct = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
6
6
|
const cognito = tslib_1.__importStar(require("aws-cdk-lib/aws-cognito"));
|
|
7
|
-
const iam = tslib_1.__importStar(require("aws-cdk-lib/aws-iam"));
|
|
8
7
|
const constructs_1 = require("constructs");
|
|
8
|
+
/**
|
|
9
|
+
* AuthConstruct is a construct that sets up an authentication infrastructure
|
|
10
|
+
* using Amazon Cognito. It creates a user pool, a domain for the user pool,
|
|
11
|
+
* and a client for the user pool with configurable authentication flows and
|
|
12
|
+
* token validity. Additionally, it can create user groups within the user pool.
|
|
13
|
+
*
|
|
14
|
+
* It extends the Construct class and implements the {@link Attachable `Attachable`} and {@link Grantable `Grantable`} interfaces.
|
|
15
|
+
*/
|
|
9
16
|
class AuthConstruct extends constructs_1.Construct {
|
|
10
17
|
userPool;
|
|
11
18
|
domain;
|
|
@@ -17,10 +24,12 @@ class AuthConstruct extends constructs_1.Construct {
|
|
|
17
24
|
selfSignUpEnabled: true,
|
|
18
25
|
signInCaseSensitive: false,
|
|
19
26
|
});
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
if (props.domainPrefix) {
|
|
28
|
+
this.domain = new cognito.UserPoolDomain(this, 'UserPoolDomain', {
|
|
29
|
+
userPool: this.userPool,
|
|
30
|
+
cognitoDomain: { domainPrefix: props.domainPrefix },
|
|
31
|
+
});
|
|
32
|
+
}
|
|
24
33
|
this.client = new cognito.UserPoolClient(this, 'WebClient', {
|
|
25
34
|
userPool: this.userPool,
|
|
26
35
|
authFlows: {
|
|
@@ -43,20 +52,19 @@ class AuthConstruct extends constructs_1.Construct {
|
|
|
43
52
|
}
|
|
44
53
|
}
|
|
45
54
|
attachable() {
|
|
46
|
-
|
|
55
|
+
const params = {
|
|
47
56
|
arn: this?.userPool.userPoolArn,
|
|
48
57
|
id: this?.userPool.userPoolId,
|
|
49
|
-
domainName: this.domain.domainName,
|
|
50
58
|
clientId: this?.client.userPoolClientId,
|
|
51
59
|
clientSecret: this?.client.userPoolClientSecret.unsafeUnwrap(),
|
|
52
60
|
};
|
|
61
|
+
if (this.domain) {
|
|
62
|
+
Object.assign(params, { domainName: this.domain.domainName, });
|
|
63
|
+
}
|
|
64
|
+
return params;
|
|
53
65
|
}
|
|
54
66
|
grantable(grant) {
|
|
55
|
-
|
|
56
|
-
effect: iam.Effect.ALLOW,
|
|
57
|
-
actions: ['cognito-idp:*', 'cognito-identity:*'],
|
|
58
|
-
resources: [this.userPool.userPoolArn],
|
|
59
|
-
}));
|
|
67
|
+
this.userPool.grant(grant, 'cognito-idp:*', 'cognito-identity:*');
|
|
60
68
|
}
|
|
61
69
|
}
|
|
62
70
|
exports.AuthConstruct = AuthConstruct;
|
package/dist/lib/types.d.ts
CHANGED
package/dist/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,4BAA4B;IAC5B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB;;SAEK;IACL,KAAK,CAAC,EAAE;QACN,qCAAqC;QACrC,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,sCAAsC;QACtC,oBAAoB,CAAC,EAAE,MAAM,CAAC;KAC/B,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,4BAA4B;IAC5B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB;;SAEK;IACL,KAAK,CAAC,EAAE;QACN,qCAAqC;QACrC,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,sCAAsC;QACtC,oBAAoB,CAAC,EAAE,MAAM,CAAC;KAC/B,CAAC;IACF,yBAAyB;IACzB,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fy-stack/auth-construct",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.126",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@fy-stack/types": "0.0.
|
|
5
|
+
"@fy-stack/types": "0.0.126",
|
|
6
6
|
"tslib": "^2.3.0"
|
|
7
7
|
},
|
|
8
8
|
"peerDependencies": {
|
|
9
|
-
"aws-cdk-lib": "2.
|
|
9
|
+
"aws-cdk-lib": "2.166.0",
|
|
10
10
|
"constructs": "10.4.2"
|
|
11
11
|
},
|
|
12
12
|
"main": "./dist/index.js",
|