|
2 | 2 |
|
3 | 3 | ### Prerequisites
|
4 | 4 | - AWS CLI
|
| 5 | +- Version used: `amplify -v` => `8.0.1` |
5 | 6 |
|
6 | 7 | ### Set-up
|
7 | 8 |
|
8 |
| -1. create a `schema.graphql` file with the content of `MultiAuth/schema.graphql` |
| 9 | +1. `amplify init` |
9 | 10 |
|
10 |
| -2. `amplify init` |
| 11 | +2. `amplify add api` |
11 | 12 |
|
12 |
| -3. `amplify add api` (when asked, provide **"datastoreintegtestmu"** as API name) |
13 | 13 | ```
|
14 |
| -? Please select from one of the below mentioned services: `GraphQL` |
15 |
| -? Provide API name: `datastoreintegtestmu` |
| 14 | +? Select from one of the below mentioned services: `GraphQL` |
| 15 | +? Provide API name: <provide any name> |
16 | 16 | ? Choose the default authorization type for the API: `API key`
|
17 | 17 | ? Enter a description for the API key:
|
18 | 18 | ? After how many days from now the API key should expire (1-365): `365`
|
19 |
| -? Do you want to configure advanced settings for the GraphQL API `Yes, I want to make some additional changes.` |
| 19 | +
|
20 | 20 | ? Configure additional auth types? `Yes`
|
21 | 21 | ? Choose the additional authorization types you want to configure for the API: `Amazon Cognito User Pool`, `IAM`
|
| 22 | +? Do you want to use the default authentication and security configuration? `Manual configuration` |
| 23 | +? Select the authentication/authorization services that you want to use: `User Sign-Up, Sign-In, connected with AWS IAM controls (Enables per-user Storage features for images or ot |
| 24 | +her content, Analytics, and more)` |
| 25 | +? Provide a friendly name for your resource that will be used to label this category in the project: <provide name> |
| 26 | +? Enter a name for your identity pool. <provide name> |
| 27 | +? Allow unauthenticated logins? (Provides scoped down permissions that you can control via AWS IAM) `Yes` |
| 28 | +? Do you want to enable 3rd party authentication providers in your identity pool? `No` |
| 29 | +? Provide a name for your user pool: <provide name> |
| 30 | + |
| 31 | +? How do you want users to be able to sign in? `Username` |
| 32 | +? Do you want to add User Pool Groups? `No` |
| 33 | +? Do you want to add an admin queries API? `No` |
| 34 | +? Multifactor authentication (MFA) user login options: `OFF` |
| 35 | +? Email based user registration/forgot password: `Enabled (Requires per-user email entry at registration)` |
| 36 | +? Specify an email verification subject: `Your verification code` |
| 37 | +? Specify an email verification message: `Your verification code is {####}` |
| 38 | +? Do you want to override the default password policy for this User Pool? `No` |
| 39 | + |
| 40 | +? What attributes are required for signing up? `Email` |
| 41 | +? Specify the app's refresh token expiration period (in days): `30` |
| 42 | +? Do you want to specify the user attributes this app can read and write? `No` |
| 43 | +? Do you want to enable any of the following capabilities? None |
| 44 | +? Do you want to use an OAuth flow? `No` |
| 45 | +? Do you want to configure Lambda Triggers for Cognito? `No` |
| 46 | +
|
| 47 | +
|
| 48 | +
|
22 | 49 | ? Enable conflict detection? `Yes`
|
23 | 50 | ? Select the default resolution strategy Auto Merge
|
24 |
| -? Do you have an annotated GraphQL schema? `Yes` |
25 |
| -? Provide your schema file path: `schema.graphql` |
| 51 | +? Choose a schema template: Blank Schema |
| 52 | +? Do you want to edit the schema now? (Y/n) 'Y' |
| 53 | +
|
| 54 | +Copy the contents from `MultiAuth/schema.graphql` |
| 55 | +
|
26 | 56 | ```
|
27 |
| -4. `amplify push` |
| 57 | + |
| 58 | +3. `amplify push` |
| 59 | + |
28 | 60 | ```perl
|
29 | 61 | ? Are you sure you want to continue? `Yes`
|
30 | 62 | ? Do you want to generate code for your newly created GraphQL API `No`
|
31 | 63 | ```
|
32 | 64 |
|
33 |
| -5. Copy `amplifyconfiguration.json` to a new file named `AWSDataStoreCategoryPluginMultiAuthIntegrationTests-amplifyconfiguration.json` inside `~/.aws-amplify/amplify-ios/testconfiguration/` |
34 |
| -6. Create `AWSDataStoreCategoryPluginMultiAuthIntegrationTests-credentials.json` inside the same folder with the following value |
| 65 | +4. Copy `amplifyconfiguration.json` to a new file named `AWSDataStoreCategoryPluginMultiAuthIntegrationTests-amplifyconfiguration.json` inside `~/.aws-amplify/amplify-ios/testconfiguration/` |
| 66 | + |
| 67 | +```perl |
| 68 | +cp amplifyconfiguration.json ~/.aws-amplify/amplify-ios/testconfiguration/AWSDataStoreCategoryPluginMultiAuthIntegrationTests-amplifyconfiguration.json |
| 69 | +``` |
| 70 | +
|
| 71 | +5. Create `AWSDataStoreCategoryPluginMultiAuthIntegrationTests-credentials.json` inside the same folder with the following value |
| 72 | +
|
35 | 73 | ```json
|
36 | 74 | {
|
37 | 75 | "user1": "<USER1_EMAIL>",
|
|
41 | 79 | }
|
42 | 80 |
|
43 | 81 | ```
|
44 |
| -7. Replace `USER1_EMAIL`, `PASSWORD_1`, `USER2_EMAIL`, `PASSWORD_2` with values for test users |
45 |
| -8. Run the following commands to create the above users and set their passwords |
| 82 | +6. Replace `USER1_EMAIL`, `PASSWORD_1`, `USER2_EMAIL`, `PASSWORD_2` with values for test users |
| 83 | +
|
| 84 | +7. Run the following commands to create the above users and set their passwords |
46 | 85 |
|
47 | 86 | `aws cognito-idp admin-create-user --user-pool-id <USER_POOL_ID> --username USER1_EMAIL`
|
48 | 87 | `aws cognito-idp admin-set-user-password --user-pool-id <USER_POOL_ID> --username USER1_EMAIL --password PASSWORD_1 --permanent`
|
49 | 88 |
|
50 | 89 | `aws cognito-idp admin-create-user --user-pool-id <USER_POOL_ID> --username USER2_EMAIL`
|
51 | 90 | `aws cognito-idp admin-set-user-password --user-pool-id <USER_POOL_ID> --username USER2_EMAIL --password PASSWORD_2 --permanent`
|
52 | 91 |
|
53 |
| -9. Create a `Admins` group in the `<USER_POOL_ID>` user pool |
54 |
| -10. Add `user1` to `Admins` group |
55 |
| -11. Some test cases require IAM to allow guest access. To do so run `amplify update auth` and follow the instructions |
56 |
| -``` |
57 |
| -What do you want to do? `Walkthrough all the auth configurations` |
58 |
| -Select the authentication/authorization services that you want to use: `User Sign-Up, Sign-In, connected with AWS IAM controls (Enables per-user Storage features for images or other content, Analytics, a |
59 |
| -nd more)` |
60 |
| -Allow unauthenticated logins? (Provides scoped down permissions that you can control via AWS IAM) `Yes` |
61 |
| -Do you want to enable 3rd party authentication providers in your identity pool? `No` |
62 |
| -Do you want to add User Pool Groups? `No` |
63 |
| -Do you want to add an admin queries API? `No` |
64 |
| -Multifactor authentication (MFA) user login options: `OFF` |
65 |
| -Email based user registration/forgot password: `Enabled (Requires per-user email entry at registration)` |
66 |
| -Please specify an email verification subject: `Your verification code` |
67 |
| -Please specify an email verification message: `Your verification code is {####}` |
68 |
| -Do you want to override the default password policy for this User Pool? `No` |
69 |
| -Specify the app's refresh token expiration period (in days): `30` |
70 |
| -Do you want to specify the user attributes this app can read and write? `No` |
71 |
| -Do you want to enable any of the following capabilities? |
72 |
| -Do you want to use an OAuth flow? `No` |
73 |
| -? Do you want to configure Lambda Triggers for Cognito? `No` |
74 |
| -``` |
75 |
| -Then `amplify push` |
| 92 | +8. Create a `Admins` group in the `<USER_POOL_ID>` user pool |
76 | 93 |
|
| 94 | +9. Add `user1` to `Admins` group |
0 commit comments