31 |
32 |
33 |
41 |
42 |
43 |
59 |
--------------------------------------------------------------------------------
/samples/react/auth/authenticator/src/logo.svg:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/samples/react/geo/display-map/amplify/backend/geo/map66858145/map66858145-cloudformation-template.json:
--------------------------------------------------------------------------------
1 | {
2 | "Parameters": {
3 | "authRoleName": {
4 | "Type": "String"
5 | },
6 | "unauthRoleName": {
7 | "Type": "String"
8 | },
9 | "mapName": {
10 | "Type": "String"
11 | },
12 | "mapStyle": {
13 | "Type": "String"
14 | },
15 | "pricingPlan": {
16 | "Type": "String"
17 | },
18 | "env": {
19 | "Type": "String"
20 | },
21 | "isDefault": {
22 | "Type": "String"
23 | }
24 | },
25 | "Resources": {
26 | "Map": {
27 | "Type": "AWS::Location::Map",
28 | "Properties": {
29 | "Configuration": {
30 | "Style": {
31 | "Ref": "mapStyle"
32 | }
33 | },
34 | "MapName": {
35 | "Fn::Join": [
36 | "-",
37 | [
38 | {
39 | "Ref": "mapName"
40 | },
41 | {
42 | "Ref": "env"
43 | }
44 | ]
45 | ]
46 | },
47 | "PricingPlan": {
48 | "Ref": "pricingPlan"
49 | }
50 | }
51 | },
52 | "MapPolicy": {
53 | "Type": "AWS::IAM::Policy",
54 | "Properties": {
55 | "PolicyDocument": {
56 | "Statement": [
57 | {
58 | "Action": [
59 | "geo:GetMapStyleDescriptor",
60 | "geo:GetMapGlyphs",
61 | "geo:GetMapSprites",
62 | "geo:GetMapTile"
63 | ],
64 | "Effect": "Allow",
65 | "Resource": {
66 | "Fn::GetAtt": [
67 | "Map",
68 | "MapArn"
69 | ]
70 | }
71 | }
72 | ],
73 | "Version": "2012-10-17"
74 | },
75 | "PolicyName": {
76 | "Fn::Join": [
77 | "-",
78 | [
79 | {
80 | "Ref": "mapName"
81 | },
82 | {
83 | "Ref": "env"
84 | },
85 | "Policy"
86 | ]
87 | ]
88 | },
89 | "Roles": [
90 | {
91 | "Ref": "authRoleName"
92 | },
93 | {
94 | "Ref": "unauthRoleName"
95 | }
96 | ]
97 | }
98 | }
99 | },
100 | "Outputs": {
101 | "Name": {
102 | "Value": {
103 | "Ref": "Map"
104 | }
105 | },
106 | "Style": {
107 | "Value": {
108 | "Ref": "mapStyle"
109 | }
110 | }
111 | }
112 | }
--------------------------------------------------------------------------------
/samples/angular/auth/authenticator/src/polyfills.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This file includes polyfills needed by Angular and is loaded before the app.
3 | * You can add your own extra polyfills to this file.
4 | *
5 | * This file is divided into 2 sections:
6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main
8 | * file.
9 | *
10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
13 | *
14 | * Learn more in https://angular.io/guide/browser-support
15 | */
16 |
17 | /***************************************************************************************************
18 | * BROWSER POLYFILLS
19 | */
20 |
21 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */
22 | // import 'classlist.js'; // Run `npm install --save classlist.js`.
23 |
24 | /**
25 | * Web Animations `@angular/platform-browser/animations`
26 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
27 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
28 | */
29 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`.
30 |
31 | /**
32 | * By default, zone.js will patch all possible macroTask and DomEvents
33 | * user can disable parts of macroTask/DomEvents patch by setting following flags
34 | * because those flags need to be set before `zone.js` being loaded, and webpack
35 | * will put import in the top of bundle, so user need to create a separate file
36 | * in this directory (for example: zone-flags.ts), and put the following flags
37 | * into that file, and then add the following code before importing zone.js.
38 | * import './zone-flags';
39 | *
40 | * The flags allowed in zone-flags.ts are listed here.
41 | *
42 | * The following flags will work for all browsers.
43 | *
44 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
45 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
46 | * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
47 | *
48 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
49 | * with the following flag, it will bypass `zone.js` patch for IE/Edge
50 | *
51 | * (window as any).__Zone_enable_cross_context_check = true;
52 | *
53 | */
54 |
55 | /***************************************************************************************************
56 | * Zone JS is required by default for Angular itself.
57 | */
58 | import 'zone.js/dist/zone'; // Included with Angular CLI.
59 |
60 | (window as any).global = window;
61 |
62 | (window as any).process = {
63 | env: { DEBUG: undefined },
64 | }
65 | /***************************************************************************************************
66 | * APPLICATION IMPORTS
67 | */
68 |
--------------------------------------------------------------------------------
/samples/angular/auth/authenticator/angular.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3 | "version": 1,
4 | "newProjectRoot": "projects",
5 | "projects": {
6 | "authenticator": {
7 | "projectType": "application",
8 | "schematics": {},
9 | "root": "",
10 | "sourceRoot": "src",
11 | "prefix": "app",
12 | "architect": {
13 | "build": {
14 | "builder": "@angular-devkit/build-angular:browser",
15 | "options": {
16 | "outputPath": "dist/authenticator",
17 | "index": "src/index.html",
18 | "main": "src/main.ts",
19 | "polyfills": "src/polyfills.ts",
20 | "tsConfig": "tsconfig.app.json",
21 | "aot": true,
22 | "assets": ["src/favicon.ico", "src/assets"],
23 | "styles": ["src/styles.css"],
24 | "scripts": []
25 | },
26 | "configurations": {
27 | "production": {
28 | "fileReplacements": [
29 | {
30 | "replace": "src/environments/environment.ts",
31 | "with": "src/environments/environment.prod.ts"
32 | }
33 | ],
34 | "optimization": true,
35 | "outputHashing": "all",
36 | "sourceMap": false,
37 | "extractCss": true,
38 | "namedChunks": false,
39 | "extractLicenses": true,
40 | "vendorChunk": false,
41 | "buildOptimizer": true,
42 | "budgets": [
43 | {
44 | "type": "initial",
45 | "maximumWarning": "2mb",
46 | "maximumError": "5mb"
47 | },
48 | {
49 | "type": "anyComponentStyle",
50 | "maximumWarning": "6kb",
51 | "maximumError": "10kb"
52 | }
53 | ]
54 | }
55 | }
56 | },
57 | "serve": {
58 | "builder": "@angular-devkit/build-angular:dev-server",
59 | "options": {
60 | "browserTarget": "authenticator:build"
61 | },
62 | "configurations": {
63 | "production": {
64 | "browserTarget": "authenticator:build:production"
65 | }
66 | }
67 | },
68 | "extract-i18n": {
69 | "builder": "@angular-devkit/build-angular:extract-i18n",
70 | "options": {
71 | "browserTarget": "authenticator:build"
72 | }
73 | },
74 | "test": {
75 | "builder": "@angular-devkit/build-angular:karma",
76 | "options": {
77 | "main": "src/test.ts",
78 | "polyfills": "src/polyfills.ts",
79 | "tsConfig": "tsconfig.spec.json",
80 | "karmaConfig": "karma.conf.js",
81 | "assets": ["src/favicon.ico", "src/assets"],
82 | "styles": ["src/styles.css"],
83 | "scripts": []
84 | }
85 | },
86 | "lint": {
87 | "builder": "@angular-devkit/build-angular:tslint",
88 | "options": {
89 | "tsConfig": [
90 | "tsconfig.app.json",
91 | "tsconfig.spec.json",
92 | "e2e/tsconfig.json"
93 | ],
94 | "exclude": ["**/node_modules/**"]
95 | }
96 | },
97 | "e2e": {
98 | "builder": "@angular-devkit/build-angular:protractor",
99 | "options": {
100 | "protractorConfig": "e2e/protractor.conf.js",
101 | "devServerTarget": "authenticator:serve"
102 | },
103 | "configurations": {
104 | "production": {
105 | "devServerTarget": "authenticator:serve:production"
106 | }
107 | }
108 | }
109 | }
110 | }
111 | },
112 | "defaultProject": "authenticator"
113 | }
114 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing Guidelines
2 |
3 | Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional
4 | documentation, we greatly value feedback and contributions from our community.
5 |
6 | Please read through this document before submitting any issues or pull requests to ensure we have all the necessary
7 | information to effectively respond to your bug report or contribution.
8 |
9 |
10 | ## Reporting Bugs/Feature Requests
11 |
12 | We welcome you to use the GitHub issue tracker to report bugs or suggest features.
13 |
14 | When filing an issue, please check [existing open](https://github.com/aws-amplify/amplify-js-samples/issues), or [recently closed](https://github.com/aws-amplify/amplify-js-samples/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), issues to make sure somebody else hasn't already
15 | reported the issue. Please try to include as much information as you can. Details like these are incredibly useful:
16 |
17 | * A reproducible test case or series of steps
18 | * The version of our code being used
19 | * Any modifications you've made relevant to the bug
20 | * Anything unusual about your environment or deployment
21 |
22 |
23 | ## Contributing via Pull Requests
24 | Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that:
25 |
26 | 1. You are working against the latest source on the *master* branch.
27 | 2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already.
28 | 3. You open an issue to discuss any significant work - we would hate for your time to be wasted.
29 |
30 | To send us a pull request, please:
31 |
32 | 1. Fork the repository.
33 | 2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change.
34 | 3. Ensure local tests pass.
35 | 4. Commit to your fork using clear commit messages.
36 | 5. Send us a pull request, answering any default questions in the pull request interface.
37 | 6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.
38 |
39 | GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and
40 | [creating a pull request](https://help.github.com/articles/creating-a-pull-request/).
41 |
42 |
43 | ## Finding contributions to work on
44 | Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any ['help wanted'](https://github.com/aws-amplify/amplify-js-samples/labels/help%20wanted) issues is a great place to start.
45 |
46 |
47 | ## Code of Conduct
48 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
49 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
50 | opensource-codeofconduct@amazon.com with any additional questions or comments.
51 |
52 |
53 | ## Security issue notifications
54 | If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue.
55 |
56 |
57 | ## Licensing
58 |
59 | See the [LICENSE](https://github.com/aws-amplify/amplify-js-samples/blob/master/LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution.
60 |
61 | We may ask you to sign a [Contributor License Agreement (CLA)](http://en.wikipedia.org/wiki/Contributor_License_Agreement) for larger changes.
62 |
--------------------------------------------------------------------------------
/samples/angular/auth/authenticator/README.md:
--------------------------------------------------------------------------------
1 | # Authentication using the Amplify Angular Authenticator Component
2 |
3 | [Amplify UI Components](https://docs.amplify.aws/ui/q/framework/angular) is an open-source toolkit that makes it easier for developers to add common use cases to their applications. The toolkit comes out of the box with a UI interface that is connected to Amplify’s backend services.
4 |
5 | ## What Are We Building?
6 |
7 | In this example, we will use the [Authenticator UI Component](https://docs.amplify.aws/ui/auth/authenticator/q/framework/angular) to allow users to signup and signin.
8 |
9 | We have bootstrapped this application using the [Angular CLI](https://cli.angular.io/).
10 |
11 |
12 |
13 | ## Let's Get Started!
14 |
15 | ## Setup
16 |
17 | 1. Login or [Create](https://portal.aws.amazon.com/billing/signup?type=enterprise#/start) an AWS Account.
18 | 2. In a terminal, clone this repo.
19 | 3. Install the [Amplify CLI](https://github.com/aws-amplify/amplify-cli) `npm install -g @aws-amplify/cli`. Ensure you are in the directory you just cloned.
20 | 4. If it’s your first time using the CLI, you will need to configure it by running `amplify configure`. Follow the instructions to create an IAM profile locally.
21 | 5. Now let’s initialize an Amplify project in this directory. `amplify init`
22 |
23 | ```
24 | $ amplify init
25 | ? Enter a name for the environment dev
26 | ? Choose your default editor: (pick an editor)
27 | ? Do you want to use an AWS profile? Y (this should be the profile you created in step #4)
28 | ```
29 |
30 | 6. Lastly, the CLI will provision our backend resources using the config files in the `amplify` directory. To provision these resources in the cloud, run `amplify push`. Confirm you want to use the Auth category.
31 |
32 | ## Running the App
33 |
34 | 1. `npm install`
35 | 2. `npm run start`
36 | 3. The app should run on http://localhost:4200/. Try creating an account and signing in.
37 |
38 | ## A Closer Look
39 |
40 | Now that you've built the app, let's take a look under the hood and explore how it works.
41 |
42 | ### Frontend
43 |
44 | Let's dive into the frontend components. In this app, the important logic is in `app.component.ts`.
45 |
46 | Using the \*ngIf directive we can conditionally render the application based on whether a user is authenticated and signed in. If a user isn’t signed in, let’s display the `AmplifyAuthenticator`:
47 |
48 | ```
49 |
50 |
51 |
52 | ```
53 |
54 | If this is signed in, we can route to a user dashboard component or simply display their username.
55 |
56 | ```
57 |
61 | ```
62 |
63 | This works out of the box and displays a standard SignIn/SignOut interface for users.
64 |
65 | ### Backend
66 |
67 | The Amplify CLI is responsible for building the necessary modules in the backend to support user authentication, which in this case lives in the AWS cloud. To be more specific, we will use Amazon Cognito, so there is no need to build your own backend.
68 |
69 | The config files in the `amplify` folder contain these instructions. If you start from scratch, run `amplify add auth` to build these files. Then run, `amplify push` to deploy them on AWS.
70 |
71 | ## Next Steps
72 |
73 | - Read our [Authentication documentation](https://docs.amplify.aws/ui/auth/authenticator/q/framework/angular) to further customize your app. There are many advanced use cases to build upon.
74 | - Join our communities on [Twitter](https://twitter.com/awsamplify) and [Discord](https://discord.gg/amplify)
75 |
--------------------------------------------------------------------------------
/samples/vue/auth/authenticator/README.md:
--------------------------------------------------------------------------------
1 | # Authentication using the Amplify Vue Authenticator Component
2 |
3 | [Amplify UI Components](https://docs.amplify.aws/ui/q/framework/vue) is an open-source toolkit that makes it easier for developers to add common use cases to their applications. The toolkit comes out of the box with a UI interface that is connected to Amplify’s backend services.
4 |
5 | ## What Are We Building?
6 |
7 | In this example, we will use the [Authenticator UI Component](https://docs.amplify.aws/ui/auth/authenticator/q/framework/vue) to allow users to signup and signin.
8 |
9 | We have bootstrapped this application using the [Vue CLI](https://cli.vuejs.org/).
10 |
11 |
12 |
13 | ## Let's Get Started!
14 |
15 | ## Setup
16 |
17 | 1. Login or [Create](https://portal.aws.amazon.com/billing/signup?type=enterprise#/start) an AWS Account.
18 | 2. In a terminal, clone this repo.
19 | 3. Install the [Amplify CLI](https://github.com/aws-amplify/amplify-cli) `npm install -g @aws-amplify/cli`. Ensure you are in the directory you just cloned.
20 | 4. If it’s your first time using the CLI, you will need to configure it by running `amplify configure`. Follow the instructions to create an IAM profile locally.
21 | 5. Now let’s initialize an Amplify project in this directory. `amplify init`
22 |
23 | ```
24 | $ amplify init
25 | ? Enter a name for the environment dev
26 | ? Choose your default editor: (pick an editor)
27 | ? Do you want to use an AWS profile? Y (this should be the profile you created in step #4)
28 | ```
29 |
30 | 6. Lastly, the CLI will provision our backend resources using the config files in the `amplify` directory. To provision these resources in the cloud, run `amplify push`. Confirm you want to use the Auth category.
31 |
32 | ## Running the App
33 |
34 | 1. `npm install`
35 | 2. `npm run start`
36 | 3. The app should run on http://localhost:8080/. Try creating an account and signing in.
37 |
38 | ## A Closer Look
39 |
40 | Now that you've built the app, let's take a look under the hood and explore how it works.
41 |
42 | ### Frontend
43 |
44 | Let's dive into the frontend components. In this app, the important logic is in `App.vue`.
45 |
46 | Using the v-if directive we can conditionally render the application based on whether a user is authenticated and signed in. If a user isn’t signed in, let’s display the `amplify-authenticator`:
47 |
48 | ```
49 |
50 |
51 |
52 | ```
53 |
54 | If this is signed in, we can route to a user dashboard component or simply display their username.
55 |
56 | ```
57 |
58 |
Hello, {{ user.username }}
59 |
60 |
61 |
62 | ```
63 |
64 | This works out of the box and displays a standard SignIn/SignOut interface for users.
65 |
66 | ### Backend
67 |
68 | The Amplify CLI is responsible for building the necessary modules in the backend to support user authentication, which in this case lives in the AWS cloud. To be more specific, we will use Amazon Cognito, so there is no need to build your own backend.
69 |
70 | The config files in the `amplify` folder contain these instructions. If you start from scratch, run `amplify add auth` to build these files. Then run, `amplify push` to deploy them on AWS.
71 |
72 | ## Next Steps
73 |
74 | - Read our [Authenticator documentation](https://docs.amplify.aws/ui/auth/authenticator/q/framework/vue) to further customize your app. There are many advanced use cases to build upon.
75 | - Join our communities on [Twitter](https://twitter.com/awsamplify) and [Discord](https://discord.gg/amplify)
76 |
--------------------------------------------------------------------------------
/samples/react/auth/authenticator/README.md:
--------------------------------------------------------------------------------
1 | # Authentication using an Amplify React Authenticator Component
2 |
3 | [Amplify UI Components](https://docs.amplify.aws/ui/q/framework/react) is an open-source toolkit that makes it easier for developers to add common use cases to their applications. The toolkit comes out of the box with a UI interface that is connected to Amplify’s backend services.
4 |
5 | ## What Are We Building?
6 |
7 | In this example, we will use the [Authenticator UI Component](https://docs.amplify.aws/ui/auth/authenticator/q/framework/react) to allow users to signup and signin.
8 |
9 | We have bootstrapped this application using [Create React App](https://github.com/facebook/create-react-app) and will focus on the logic that adds authentication.
10 |
11 |
12 |
13 | ## Let's Get Started!
14 |
15 | ## Setup
16 |
17 | 1. Login or [Create](https://portal.aws.amazon.com/billing/signup?type=enterprise#/start) an AWS Account.
18 | 2. In a terminal, clone this repo.
19 | 3. Install the [Amplify CLI](https://github.com/aws-amplify/amplify-cli) `npm install -g @aws-amplify/cli`. Ensure you are in the directory you just cloned.
20 | 4. If it’s your first time using the CLI, you will need to configure it by running `amplify configure`. Follow the instructions to create an IAM profile locally.
21 | 5. Now let’s initialize an Amplify project in this directory. `amplify init`
22 |
23 | ```
24 | $ amplify init
25 | ? Enter a name for the environment dev
26 | ? Choose your default editor: (pick an editor)
27 | ? Do you want to use an AWS profile? Y (this should be the profile you created in step #4)
28 | ```
29 |
30 | 6. Lastly, the CLI will provision our backend resources using the config files in the `amplify` directory. To provision these resources in the cloud, run `amplify push`. Confirm you want to use the Auth category.
31 |
32 | ## Running the App
33 |
34 | 1. `npm install`
35 | 2. `npm run start`
36 | 3. The app should run on http://localhost:3000/. Try creating an account and signing in.
37 |
38 | ## A Closer Look
39 |
40 | Now that you've built the app, let's take a look under the hood and explore how it works.
41 |
42 | ### Frontend
43 |
44 | Let's dive into the frontend components. In this app, the important logic is in `App.js`.
45 |
46 | Using `AuthState` we can check if a user is authenticated and signed in: `AuthState.SignedIn`. If this is true, we can route to a user dashboard component or simply display their name.
47 |
48 | ```
49 |
Hello, {user.username}
50 |
51 |
52 | ```
53 |
54 | Notice, we also provide a way for users to signout, is the [signout component](https://docs.amplify.aws/ui/auth/authenticator/q/framework/react#sign-out).
55 |
56 | If a user isn’t signed in, let’s display the `AmplifyAuthenticator`:
57 |
58 | ```
59 |
60 |
61 |
62 | ```
63 |
64 | This works out of the box and displays a standard SignIn/SignOut interface for users.
65 |
66 | ### Backend
67 |
68 | The Amplify CLI is responsible for building the necessary modules in the backend to support user authentication, which in this case lives in the AWS cloud. To be more specific, we will use Amazon Cognito, so there is no need to build your own backend.
69 |
70 | The config files in the `amplify` folder contain these instructions. If you start from scratch, run `amplify add auth` to build these files. Then run, `amplify push` to deploy them on AWS.
71 |
72 | ## Next Steps
73 |
74 | - Read our [Authentication documentation](https://docs.amplify.aws/ui/auth/authenticator/q/framework/react) to further customize your app. There are many advanced use cases to build upon.
75 | - Join our communities on [Twitter](https://twitter.com/awsamplify) and [Discord](https://discord.gg/amplify)
76 |
--------------------------------------------------------------------------------
/samples/angular/auth/authenticator/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "tslint:recommended",
3 | "rules": {
4 | "align": {
5 | "options": [
6 | "parameters",
7 | "statements"
8 | ]
9 | },
10 | "array-type": false,
11 | "arrow-return-shorthand": true,
12 | "curly": true,
13 | "deprecation": {
14 | "severity": "warning"
15 | },
16 | "component-class-suffix": true,
17 | "contextual-lifecycle": true,
18 | "directive-class-suffix": true,
19 | "directive-selector": [
20 | true,
21 | "attribute",
22 | "app",
23 | "camelCase"
24 | ],
25 | "component-selector": [
26 | true,
27 | "element",
28 | "app",
29 | "kebab-case"
30 | ],
31 | "eofline": true,
32 | "import-blacklist": [
33 | true,
34 | "rxjs/Rx"
35 | ],
36 | "import-spacing": true,
37 | "indent": {
38 | "options": [
39 | "spaces"
40 | ]
41 | },
42 | "max-classes-per-file": false,
43 | "max-line-length": [
44 | true,
45 | 140
46 | ],
47 | "member-ordering": [
48 | true,
49 | {
50 | "order": [
51 | "static-field",
52 | "instance-field",
53 | "static-method",
54 | "instance-method"
55 | ]
56 | }
57 | ],
58 | "no-console": [
59 | true,
60 | "debug",
61 | "info",
62 | "time",
63 | "timeEnd",
64 | "trace"
65 | ],
66 | "no-empty": false,
67 | "no-inferrable-types": [
68 | true,
69 | "ignore-params"
70 | ],
71 | "no-non-null-assertion": true,
72 | "no-redundant-jsdoc": true,
73 | "no-switch-case-fall-through": true,
74 | "no-var-requires": false,
75 | "object-literal-key-quotes": [
76 | true,
77 | "as-needed"
78 | ],
79 | "quotemark": [
80 | true,
81 | "single"
82 | ],
83 | "semicolon": {
84 | "options": [
85 | "always"
86 | ]
87 | },
88 | "space-before-function-paren": {
89 | "options": {
90 | "anonymous": "never",
91 | "asyncArrow": "always",
92 | "constructor": "never",
93 | "method": "never",
94 | "named": "never"
95 | }
96 | },
97 | "typedef-whitespace": {
98 | "options": [
99 | {
100 | "call-signature": "nospace",
101 | "index-signature": "nospace",
102 | "parameter": "nospace",
103 | "property-declaration": "nospace",
104 | "variable-declaration": "nospace"
105 | },
106 | {
107 | "call-signature": "onespace",
108 | "index-signature": "onespace",
109 | "parameter": "onespace",
110 | "property-declaration": "onespace",
111 | "variable-declaration": "onespace"
112 | }
113 | ]
114 | },
115 | "variable-name": {
116 | "options": [
117 | "ban-keywords",
118 | "check-format",
119 | "allow-pascal-case"
120 | ]
121 | },
122 | "whitespace": {
123 | "options": [
124 | "check-branch",
125 | "check-decl",
126 | "check-operator",
127 | "check-separator",
128 | "check-type",
129 | "check-typecast"
130 | ]
131 | },
132 | "no-conflicting-lifecycle": true,
133 | "no-host-metadata-property": true,
134 | "no-input-rename": true,
135 | "no-inputs-metadata-property": true,
136 | "no-output-native": true,
137 | "no-output-on-prefix": true,
138 | "no-output-rename": true,
139 | "no-outputs-metadata-property": true,
140 | "template-banana-in-box": true,
141 | "template-no-negated-async": true,
142 | "use-lifecycle-interface": true,
143 | "use-pipe-transform-interface": true
144 | },
145 | "rulesDirectory": [
146 | "codelyzer"
147 | ]
148 | }
--------------------------------------------------------------------------------
/samples/react/auth/authenticator/src/serviceWorker.js:
--------------------------------------------------------------------------------
1 | // This optional code is used to register a service worker.
2 | // register() is not called by default.
3 |
4 | // This lets the app load faster on subsequent visits in production, and gives
5 | // it offline capabilities. However, it also means that developers (and users)
6 | // will only see deployed updates on subsequent visits to a page, after all the
7 | // existing tabs open on the page have been closed, since previously cached
8 | // resources are updated in the background.
9 |
10 | // To learn more about the benefits of this model and instructions on how to
11 | // opt-in, read https://bit.ly/CRA-PWA
12 |
13 | const isLocalhost = Boolean(
14 | window.location.hostname === 'localhost' ||
15 | // [::1] is the IPv6 localhost address.
16 | window.location.hostname === '[::1]' ||
17 | // 127.0.0.0/8 are considered localhost for IPv4.
18 | window.location.hostname.match(
19 | /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
20 | )
21 | );
22 |
23 | export function register(config) {
24 | if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
25 | // The URL constructor is available in all browsers that support SW.
26 | const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
27 | if (publicUrl.origin !== window.location.origin) {
28 | // Our service worker won't work if PUBLIC_URL is on a different origin
29 | // from what our page is served on. This might happen if a CDN is used to
30 | // serve assets; see https://github.com/facebook/create-react-app/issues/2374
31 | return;
32 | }
33 |
34 | window.addEventListener('load', () => {
35 | const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
36 |
37 | if (isLocalhost) {
38 | // This is running on localhost. Let's check if a service worker still exists or not.
39 | checkValidServiceWorker(swUrl, config);
40 |
41 | // Add some additional logging to localhost, pointing developers to the
42 | // service worker/PWA documentation.
43 | navigator.serviceWorker.ready.then(() => {
44 | console.log(
45 | 'This web app is being served cache-first by a service ' +
46 | 'worker. To learn more, visit https://bit.ly/CRA-PWA'
47 | );
48 | });
49 | } else {
50 | // Is not localhost. Just register service worker
51 | registerValidSW(swUrl, config);
52 | }
53 | });
54 | }
55 | }
56 |
57 | function registerValidSW(swUrl, config) {
58 | navigator.serviceWorker
59 | .register(swUrl)
60 | .then(registration => {
61 | registration.onupdatefound = () => {
62 | const installingWorker = registration.installing;
63 | if (installingWorker == null) {
64 | return;
65 | }
66 | installingWorker.onstatechange = () => {
67 | if (installingWorker.state === 'installed') {
68 | if (navigator.serviceWorker.controller) {
69 | // At this point, the updated precached content has been fetched,
70 | // but the previous service worker will still serve the older
71 | // content until all client tabs are closed.
72 | console.log(
73 | 'New content is available and will be used when all ' +
74 | 'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
75 | );
76 |
77 | // Execute callback
78 | if (config && config.onUpdate) {
79 | config.onUpdate(registration);
80 | }
81 | } else {
82 | // At this point, everything has been precached.
83 | // It's the perfect time to display a
84 | // "Content is cached for offline use." message.
85 | console.log('Content is cached for offline use.');
86 |
87 | // Execute callback
88 | if (config && config.onSuccess) {
89 | config.onSuccess(registration);
90 | }
91 | }
92 | }
93 | };
94 | };
95 | })
96 | .catch(error => {
97 | console.error('Error during service worker registration:', error);
98 | });
99 | }
100 |
101 | function checkValidServiceWorker(swUrl, config) {
102 | // Check if the service worker can be found. If it can't reload the page.
103 | fetch(swUrl, {
104 | headers: { 'Service-Worker': 'script' },
105 | })
106 | .then(response => {
107 | // Ensure service worker exists, and that we really are getting a JS file.
108 | const contentType = response.headers.get('content-type');
109 | if (
110 | response.status === 404 ||
111 | (contentType != null && contentType.indexOf('javascript') === -1)
112 | ) {
113 | // No service worker found. Probably a different app. Reload the page.
114 | navigator.serviceWorker.ready.then(registration => {
115 | registration.unregister().then(() => {
116 | window.location.reload();
117 | });
118 | });
119 | } else {
120 | // Service worker found. Proceed as normal.
121 | registerValidSW(swUrl, config);
122 | }
123 | })
124 | .catch(() => {
125 | console.log(
126 | 'No internet connection found. App is running in offline mode.'
127 | );
128 | });
129 | }
130 |
131 | export function unregister() {
132 | if ('serviceWorker' in navigator) {
133 | navigator.serviceWorker.ready
134 | .then(registration => {
135 | registration.unregister();
136 | })
137 | .catch(error => {
138 | console.error(error.message);
139 | });
140 | }
141 | }
142 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
--------------------------------------------------------------------------------
/samples/react/auth/authenticator/amplify/backend/auth/authenticatordf03bc0b/authenticatordf03bc0b-cloudformation-template.yml:
--------------------------------------------------------------------------------
1 | AWSTemplateFormatVersion: '2010-09-09'
2 | Parameters:
3 | env:
4 | Type: String
5 | authRoleArn:
6 | Type: String
7 | unauthRoleArn:
8 | Type: String
9 | identityPoolName:
10 | Type: String
11 | allowUnauthenticatedIdentities:
12 | Type: String
13 | resourceNameTruncated:
14 | Type: String
15 | userPoolName:
16 | Type: String
17 | autoVerifiedAttributes:
18 | Type: CommaDelimitedList
19 | mfaConfiguration:
20 | Type: String
21 | mfaTypes:
22 | Type: CommaDelimitedList
23 | smsAuthenticationMessage:
24 | Type: String
25 | smsVerificationMessage:
26 | Type: String
27 | emailVerificationSubject:
28 | Type: String
29 | emailVerificationMessage:
30 | Type: String
31 | defaultPasswordPolicy:
32 | Type: String
33 | passwordPolicyMinLength:
34 | Type: Number
35 | passwordPolicyCharacters:
36 | Type: CommaDelimitedList
37 | requiredAttributes:
38 | Type: CommaDelimitedList
39 | userpoolClientGenerateSecret:
40 | Type: String
41 | userpoolClientRefreshTokenValidity:
42 | Type: Number
43 | userpoolClientWriteAttributes:
44 | Type: CommaDelimitedList
45 | userpoolClientReadAttributes:
46 | Type: CommaDelimitedList
47 | userpoolClientLambdaRole:
48 | Type: String
49 | userpoolClientSetAttributes:
50 | Type: String
51 | resourceName:
52 | Type: String
53 | authSelections:
54 | Type: String
55 | useDefault:
56 | Type: String
57 | userPoolGroupList:
58 | Type: CommaDelimitedList
59 | dependsOn:
60 | Type: CommaDelimitedList
61 | Conditions:
62 | ShouldNotCreateEnvResources:
63 | Fn::Equals:
64 | - Ref: env
65 | - NONE
66 | Resources:
67 | SNSRole:
68 | Type: AWS::IAM::Role
69 | Properties:
70 | RoleName:
71 | Fn::If:
72 | - ShouldNotCreateEnvResources
73 | - authendf03bc0b_sns-role
74 | - Fn::Join:
75 | - ''
76 | - - sns
77 | - Fn::Select:
78 | - 3
79 | - Fn::Split:
80 | - '-'
81 | - Ref: AWS::StackName
82 | - '-'
83 | - Ref: env
84 | AssumeRolePolicyDocument:
85 | Version: '2012-10-17'
86 | Statement:
87 | - Sid: ''
88 | Effect: Allow
89 | Principal:
90 | Service: cognito-idp.amazonaws.com
91 | Action:
92 | - sts:AssumeRole
93 | Condition:
94 | StringEquals:
95 | sts:ExternalId: authendf03bc0b_role_external_id
96 | Policies:
97 | - PolicyName: authendf03bc0b-sns-policy
98 | PolicyDocument:
99 | Version: '2012-10-17'
100 | Statement:
101 | - Effect: Allow
102 | Action:
103 | - sns:Publish
104 | Resource: '*'
105 | UserPool:
106 | Type: AWS::Cognito::UserPool
107 | UpdateReplacePolicy: Retain
108 | Properties:
109 | UserPoolName:
110 | Fn::If:
111 | - ShouldNotCreateEnvResources
112 | - Ref: userPoolName
113 | - Fn::Join:
114 | - ''
115 | - - Ref: userPoolName
116 | - '-'
117 | - Ref: env
118 | Schema:
119 | - Name: email
120 | Required: true
121 | Mutable: true
122 | AutoVerifiedAttributes:
123 | Ref: autoVerifiedAttributes
124 | EmailVerificationMessage:
125 | Ref: emailVerificationMessage
126 | EmailVerificationSubject:
127 | Ref: emailVerificationSubject
128 | Policies:
129 | PasswordPolicy:
130 | MinimumLength:
131 | Ref: passwordPolicyMinLength
132 | RequireLowercase: false
133 | RequireNumbers: false
134 | RequireSymbols: false
135 | RequireUppercase: false
136 | MfaConfiguration:
137 | Ref: mfaConfiguration
138 | SmsVerificationMessage:
139 | Ref: smsVerificationMessage
140 | SmsConfiguration:
141 | SnsCallerArn:
142 | Fn::GetAtt:
143 | - SNSRole
144 | - Arn
145 | ExternalId: authendf03bc0b_role_external_id
146 | UserPoolClientWeb:
147 | Type: AWS::Cognito::UserPoolClient
148 | Properties:
149 | ClientName: authendf03bc0b_app_clientWeb
150 | RefreshTokenValidity:
151 | Ref: userpoolClientRefreshTokenValidity
152 | UserPoolId:
153 | Ref: UserPool
154 | DependsOn: UserPool
155 | UserPoolClient:
156 | Type: AWS::Cognito::UserPoolClient
157 | Properties:
158 | ClientName: authendf03bc0b_app_client
159 | GenerateSecret:
160 | Ref: userpoolClientGenerateSecret
161 | RefreshTokenValidity:
162 | Ref: userpoolClientRefreshTokenValidity
163 | UserPoolId:
164 | Ref: UserPool
165 | DependsOn: UserPool
166 | UserPoolClientRole:
167 | Type: AWS::IAM::Role
168 | Properties:
169 | RoleName:
170 | Fn::If:
171 | - ShouldNotCreateEnvResources
172 | - Ref: userpoolClientLambdaRole
173 | - Fn::Join:
174 | - ''
175 | - - upClientLambdaRole
176 | - Fn::Select:
177 | - 3
178 | - Fn::Split:
179 | - '-'
180 | - Ref: AWS::StackName
181 | - '-'
182 | - Ref: env
183 | AssumeRolePolicyDocument:
184 | Version: '2012-10-17'
185 | Statement:
186 | - Effect: Allow
187 | Principal:
188 | Service:
189 | - lambda.amazonaws.com
190 | Action:
191 | - sts:AssumeRole
192 | DependsOn: UserPoolClient
193 | UserPoolClientLambda:
194 | Type: AWS::Lambda::Function
195 | Properties:
196 | Code:
197 | ZipFile:
198 | Fn::Join:
199 | - ''
200 | - - const response = require('cfn-response');
201 | - const aws = require('aws-sdk');
202 | - const identity = new aws.CognitoIdentityServiceProvider();
203 | - exports.handler = (event, context, callback) => {
204 | - ' if (event.RequestType == ''Delete'') { '
205 | - ' response.send(event, context, response.SUCCESS, {})'
206 | - ' }'
207 | - ' if (event.RequestType == ''Update'' || event.RequestType == ''Create'') {'
208 | - ' const params = {'
209 | - ' ClientId: event.ResourceProperties.clientId,'
210 | - ' UserPoolId: event.ResourceProperties.userpoolId'
211 | - ' };'
212 | - ' identity.describeUserPoolClient(params).promise()'
213 | - ' .then((res) => {'
214 | - ' response.send(event, context, response.SUCCESS, {''appSecret'': res.UserPoolClient.ClientSecret});'
215 | - ' })'
216 | - ' .catch((err) => {'
217 | - ' response.send(event, context, response.FAILED, {err});'
218 | - ' });'
219 | - ' }'
220 | - '};'
221 | Handler: index.handler
222 | Runtime: nodejs12.x
223 | Timeout: '300'
224 | Role:
225 | Fn::GetAtt:
226 | - UserPoolClientRole
227 | - Arn
228 | DependsOn: UserPoolClientRole
229 | UserPoolClientLambdaPolicy:
230 | Type: AWS::IAM::Policy
231 | Properties:
232 | PolicyName: authendf03bc0b_userpoolclient_lambda_iam_policy
233 | Roles:
234 | - Ref: UserPoolClientRole
235 | PolicyDocument:
236 | Version: '2012-10-17'
237 | Statement:
238 | - Effect: Allow
239 | Action:
240 | - cognito-idp:DescribeUserPoolClient
241 | Resource:
242 | Fn::GetAtt:
243 | - UserPool
244 | - Arn
245 | DependsOn: UserPoolClientLambda
246 | UserPoolClientLogPolicy:
247 | Type: AWS::IAM::Policy
248 | Properties:
249 | PolicyName: authendf03bc0b_userpoolclient_lambda_log_policy
250 | Roles:
251 | - Ref: UserPoolClientRole
252 | PolicyDocument:
253 | Version: '2012-10-17'
254 | Statement:
255 | - Effect: Allow
256 | Action:
257 | - logs:CreateLogGroup
258 | - logs:CreateLogStream
259 | - logs:PutLogEvents
260 | Resource:
261 | Fn::Sub:
262 | - >-
263 | arn:aws:logs:${region}:${account}:log-group:/aws/lambda/${lambda}:log-stream:*
264 | - region:
265 | Ref: AWS::Region
266 | account:
267 | Ref: AWS::AccountId
268 | lambda:
269 | Ref: UserPoolClientLambda
270 | DependsOn: UserPoolClientLambdaPolicy
271 | UserPoolClientInputs:
272 | Type: Custom::LambdaCallout
273 | Properties:
274 | ServiceToken:
275 | Fn::GetAtt:
276 | - UserPoolClientLambda
277 | - Arn
278 | clientId:
279 | Ref: UserPoolClient
280 | userpoolId:
281 | Ref: UserPool
282 | DependsOn: UserPoolClientLogPolicy
283 | IdentityPool:
284 | Type: AWS::Cognito::IdentityPool
285 | Properties:
286 | IdentityPoolName:
287 | Fn::If:
288 | - ShouldNotCreateEnvResources
289 | - authenticatordf03bc0b_identitypool_df03bc0b
290 | - Fn::Join:
291 | - ''
292 | - - authenticatordf03bc0b_identitypool_df03bc0b
293 | - __
294 | - Ref: env
295 | CognitoIdentityProviders:
296 | - ClientId:
297 | Ref: UserPoolClient
298 | ProviderName:
299 | Fn::Sub:
300 | - cognito-idp.${region}.amazonaws.com/${client}
301 | - region:
302 | Ref: AWS::Region
303 | client:
304 | Ref: UserPool
305 | - ClientId:
306 | Ref: UserPoolClientWeb
307 | ProviderName:
308 | Fn::Sub:
309 | - cognito-idp.${region}.amazonaws.com/${client}
310 | - region:
311 | Ref: AWS::Region
312 | client:
313 | Ref: UserPool
314 | AllowUnauthenticatedIdentities:
315 | Ref: allowUnauthenticatedIdentities
316 | DependsOn: UserPoolClientInputs
317 | IdentityPoolRoleMap:
318 | Type: AWS::Cognito::IdentityPoolRoleAttachment
319 | Properties:
320 | IdentityPoolId:
321 | Ref: IdentityPool
322 | Roles:
323 | unauthenticated:
324 | Ref: unauthRoleArn
325 | authenticated:
326 | Ref: authRoleArn
327 | DependsOn: IdentityPool
328 | Outputs:
329 | IdentityPoolId:
330 | Value:
331 | Ref: IdentityPool
332 | Description: Id for the identity pool
333 | IdentityPoolName:
334 | Value:
335 | Fn::GetAtt:
336 | - IdentityPool
337 | - Name
338 | UserPoolId:
339 | Value:
340 | Ref: UserPool
341 | Description: Id for the user pool
342 | UserPoolName:
343 | Value:
344 | Ref: userPoolName
345 | AppClientIDWeb:
346 | Value:
347 | Ref: UserPoolClientWeb
348 | Description: The user pool app client id for web
349 | AppClientID:
350 | Value:
351 | Ref: UserPoolClient
352 | Description: The user pool app client id
353 | AppClientSecret:
354 | Value:
355 | Fn::GetAtt:
356 | - UserPoolClientInputs
357 | - appSecret
358 | Description: >-
359 | {"createdOn":"Mac","createdBy":"Amplify","createdWith":"7.6.3","stackType":"auth-Cognito","metadata":{}}
360 |
--------------------------------------------------------------------------------
/samples/angular/auth/authenticator/amplify/backend/auth/angauthenticator98214054/angauthenticator98214054-cloudformation-template.yml:
--------------------------------------------------------------------------------
1 | AWSTemplateFormatVersion: 2010-09-09
2 |
3 | Parameters:
4 | env:
5 | Type: String
6 | authRoleArn:
7 | Type: String
8 | unauthRoleArn:
9 | Type: String
10 |
11 |
12 |
13 |
14 | identityPoolName:
15 | Type: String
16 |
17 | allowUnauthenticatedIdentities:
18 | Type: String
19 |
20 | resourceNameTruncated:
21 | Type: String
22 |
23 | userPoolName:
24 | Type: String
25 |
26 | autoVerifiedAttributes:
27 | Type: CommaDelimitedList
28 |
29 | mfaConfiguration:
30 | Type: String
31 |
32 | mfaTypes:
33 | Type: CommaDelimitedList
34 |
35 | smsAuthenticationMessage:
36 | Type: String
37 |
38 | smsVerificationMessage:
39 | Type: String
40 |
41 | emailVerificationSubject:
42 | Type: String
43 |
44 | emailVerificationMessage:
45 | Type: String
46 |
47 | defaultPasswordPolicy:
48 | Type: String
49 |
50 | passwordPolicyMinLength:
51 | Type: Number
52 |
53 | passwordPolicyCharacters:
54 | Type: CommaDelimitedList
55 |
56 | requiredAttributes:
57 | Type: CommaDelimitedList
58 |
59 | userpoolClientGenerateSecret:
60 | Type: String
61 |
62 | userpoolClientRefreshTokenValidity:
63 | Type: Number
64 |
65 | userpoolClientWriteAttributes:
66 | Type: CommaDelimitedList
67 |
68 | userpoolClientReadAttributes:
69 | Type: CommaDelimitedList
70 |
71 | userpoolClientLambdaRole:
72 | Type: String
73 |
74 | userpoolClientSetAttributes:
75 | Type: String
76 |
77 | resourceName:
78 | Type: String
79 |
80 | authSelections:
81 | Type: String
82 |
83 | useDefault:
84 | Type: String
85 |
86 | userPoolGroupList:
87 | Type: CommaDelimitedList
88 |
89 | dependsOn:
90 | Type: CommaDelimitedList
91 |
92 | Conditions:
93 | ShouldNotCreateEnvResources: !Equals [ !Ref env, NONE ]
94 |
95 | Resources:
96 |
97 |
98 | # BEGIN SNS ROLE RESOURCE
99 | SNSRole:
100 | # Created to allow the UserPool SMS Config to publish via the Simple Notification Service during MFA Process
101 | Type: AWS::IAM::Role
102 | Properties:
103 | RoleName: !If [ShouldNotCreateEnvResources, 'angaut98214054_sns-role', !Join ['',[ 'sns', !Select [3, !Split ['-', !Ref 'AWS::StackName']], '-', !Ref env]]]
104 | AssumeRolePolicyDocument:
105 | Version: "2012-10-17"
106 | Statement:
107 | - Sid: ""
108 | Effect: "Allow"
109 | Principal:
110 | Service: "cognito-idp.amazonaws.com"
111 | Action:
112 | - "sts:AssumeRole"
113 | Condition:
114 | StringEquals:
115 | sts:ExternalId: angaut98214054_role_external_id
116 | Policies:
117 | -
118 | PolicyName: angaut98214054-sns-policy
119 | PolicyDocument:
120 | Version: "2012-10-17"
121 | Statement:
122 | -
123 | Effect: "Allow"
124 | Action:
125 | - "sns:Publish"
126 | Resource: "*"
127 | # BEGIN USER POOL RESOURCES
128 | UserPool:
129 | # Created upon user selection
130 | # Depends on SNS Role for Arn if MFA is enabled
131 | Type: AWS::Cognito::UserPool
132 | UpdateReplacePolicy: Retain
133 | Properties:
134 | UserPoolName: !If [ShouldNotCreateEnvResources, !Ref userPoolName, !Join ['',[!Ref userPoolName, '-', !Ref env]]]
135 |
136 | Schema:
137 |
138 | -
139 | Name: email
140 | Required: true
141 | Mutable: true
142 |
143 |
144 |
145 |
146 | AutoVerifiedAttributes: !Ref autoVerifiedAttributes
147 |
148 |
149 | EmailVerificationMessage: !Ref emailVerificationMessage
150 | EmailVerificationSubject: !Ref emailVerificationSubject
151 |
152 | Policies:
153 | PasswordPolicy:
154 | MinimumLength: !Ref passwordPolicyMinLength
155 | RequireLowercase: false
156 | RequireNumbers: false
157 | RequireSymbols: false
158 | RequireUppercase: false
159 |
160 | MfaConfiguration: !Ref mfaConfiguration
161 | SmsVerificationMessage: !Ref smsVerificationMessage
162 | SmsConfiguration:
163 | SnsCallerArn: !GetAtt SNSRole.Arn
164 | ExternalId: angaut98214054_role_external_id
165 |
166 |
167 | UserPoolClientWeb:
168 | # Created provide application access to user pool
169 | # Depends on UserPool for ID reference
170 | Type: "AWS::Cognito::UserPoolClient"
171 | Properties:
172 | ClientName: angaut98214054_app_clientWeb
173 |
174 | RefreshTokenValidity: !Ref userpoolClientRefreshTokenValidity
175 | UserPoolId: !Ref UserPool
176 | DependsOn: UserPool
177 | UserPoolClient:
178 | # Created provide application access to user pool
179 | # Depends on UserPool for ID reference
180 | Type: "AWS::Cognito::UserPoolClient"
181 | Properties:
182 | ClientName: angaut98214054_app_client
183 |
184 | GenerateSecret: !Ref userpoolClientGenerateSecret
185 | RefreshTokenValidity: !Ref userpoolClientRefreshTokenValidity
186 | UserPoolId: !Ref UserPool
187 | DependsOn: UserPool
188 | # BEGIN USER POOL LAMBDA RESOURCES
189 | UserPoolClientRole:
190 | # Created to execute Lambda which gets userpool app client config values
191 | Type: 'AWS::IAM::Role'
192 | Properties:
193 | RoleName: !If [ShouldNotCreateEnvResources, !Ref userpoolClientLambdaRole, !Join ['',['upClientLambdaRole', !Select [3, !Split ['-', !Ref 'AWS::StackName']], '-', !Ref env]]]
194 | AssumeRolePolicyDocument:
195 | Version: '2012-10-17'
196 | Statement:
197 | - Effect: Allow
198 | Principal:
199 | Service:
200 | - lambda.amazonaws.com
201 | Action:
202 | - 'sts:AssumeRole'
203 | DependsOn: UserPoolClient
204 | UserPoolClientLambda:
205 | # Lambda which gets userpool app client config values
206 | # Depends on UserPool for id
207 | # Depends on UserPoolClientRole for role ARN
208 | Type: 'AWS::Lambda::Function'
209 | Properties:
210 | Code:
211 | ZipFile: !Join
212 | - |+
213 | - - 'const response = require(''cfn-response'');'
214 | - 'const aws = require(''aws-sdk'');'
215 | - 'const identity = new aws.CognitoIdentityServiceProvider();'
216 | - 'exports.handler = (event, context, callback) => {'
217 | - ' if (event.RequestType == ''Delete'') { '
218 | - ' response.send(event, context, response.SUCCESS, {})'
219 | - ' }'
220 | - ' if (event.RequestType == ''Update'' || event.RequestType == ''Create'') {'
221 | - ' const params = {'
222 | - ' ClientId: event.ResourceProperties.clientId,'
223 | - ' UserPoolId: event.ResourceProperties.userpoolId'
224 | - ' };'
225 | - ' identity.describeUserPoolClient(params).promise()'
226 | - ' .then((res) => {'
227 | - ' response.send(event, context, response.SUCCESS, {''appSecret'': res.UserPoolClient.ClientSecret});'
228 | - ' })'
229 | - ' .catch((err) => {'
230 | - ' response.send(event, context, response.FAILED, {err});'
231 | - ' });'
232 | - ' }'
233 | - '};'
234 | Handler: index.handler
235 | Runtime: nodejs10.x
236 | Timeout: '300'
237 | Role: !GetAtt
238 | - UserPoolClientRole
239 | - Arn
240 | DependsOn: UserPoolClientRole
241 | UserPoolClientLambdaPolicy:
242 | # Sets userpool policy for the role that executes the Userpool Client Lambda
243 | # Depends on UserPool for Arn
244 | # Marked as depending on UserPoolClientRole for easier to understand CFN sequencing
245 | Type: 'AWS::IAM::Policy'
246 | Properties:
247 | PolicyName: angaut98214054_userpoolclient_lambda_iam_policy
248 | Roles:
249 | - !Ref UserPoolClientRole
250 | PolicyDocument:
251 | Version: '2012-10-17'
252 | Statement:
253 | - Effect: Allow
254 | Action:
255 | - 'cognito-idp:DescribeUserPoolClient'
256 | Resource: !GetAtt UserPool.Arn
257 | DependsOn: UserPoolClientLambda
258 | UserPoolClientLogPolicy:
259 | # Sets log policy for the role that executes the Userpool Client Lambda
260 | # Depends on UserPool for Arn
261 | # Marked as depending on UserPoolClientLambdaPolicy for easier to understand CFN sequencing
262 | Type: 'AWS::IAM::Policy'
263 | Properties:
264 | PolicyName: angaut98214054_userpoolclient_lambda_log_policy
265 | Roles:
266 | - !Ref UserPoolClientRole
267 | PolicyDocument:
268 | Version: 2012-10-17
269 | Statement:
270 | - Effect: Allow
271 | Action:
272 | - 'logs:CreateLogGroup'
273 | - 'logs:CreateLogStream'
274 | - 'logs:PutLogEvents'
275 | Resource: !Sub
276 | - arn:aws:logs:${region}:${account}:log-group:/aws/lambda/${lambda}:log-stream:*
277 | - { region: !Ref "AWS::Region", account: !Ref "AWS::AccountId", lambda: !Ref UserPoolClientLambda}
278 | DependsOn: UserPoolClientLambdaPolicy
279 | UserPoolClientInputs:
280 | # Values passed to Userpool client Lambda
281 | # Depends on UserPool for Id
282 | # Depends on UserPoolClient for Id
283 | # Marked as depending on UserPoolClientLambdaPolicy for easier to understand CFN sequencing
284 | Type: 'Custom::LambdaCallout'
285 | Properties:
286 | ServiceToken: !GetAtt UserPoolClientLambda.Arn
287 | clientId: !Ref UserPoolClient
288 | userpoolId: !Ref UserPool
289 | DependsOn: UserPoolClientLogPolicy
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 | # BEGIN IDENTITY POOL RESOURCES
298 |
299 |
300 | IdentityPool:
301 | # Always created
302 | Type: AWS::Cognito::IdentityPool
303 | Properties:
304 | IdentityPoolName: !If [ShouldNotCreateEnvResources, 'angauthenticator98214054_identitypool_98214054', !Join ['',['angauthenticator98214054_identitypool_98214054', '__', !Ref env]]]
305 |
306 | CognitoIdentityProviders:
307 | - ClientId: !Ref UserPoolClient
308 | ProviderName: !Sub
309 | - cognito-idp.${region}.amazonaws.com/${client}
310 | - { region: !Ref "AWS::Region", client: !Ref UserPool}
311 | - ClientId: !Ref UserPoolClientWeb
312 | ProviderName: !Sub
313 | - cognito-idp.${region}.amazonaws.com/${client}
314 | - { region: !Ref "AWS::Region", client: !Ref UserPool}
315 |
316 | AllowUnauthenticatedIdentities: !Ref allowUnauthenticatedIdentities
317 |
318 |
319 | DependsOn: UserPoolClientInputs
320 |
321 |
322 | IdentityPoolRoleMap:
323 | # Created to map Auth and Unauth roles to the identity pool
324 | # Depends on Identity Pool for ID ref
325 | Type: AWS::Cognito::IdentityPoolRoleAttachment
326 | Properties:
327 | IdentityPoolId: !Ref IdentityPool
328 | Roles:
329 | unauthenticated: !Ref unauthRoleArn
330 | authenticated: !Ref authRoleArn
331 | DependsOn: IdentityPool
332 |
333 |
334 | Outputs :
335 |
336 | IdentityPoolId:
337 | Value: !Ref 'IdentityPool'
338 | Description: Id for the identity pool
339 | IdentityPoolName:
340 | Value: !GetAtt IdentityPool.Name
341 |
342 |
343 |
344 |
345 | UserPoolId:
346 | Value: !Ref 'UserPool'
347 | Description: Id for the user pool
348 | UserPoolName:
349 | Value: !Ref userPoolName
350 | AppClientIDWeb:
351 | Value: !Ref 'UserPoolClientWeb'
352 | Description: The user pool app client id for web
353 | AppClientID:
354 | Value: !Ref 'UserPoolClient'
355 | Description: The user pool app client id
356 | AppClientSecret:
357 | Value: !GetAtt UserPoolClientInputs.appSecret
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
--------------------------------------------------------------------------------
/samples/vue/auth/authenticator/amplify/backend/auth/publicvueauthcomp6994b8e7/publicvueauthcomp6994b8e7-cloudformation-template.yml:
--------------------------------------------------------------------------------
1 | AWSTemplateFormatVersion: 2010-09-09
2 |
3 | Parameters:
4 | env:
5 | Type: String
6 | authRoleArn:
7 | Type: String
8 | unauthRoleArn:
9 | Type: String
10 |
11 |
12 |
13 |
14 | identityPoolName:
15 | Type: String
16 |
17 | allowUnauthenticatedIdentities:
18 | Type: String
19 |
20 | resourceNameTruncated:
21 | Type: String
22 |
23 | userPoolName:
24 | Type: String
25 |
26 | autoVerifiedAttributes:
27 | Type: CommaDelimitedList
28 |
29 | mfaConfiguration:
30 | Type: String
31 |
32 | mfaTypes:
33 | Type: CommaDelimitedList
34 |
35 | smsAuthenticationMessage:
36 | Type: String
37 |
38 | smsVerificationMessage:
39 | Type: String
40 |
41 | emailVerificationSubject:
42 | Type: String
43 |
44 | emailVerificationMessage:
45 | Type: String
46 |
47 | defaultPasswordPolicy:
48 | Type: String
49 |
50 | passwordPolicyMinLength:
51 | Type: Number
52 |
53 | passwordPolicyCharacters:
54 | Type: CommaDelimitedList
55 |
56 | requiredAttributes:
57 | Type: CommaDelimitedList
58 |
59 | userpoolClientGenerateSecret:
60 | Type: String
61 |
62 | userpoolClientRefreshTokenValidity:
63 | Type: Number
64 |
65 | userpoolClientWriteAttributes:
66 | Type: CommaDelimitedList
67 |
68 | userpoolClientReadAttributes:
69 | Type: CommaDelimitedList
70 |
71 | userpoolClientLambdaRole:
72 | Type: String
73 |
74 | userpoolClientSetAttributes:
75 | Type: String
76 |
77 | resourceName:
78 | Type: String
79 |
80 | authSelections:
81 | Type: String
82 |
83 | useDefault:
84 | Type: String
85 |
86 | userPoolGroupList:
87 | Type: CommaDelimitedList
88 |
89 | dependsOn:
90 | Type: CommaDelimitedList
91 |
92 | Conditions:
93 | ShouldNotCreateEnvResources: !Equals [ !Ref env, NONE ]
94 |
95 | Resources:
96 |
97 |
98 | # BEGIN SNS ROLE RESOURCE
99 | SNSRole:
100 | # Created to allow the UserPool SMS Config to publish via the Simple Notification Service during MFA Process
101 | Type: AWS::IAM::Role
102 | Properties:
103 | RoleName: !If [ShouldNotCreateEnvResources, 'public6994b8e7_sns-role', !Join ['',[ 'sns', !Select [3, !Split ['-', !Ref 'AWS::StackName']], '-', !Ref env]]]
104 | AssumeRolePolicyDocument:
105 | Version: "2012-10-17"
106 | Statement:
107 | - Sid: ""
108 | Effect: "Allow"
109 | Principal:
110 | Service: "cognito-idp.amazonaws.com"
111 | Action:
112 | - "sts:AssumeRole"
113 | Condition:
114 | StringEquals:
115 | sts:ExternalId: public6994b8e7_role_external_id
116 | Policies:
117 | -
118 | PolicyName: public6994b8e7-sns-policy
119 | PolicyDocument:
120 | Version: "2012-10-17"
121 | Statement:
122 | -
123 | Effect: "Allow"
124 | Action:
125 | - "sns:Publish"
126 | Resource: "*"
127 | # BEGIN USER POOL RESOURCES
128 | UserPool:
129 | # Created upon user selection
130 | # Depends on SNS Role for Arn if MFA is enabled
131 | Type: AWS::Cognito::UserPool
132 | UpdateReplacePolicy: Retain
133 | Properties:
134 | UserPoolName: !If [ShouldNotCreateEnvResources, !Ref userPoolName, !Join ['',[!Ref userPoolName, '-', !Ref env]]]
135 |
136 | Schema:
137 |
138 | -
139 | Name: email
140 | Required: true
141 | Mutable: true
142 |
143 |
144 |
145 |
146 | AutoVerifiedAttributes: !Ref autoVerifiedAttributes
147 |
148 |
149 | EmailVerificationMessage: !Ref emailVerificationMessage
150 | EmailVerificationSubject: !Ref emailVerificationSubject
151 |
152 | Policies:
153 | PasswordPolicy:
154 | MinimumLength: !Ref passwordPolicyMinLength
155 | RequireLowercase: false
156 | RequireNumbers: false
157 | RequireSymbols: false
158 | RequireUppercase: false
159 |
160 | MfaConfiguration: !Ref mfaConfiguration
161 | SmsVerificationMessage: !Ref smsVerificationMessage
162 | SmsConfiguration:
163 | SnsCallerArn: !GetAtt SNSRole.Arn
164 | ExternalId: public6994b8e7_role_external_id
165 |
166 |
167 | UserPoolClientWeb:
168 | # Created provide application access to user pool
169 | # Depends on UserPool for ID reference
170 | Type: "AWS::Cognito::UserPoolClient"
171 | Properties:
172 | ClientName: public6994b8e7_app_clientWeb
173 |
174 | RefreshTokenValidity: !Ref userpoolClientRefreshTokenValidity
175 | UserPoolId: !Ref UserPool
176 | DependsOn: UserPool
177 | UserPoolClient:
178 | # Created provide application access to user pool
179 | # Depends on UserPool for ID reference
180 | Type: "AWS::Cognito::UserPoolClient"
181 | Properties:
182 | ClientName: public6994b8e7_app_client
183 |
184 | GenerateSecret: !Ref userpoolClientGenerateSecret
185 | RefreshTokenValidity: !Ref userpoolClientRefreshTokenValidity
186 | UserPoolId: !Ref UserPool
187 | DependsOn: UserPool
188 | # BEGIN USER POOL LAMBDA RESOURCES
189 | UserPoolClientRole:
190 | # Created to execute Lambda which gets userpool app client config values
191 | Type: 'AWS::IAM::Role'
192 | Properties:
193 | RoleName: !If [ShouldNotCreateEnvResources, !Ref userpoolClientLambdaRole, !Join ['',['upClientLambdaRole', !Select [3, !Split ['-', !Ref 'AWS::StackName']], '-', !Ref env]]]
194 | AssumeRolePolicyDocument:
195 | Version: '2012-10-17'
196 | Statement:
197 | - Effect: Allow
198 | Principal:
199 | Service:
200 | - lambda.amazonaws.com
201 | Action:
202 | - 'sts:AssumeRole'
203 | DependsOn: UserPoolClient
204 | UserPoolClientLambda:
205 | # Lambda which gets userpool app client config values
206 | # Depends on UserPool for id
207 | # Depends on UserPoolClientRole for role ARN
208 | Type: 'AWS::Lambda::Function'
209 | Properties:
210 | Code:
211 | ZipFile: !Join
212 | - |+
213 | - - 'const response = require(''cfn-response'');'
214 | - 'const aws = require(''aws-sdk'');'
215 | - 'const identity = new aws.CognitoIdentityServiceProvider();'
216 | - 'exports.handler = (event, context, callback) => {'
217 | - ' if (event.RequestType == ''Delete'') { '
218 | - ' response.send(event, context, response.SUCCESS, {})'
219 | - ' }'
220 | - ' if (event.RequestType == ''Update'' || event.RequestType == ''Create'') {'
221 | - ' const params = {'
222 | - ' ClientId: event.ResourceProperties.clientId,'
223 | - ' UserPoolId: event.ResourceProperties.userpoolId'
224 | - ' };'
225 | - ' identity.describeUserPoolClient(params).promise()'
226 | - ' .then((res) => {'
227 | - ' response.send(event, context, response.SUCCESS, {''appSecret'': res.UserPoolClient.ClientSecret});'
228 | - ' })'
229 | - ' .catch((err) => {'
230 | - ' response.send(event, context, response.FAILED, {err});'
231 | - ' });'
232 | - ' }'
233 | - '};'
234 | Handler: index.handler
235 | Runtime: nodejs10.x
236 | Timeout: '300'
237 | Role: !GetAtt
238 | - UserPoolClientRole
239 | - Arn
240 | DependsOn: UserPoolClientRole
241 | UserPoolClientLambdaPolicy:
242 | # Sets userpool policy for the role that executes the Userpool Client Lambda
243 | # Depends on UserPool for Arn
244 | # Marked as depending on UserPoolClientRole for easier to understand CFN sequencing
245 | Type: 'AWS::IAM::Policy'
246 | Properties:
247 | PolicyName: public6994b8e7_userpoolclient_lambda_iam_policy
248 | Roles:
249 | - !Ref UserPoolClientRole
250 | PolicyDocument:
251 | Version: '2012-10-17'
252 | Statement:
253 | - Effect: Allow
254 | Action:
255 | - 'cognito-idp:DescribeUserPoolClient'
256 | Resource: !GetAtt UserPool.Arn
257 | DependsOn: UserPoolClientLambda
258 | UserPoolClientLogPolicy:
259 | # Sets log policy for the role that executes the Userpool Client Lambda
260 | # Depends on UserPool for Arn
261 | # Marked as depending on UserPoolClientLambdaPolicy for easier to understand CFN sequencing
262 | Type: 'AWS::IAM::Policy'
263 | Properties:
264 | PolicyName: public6994b8e7_userpoolclient_lambda_log_policy
265 | Roles:
266 | - !Ref UserPoolClientRole
267 | PolicyDocument:
268 | Version: 2012-10-17
269 | Statement:
270 | - Effect: Allow
271 | Action:
272 | - 'logs:CreateLogGroup'
273 | - 'logs:CreateLogStream'
274 | - 'logs:PutLogEvents'
275 | Resource: !Sub
276 | - arn:aws:logs:${region}:${account}:log-group:/aws/lambda/${lambda}:log-stream:*
277 | - { region: !Ref "AWS::Region", account: !Ref "AWS::AccountId", lambda: !Ref UserPoolClientLambda}
278 | DependsOn: UserPoolClientLambdaPolicy
279 | UserPoolClientInputs:
280 | # Values passed to Userpool client Lambda
281 | # Depends on UserPool for Id
282 | # Depends on UserPoolClient for Id
283 | # Marked as depending on UserPoolClientLambdaPolicy for easier to understand CFN sequencing
284 | Type: 'Custom::LambdaCallout'
285 | Properties:
286 | ServiceToken: !GetAtt UserPoolClientLambda.Arn
287 | clientId: !Ref UserPoolClient
288 | userpoolId: !Ref UserPool
289 | DependsOn: UserPoolClientLogPolicy
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 | # BEGIN IDENTITY POOL RESOURCES
298 |
299 |
300 | IdentityPool:
301 | # Always created
302 | Type: AWS::Cognito::IdentityPool
303 | Properties:
304 | IdentityPoolName: !If [ShouldNotCreateEnvResources, 'publicvueauthcomp6994b8e7_identitypool_6994b8e7', !Join ['',['publicvueauthcomp6994b8e7_identitypool_6994b8e7', '__', !Ref env]]]
305 |
306 | CognitoIdentityProviders:
307 | - ClientId: !Ref UserPoolClient
308 | ProviderName: !Sub
309 | - cognito-idp.${region}.amazonaws.com/${client}
310 | - { region: !Ref "AWS::Region", client: !Ref UserPool}
311 | - ClientId: !Ref UserPoolClientWeb
312 | ProviderName: !Sub
313 | - cognito-idp.${region}.amazonaws.com/${client}
314 | - { region: !Ref "AWS::Region", client: !Ref UserPool}
315 |
316 | AllowUnauthenticatedIdentities: !Ref allowUnauthenticatedIdentities
317 |
318 |
319 | DependsOn: UserPoolClientInputs
320 |
321 |
322 | IdentityPoolRoleMap:
323 | # Created to map Auth and Unauth roles to the identity pool
324 | # Depends on Identity Pool for ID ref
325 | Type: AWS::Cognito::IdentityPoolRoleAttachment
326 | Properties:
327 | IdentityPoolId: !Ref IdentityPool
328 | Roles:
329 | unauthenticated: !Ref unauthRoleArn
330 | authenticated: !Ref authRoleArn
331 | DependsOn: IdentityPool
332 |
333 |
334 | Outputs :
335 |
336 | IdentityPoolId:
337 | Value: !Ref 'IdentityPool'
338 | Description: Id for the identity pool
339 | IdentityPoolName:
340 | Value: !GetAtt IdentityPool.Name
341 |
342 |
343 |
344 |
345 | UserPoolId:
346 | Value: !Ref 'UserPool'
347 | Description: Id for the user pool
348 | UserPoolName:
349 | Value: !Ref userPoolName
350 | AppClientIDWeb:
351 | Value: !Ref 'UserPoolClientWeb'
352 | Description: The user pool app client id for web
353 | AppClientID:
354 | Value: !Ref 'UserPoolClient'
355 | Description: The user pool app client id
356 | AppClientSecret:
357 | Value: !GetAtt UserPoolClientInputs.appSecret
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
--------------------------------------------------------------------------------
/samples/react/geo/display-map/amplify/backend/auth/displaymap5fde5e85/displaymap5fde5e85-cloudformation-template.yml:
--------------------------------------------------------------------------------
1 |
2 | AWSTemplateFormatVersion: 2010-09-09
3 |
4 | Parameters:
5 | env:
6 | Type: String
7 | authRoleArn:
8 | Type: String
9 | unauthRoleArn:
10 | Type: String
11 |
12 |
13 |
14 |
15 | identityPoolName:
16 | Type: String
17 |
18 |
19 |
20 | allowUnauthenticatedIdentities:
21 | Type: String
22 |
23 | resourceNameTruncated:
24 | Type: String
25 |
26 |
27 | userPoolName:
28 | Type: String
29 |
30 |
31 |
32 | autoVerifiedAttributes:
33 | Type: CommaDelimitedList
34 |
35 | mfaConfiguration:
36 | Type: String
37 |
38 |
39 |
40 | mfaTypes:
41 | Type: CommaDelimitedList
42 |
43 | smsAuthenticationMessage:
44 | Type: String
45 |
46 |
47 | smsVerificationMessage:
48 | Type: String
49 |
50 |
51 | emailVerificationSubject:
52 | Type: String
53 |
54 |
55 | emailVerificationMessage:
56 | Type: String
57 |
58 |
59 |
60 | defaultPasswordPolicy:
61 | Type: String
62 |
63 |
64 | passwordPolicyMinLength:
65 | Type: Number
66 |
67 |
68 | passwordPolicyCharacters:
69 | Type: CommaDelimitedList
70 |
71 |
72 | requiredAttributes:
73 | Type: CommaDelimitedList
74 |
75 |
76 | aliasAttributes:
77 | Type: CommaDelimitedList
78 |
79 |
80 | userpoolClientGenerateSecret:
81 | Type: String
82 |
83 |
84 | userpoolClientRefreshTokenValidity:
85 | Type: Number
86 |
87 |
88 | userpoolClientWriteAttributes:
89 | Type: CommaDelimitedList
90 |
91 |
92 | userpoolClientReadAttributes:
93 | Type: CommaDelimitedList
94 |
95 | userpoolClientLambdaRole:
96 | Type: String
97 |
98 |
99 |
100 | userpoolClientSetAttributes:
101 | Type: String
102 |
103 | sharedId:
104 | Type: String
105 |
106 |
107 | resourceName:
108 | Type: String
109 |
110 |
111 | authSelections:
112 | Type: String
113 |
114 |
115 |
116 |
117 | useDefault:
118 | Type: String
119 |
120 |
121 |
122 | userPoolGroupList:
123 | Type: CommaDelimitedList
124 |
125 | serviceName:
126 | Type: String
127 |
128 |
129 |
130 | usernameCaseSensitive:
131 | Type: String
132 |
133 |
134 | dependsOn:
135 | Type: CommaDelimitedList
136 |
137 | Conditions:
138 | ShouldNotCreateEnvResources: !Equals [ !Ref env, NONE ]
139 |
140 | ShouldOutputAppClientSecrets: !Equals [!Ref userpoolClientGenerateSecret, true ]
141 |
142 |
143 | Resources:
144 |
145 |
146 | # BEGIN SNS ROLE RESOURCE
147 | SNSRole:
148 | # Created to allow the UserPool SMS Config to publish via the Simple Notification Service during MFA Process
149 | Type: AWS::IAM::Role
150 | Properties:
151 | RoleName: !If [ShouldNotCreateEnvResources, 'displa5fde5e85_sns-role', !Join ['',[ 'sns', '5fde5e85', !Select [3, !Split ['-', !Ref 'AWS::StackName']], '-', !Ref env]]]
152 | AssumeRolePolicyDocument:
153 | Version: "2012-10-17"
154 | Statement:
155 | - Sid: ""
156 | Effect: "Allow"
157 | Principal:
158 | Service: "cognito-idp.amazonaws.com"
159 | Action:
160 | - "sts:AssumeRole"
161 | Condition:
162 | StringEquals:
163 | sts:ExternalId: displa5fde5e85_role_external_id
164 | Policies:
165 | -
166 | PolicyName: displa5fde5e85-sns-policy
167 | PolicyDocument:
168 | Version: "2012-10-17"
169 | Statement:
170 | -
171 | Effect: "Allow"
172 | Action:
173 | - "sns:Publish"
174 | Resource: "*"
175 | # BEGIN USER POOL RESOURCES
176 | UserPool:
177 | # Created upon user selection
178 | # Depends on SNS Role for Arn if MFA is enabled
179 | Type: AWS::Cognito::UserPool
180 | UpdateReplacePolicy: Retain
181 | Properties:
182 | UserPoolName: !If [ShouldNotCreateEnvResources, !Ref userPoolName, !Join ['',[!Ref userPoolName, '-', !Ref env]]]
183 |
184 |
185 | UsernameConfiguration:
186 | CaseSensitive: false
187 |
188 | Schema:
189 |
190 | -
191 | Name: email
192 | Required: true
193 | Mutable: true
194 |
195 |
196 |
197 |
198 | AutoVerifiedAttributes:
199 |
200 | - email
201 |
202 |
203 |
204 | EmailVerificationMessage: !Ref emailVerificationMessage
205 | EmailVerificationSubject: !Ref emailVerificationSubject
206 |
207 | Policies:
208 | PasswordPolicy:
209 | MinimumLength: !Ref passwordPolicyMinLength
210 | RequireLowercase: false
211 | RequireNumbers: false
212 | RequireSymbols: false
213 | RequireUppercase: false
214 |
215 |
216 | AliasAttributes: !Ref aliasAttributes
217 |
218 | MfaConfiguration: !Ref mfaConfiguration
219 | SmsVerificationMessage: !Ref smsVerificationMessage
220 | SmsAuthenticationMessage: !Ref smsAuthenticationMessage
221 | SmsConfiguration:
222 | SnsCallerArn: !GetAtt SNSRole.Arn
223 | ExternalId: displa5fde5e85_role_external_id
224 |
225 |
226 | UserPoolClientWeb:
227 | # Created provide application access to user pool
228 | # Depends on UserPool for ID reference
229 | Type: "AWS::Cognito::UserPoolClient"
230 | Properties:
231 | ClientName: displa5fde5e85_app_clientWeb
232 |
233 | RefreshTokenValidity: !Ref userpoolClientRefreshTokenValidity
234 | UserPoolId: !Ref UserPool
235 | DependsOn: UserPool
236 | UserPoolClient:
237 | # Created provide application access to user pool
238 | # Depends on UserPool for ID reference
239 | Type: "AWS::Cognito::UserPoolClient"
240 | Properties:
241 | ClientName: displa5fde5e85_app_client
242 |
243 | GenerateSecret: !Ref userpoolClientGenerateSecret
244 | RefreshTokenValidity: !Ref userpoolClientRefreshTokenValidity
245 | UserPoolId: !Ref UserPool
246 | DependsOn: UserPool
247 | # BEGIN USER POOL LAMBDA RESOURCES
248 | UserPoolClientRole:
249 | # Created to execute Lambda which gets userpool app client config values
250 | Type: 'AWS::IAM::Role'
251 | Properties:
252 | RoleName: !If [ShouldNotCreateEnvResources, !Ref userpoolClientLambdaRole, !Join ['',['upClientLambdaRole', '5fde5e85', !Select [3, !Split ['-', !Ref 'AWS::StackName']], '-', !Ref env]]]
253 | AssumeRolePolicyDocument:
254 | Version: '2012-10-17'
255 | Statement:
256 | - Effect: Allow
257 | Principal:
258 | Service:
259 | - lambda.amazonaws.com
260 | Action:
261 | - 'sts:AssumeRole'
262 | DependsOn: UserPoolClient
263 | UserPoolClientLambda:
264 | # Lambda which gets userpool app client config values
265 | # Depends on UserPool for id
266 | # Depends on UserPoolClientRole for role ARN
267 | Type: 'AWS::Lambda::Function'
268 | Properties:
269 | Code:
270 | ZipFile: !Join
271 | - |+
272 | - - 'const response = require(''cfn-response'');'
273 | - 'const aws = require(''aws-sdk'');'
274 | - 'const identity = new aws.CognitoIdentityServiceProvider();'
275 | - 'exports.handler = (event, context, callback) => {'
276 | - ' if (event.RequestType == ''Delete'') { '
277 | - ' response.send(event, context, response.SUCCESS, {})'
278 | - ' }'
279 | - ' if (event.RequestType == ''Update'' || event.RequestType == ''Create'') {'
280 | - ' const params = {'
281 | - ' ClientId: event.ResourceProperties.clientId,'
282 | - ' UserPoolId: event.ResourceProperties.userpoolId'
283 | - ' };'
284 | - ' identity.describeUserPoolClient(params).promise()'
285 | - ' .then((res) => {'
286 | - ' response.send(event, context, response.SUCCESS, {''appSecret'': res.UserPoolClient.ClientSecret});'
287 | - ' })'
288 | - ' .catch((err) => {'
289 | - ' response.send(event, context, response.FAILED, {err});'
290 | - ' });'
291 | - ' }'
292 | - '};'
293 | Handler: index.handler
294 | Runtime: nodejs12.x
295 | Timeout: 300
296 | Role: !GetAtt
297 | - UserPoolClientRole
298 | - Arn
299 | DependsOn: UserPoolClientRole
300 | UserPoolClientLambdaPolicy:
301 | # Sets userpool policy for the role that executes the Userpool Client Lambda
302 | # Depends on UserPool for Arn
303 | # Marked as depending on UserPoolClientRole for easier to understand CFN sequencing
304 | Type: 'AWS::IAM::Policy'
305 | Properties:
306 | PolicyName: displa5fde5e85_userpoolclient_lambda_iam_policy
307 | Roles:
308 | - !Ref UserPoolClientRole
309 | PolicyDocument:
310 | Version: '2012-10-17'
311 | Statement:
312 | - Effect: Allow
313 | Action:
314 | - 'cognito-idp:DescribeUserPoolClient'
315 | Resource: !GetAtt UserPool.Arn
316 | DependsOn: UserPoolClientLambda
317 | UserPoolClientLogPolicy:
318 | # Sets log policy for the role that executes the Userpool Client Lambda
319 | # Depends on UserPool for Arn
320 | # Marked as depending on UserPoolClientLambdaPolicy for easier to understand CFN sequencing
321 | Type: 'AWS::IAM::Policy'
322 | Properties:
323 | PolicyName: displa5fde5e85_userpoolclient_lambda_log_policy
324 | Roles:
325 | - !Ref UserPoolClientRole
326 | PolicyDocument:
327 | Version: 2012-10-17
328 | Statement:
329 | - Effect: Allow
330 | Action:
331 | - 'logs:CreateLogGroup'
332 | - 'logs:CreateLogStream'
333 | - 'logs:PutLogEvents'
334 | Resource: !Sub
335 | - arn:aws:logs:${region}:${account}:log-group:/aws/lambda/${lambda}:log-stream:*
336 | - { region: !Ref "AWS::Region", account: !Ref "AWS::AccountId", lambda: !Ref UserPoolClientLambda}
337 | DependsOn: UserPoolClientLambdaPolicy
338 | UserPoolClientInputs:
339 | # Values passed to Userpool client Lambda
340 | # Depends on UserPool for Id
341 | # Depends on UserPoolClient for Id
342 | # Marked as depending on UserPoolClientLambdaPolicy for easier to understand CFN sequencing
343 | Type: 'Custom::LambdaCallout'
344 | Properties:
345 | ServiceToken: !GetAtt UserPoolClientLambda.Arn
346 | clientId: !Ref UserPoolClient
347 | userpoolId: !Ref UserPool
348 | DependsOn: UserPoolClientLogPolicy
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 | # BEGIN IDENTITY POOL RESOURCES
357 |
358 |
359 | IdentityPool:
360 | # Always created
361 | Type: AWS::Cognito::IdentityPool
362 | Properties:
363 | IdentityPoolName: !If [ShouldNotCreateEnvResources, 'displaymap5fde5e85_identitypool_5fde5e85', !Join ['',['displaymap5fde5e85_identitypool_5fde5e85', '__', !Ref env]]]
364 |
365 | CognitoIdentityProviders:
366 | - ClientId: !Ref UserPoolClient
367 | ProviderName: !Sub
368 | - cognito-idp.${region}.amazonaws.com/${client}
369 | - { region: !Ref "AWS::Region", client: !Ref UserPool}
370 | - ClientId: !Ref UserPoolClientWeb
371 | ProviderName: !Sub
372 | - cognito-idp.${region}.amazonaws.com/${client}
373 | - { region: !Ref "AWS::Region", client: !Ref UserPool}
374 |
375 | AllowUnauthenticatedIdentities: !Ref allowUnauthenticatedIdentities
376 |
377 |
378 | DependsOn: UserPoolClientInputs
379 |
380 |
381 | IdentityPoolRoleMap:
382 | # Created to map Auth and Unauth roles to the identity pool
383 | # Depends on Identity Pool for ID ref
384 | Type: AWS::Cognito::IdentityPoolRoleAttachment
385 | Properties:
386 | IdentityPoolId: !Ref IdentityPool
387 | Roles:
388 | unauthenticated: !Ref unauthRoleArn
389 | authenticated: !Ref authRoleArn
390 | DependsOn: IdentityPool
391 |
392 |
393 | Outputs :
394 |
395 | IdentityPoolId:
396 | Value: !Ref 'IdentityPool'
397 | Description: Id for the identity pool
398 | IdentityPoolName:
399 | Value: !GetAtt IdentityPool.Name
400 |
401 |
402 |
403 |
404 | UserPoolId:
405 | Value: !Ref 'UserPool'
406 | Description: Id for the user pool
407 | UserPoolArn:
408 | Value: !GetAtt UserPool.Arn
409 | Description: Arn for the user pool
410 | UserPoolName:
411 | Value: !Ref userPoolName
412 | AppClientIDWeb:
413 | Value: !Ref 'UserPoolClientWeb'
414 | Description: The user pool app client id for web
415 | AppClientID:
416 | Value: !Ref 'UserPoolClient'
417 | Description: The user pool app client id
418 | AppClientSecret:
419 | Value: !GetAtt UserPoolClientInputs.appSecret
420 | Condition: ShouldOutputAppClientSecrets
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 |
--------------------------------------------------------------------------------
/samples/angular/auth/authenticator/src/app/app.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
301 |
302 |
303 |
304 |
305 |
306 |