Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
a415417
update docs to include switch for CLI and existing resources when add…
cwomack Mar 8, 2023
fdf08a6
fix flutter page with proper "existing resources" code sample
cwomack Mar 8, 2023
2bae1b8
fix to file type and minor visual improvement of code sample
cwomack Mar 8, 2023
1170622
add preamble after "Set Up Backend Resources"
cwomack Mar 8, 2023
8ad0e84
add back in the 'Identify User' title/reference in directory.js (out …
cwomack Mar 8, 2023
4d5789d
Updates to remove config/dependencies within Blockswitcher, additiona…
cwomack Mar 9, 2023
462b3c4
space added for spell check error
cwomack Mar 9, 2023
a7ee8f0
New block add for 3 options (2 CLI and 1 Manual config) for Auth back…
cwomack Mar 14, 2023
b3bf372
Merge branch 'aws-amplify:main' into main
cwomack Mar 14, 2023
4de15d3
Merge branch 'main' of github.com:cwomack/docs
cwomack Mar 14, 2023
1177dca
Further refinement of blocks and verbiage. Add 3rd Manual Config bloc…
cwomack Mar 17, 2023
246b8db
Merge branch 'aws-amplify:main' into main
cwomack Mar 17, 2023
d4cc639
Merge branch 'main' of github.com:cwomack/docs
cwomack Mar 17, 2023
8276a41
fixes to create new fragments for Flutter/iOS/Android pages
cwomack Mar 17, 2023
cec6d79
add change to js preamble
cwomack Mar 17, 2023
5df7194
fixes to links that navigating to wrong platform, general feedback fr…
cwomack Mar 28, 2023
d8a949a
Merge branch 'aws-amplify:main' into main
cwomack Mar 28, 2023
7f77a59
Merge branch 'main' of github.com:cwomack/docs
cwomack Mar 28, 2023
da4809d
Revert callouts
cwomack Mar 28, 2023
417853b
remove a comma that leads to invalid JSON string
cwomack Mar 28, 2023
c188f58
revert "jsx" to "dart" for code block
cwomack Mar 28, 2023
d980f11
fixes to block switcher links, updates to text, fragments for JS and RN
cwomack Mar 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions src/directory/directory.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,6 @@ const directory = {
route: '/lib/auth/getting-started',
filters: ['android', 'flutter', 'ios', 'js', 'react-native']
},
{
title: 'Create or re-use existing backend',
route: '/lib/auth/start',
filters: ['js', 'react-native']
},
{
title: 'Sign up, Sign in & Sign out',
route: '/lib/auth/emailpassword',
Expand Down Expand Up @@ -374,11 +369,6 @@ const directory = {
title: 'Under the hood',
route: '/lib/auth/overview',
filters: ['android', 'ios', 'js', 'react-native']
},
{
title: 'Use existing Amazon Cognito resources',
route: '/lib/auth/existing-resources',
filters: ['android', 'flutter', 'ios']
}
]
},
Expand Down Expand Up @@ -1159,11 +1149,6 @@ const directory = {
title: 'Under the hood',
route: '/lib-v1/auth/overview',
filters: ['android', 'ios']
},
{
title: 'Use existing Amazon Cognito resources',
route: '/lib-v1/auth/existing-resources',
filters: ['android', 'ios']
}
]
},
Expand Down
4 changes: 2 additions & 2 deletions src/fragments/lib-v1/auth/existing-resources.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import nativeCommon0 from "/src/fragments/lib-v1/auth/native_common/existing_res
- **Region**: AWS Region where the resources are provisioned (e.g. `us-east-1`)
- **Auth**:
- **Default**:
- **authenticationFlowType**: The authentication flow type, takes values `USER_SRP_AUTH`, `CUSTOM_AUTH`. Default is `USER_SRP_AUTH`.
- **authenticationFlowType**: The authentication flow type, takes values `USER_SRP_AUTH`, `CUSTOM_AUTH`, and `USER_PASSWORD_AUTH`. Default is `USER_SRP_AUTH`.
- **OAuth**: Hosted UI Configuration (only include this if using the Hosted UI flow)
- **Scopes:** Scopes should match the scopes enables in Cognito under "App client settings"

Note that before you can add an AWS resource to your application, the application must have the Amplify libraries installed. If you need to perform this step, see [Install Amplify Libraries](/lib-v1/project-setup/create-application#n2-install-amplify-libraries).

If you are using a Cognito User Pool, without a Cognito Identity Pool, you can omit the **CredentialsProvider** section in the configuration.
If you are using a Cognito User Pool without a Cognito Identity Pool, you can omit the **CredentialsProvider** section in the configuration.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ If you are not using the Amplify CLI, a Cognito User Pool and Identity Pool can
"profile",
"aws.cognito.signin.user.admin"
]
},
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
The Amplify Auth category provides an interface for authenticating a user. Behind the scenes, it provides the necessary authorization to the other Amplify categories. It comes with default, built-in support for [Amazon Cognito](https://aws.amazon.com/cognito) User Pool and Identity Pool. The Amplify CLI helps you to create and configure the auth category with an authentication provider.
The Amplify Auth category provides an interface for authenticating a user. Behind the scenes, it provides the necessary authorization to the other Amplify categories. It comes with default, built-in support for [Amazon Cognito](https://aws.amazon.com/cognito) User Pool and Identity Pool. The Amplify CLI helps you create and configure the auth category with an authentication provider.

## Goal
To setup and configure your application with Amplify Auth and go through a simple api to check the current auth session

To setup and configure your application with Amplify Auth and go through a simple api to check the current auth session.

## Prerequisites

Expand All @@ -13,47 +14,31 @@ import android1 from "/src/fragments/lib-v1/auth/android/getting_started/10_preR

<Fragments fragments={{android: android1}} />

## Configure Auth Category

To start provisioning auth resources in the backend, go to your project directory and **execute the command**:

```bash
amplify add auth
```
## Install Amplify Libraries

Enter the following when prompted:
```console
? Do you want to use the default authentication and security configuration?
`Default configuration`
? How do you want users to be able to sign in?
`Username`
? Do you want to configure advanced settings?
`No, I am done.`
```
import ios6 from "/src/fragments/lib-v1/auth/ios/getting_started/20_installLib.mdx";

To push your changes to the cloud, **execute the command**:
<Fragments fragments={{ios: ios6}} />

```bash
amplify push
```
import android7 from "/src/fragments/lib-v1/auth/android/getting_started/20_installLib.mdx";

import ios3 from "/src/fragments/lib-v1/auth/ios/getting_started/12_amplifyConfig.mdx";
<Fragments fragments={{android: android7}} />

<Fragments fragments={{ios: ios3}} />
## Set Up Backend Resources

import android4 from "/src/fragments/lib-v1/auth/android/getting_started/12_amplifyConfig.mdx";
To use Authentication with Amplify, you have the option to set up or import existing Amazon Cognito resources via the Amplify CLI or manually configure them in your application.

<Fragments fragments={{android: android4}} />
import ios50 from "/src/fragments/lib/auth/ios/getting_started/50_configureBackend.mdx";

## Install Amplify Libraries
<Fragments fragments={{ios: ios50}} />

import ios6 from "/src/fragments/lib-v1/auth/ios/getting_started/20_installLib.mdx";
import android50 from "/src/fragments/lib/auth/android/getting_started/50_configureBackend.mdx";

<Fragments fragments={{ios: ios6}} />
<Fragments fragments={{android: android50}} />

import android7 from "/src/fragments/lib-v1/auth/android/getting_started/20_installLib.mdx";
import flutter70 from "/src/fragments/lib/auth/flutter/getting_started/70_configureBackend.mdx";

<Fragments fragments={{android: android7}} />
<Fragments fragments={{flutter: flutter70}} />

## Initialize Amplify Auth

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,5 @@ Select a category from the following list to view an example `amplifyconfigurati
* See the [Analytics category](/lib-v1/analytics/existing-resources) to use existing AWS Pinpoint resources.
* See the [API (GraphQL) category](/lib-v1/graphqlapi/existing-resources) to use existing AWS AppSync resources.
* See the [API (REST) category](/lib-v1/restapi/existing-resources) to use existing Amazon API Gateway and AWS Lambda resources.
* See the [Authentication category](/lib-v1/auth/existing-resources) to use existing Amazon Cognito resources.
* See the [Authentication category](/lib-v1/auth/getting-started/q/platform/android/#prerequisites) to use existing Amazon Cognito resources.
* See the [Storage category](/lib-v1/storage/existing-resources) to use existing Amazon S3 resources.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Upon completion, `amplifyconfiguration.json` should be updated to reference provisioned backend auth resources. Note that these files should already be a part of your project if you followed the [Project setup walkthrough](/lib/project-setup/create-application).
Upon completion, `amplifyconfiguration.json` should be updated to reference provisioned backend auth resources. Note that these files should already be a part of your project if you followed the [project setup walkthrough](/lib/project-setup/create-application).
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
<BlockSwitcher>
<Block name="Amplify CLI (Create)">

> Prerequisites: [Install and configure](/lib/project-setup/prereq/q/platform/android/#install-and-configure-the-amplify-cli) the Amplify CLI in addition to the Amplify libraries and [necessary dependencies](/lib/auth/getting-started/q/platform/android/#install-amplify-libraries).

To start provisioning auth resources in the backend, go to your project directory and **execute the command**:

```bash
amplify add auth
```

Enter the following when prompted:
```console
? Do you want to use the default authentication and security configuration?
`Default configuration`
? How do you want users to be able to sign in?
`Username`
? Do you want to configure advanced settings?
`No, I am done.`
```

> If you have previously enabled an Amplify category that uses Auth behind the scenes (e.g. API category), you can run the `amplify update auth` command to edit your configuration if needed.

To push your changes to the cloud, **execute the command**:

```bash
amplify push
```

import android5 from "/src/fragments/lib/auth/android/getting_started/12_amplifyConfig.mdx";

<Fragments fragments={{android: android5}} />

</Block>

<Block name="Amplify CLI (Import)">

> Prerequisites: [Install and configure](/lib/project-setup/prereq/q/platform/android/#install-and-configure-the-amplify-cli) the Amplify CLI in addition to the Amplify libraries and [necessary dependencies](/lib/auth/getting-started/q/platform/android/#install-amplify-libraries).

To import existing Amazon Cognito resources into your Amplify project, **execute the command**:

```bash
amplify import auth
```
```console
? What type of auth resource do you want to import?
Cognito User Pool and Identity Pool
Cognito User Pool only
```

Once you've selected an option, you'll be able to search for and import an existing Cognito User Pool and Identity Pool (or User Pool only) within your AWS account. The `amplify import auth` command will also do the following:
- Automatically populate your Amplify Library configuration file (`amplifyconfiguration.json`) with your chosen Amazon Cognito resource information
- Provide your designated existing Cognito resource as the authentication & authorization mechanism for all auth-dependent categories (API, Storage and more)
- Enable Lambda functions to access the chosen Cognito resource if you permit it

> If you have previously enabled an Amplify category that uses Auth behind the scenes (e.g. API category), you can run the `amplify update auth` command to edit your configuration if needed.

After configuring your Authentication options, update your backend and deploy the service by running the `push` command:

```bash
amplify push
```

Now, the authentication service has been deployed and you can start using it. To view the deployed services in your project at any time, go to Amplify Console by running the following command:

```bash
amplify console
```
For more details, see how to [Use an existing Cognito User Pool and Identity Pool](/cli/auth/import).

</Block>

<Block name="Manual Configuration">

If you are not using the Amplify CLI, existing Authentication resources from AWS (e.g. Amazon Cognito UserPools or Identity Pools) can be used with the Amplify Libraries by [manually creating a configuration file](/lib/project-setup/use-existing-resources/q/platform/android/#add-an-existing-aws-resource-to-an-android-application) (`amplifyconfiguration.json`) and then updating the associated Plugin within it:

```jsx
{
"auth": {
"plugins": {
"awsCognitoAuthPlugin": {
"IdentityManager": {
"Default": {}
},
"CredentialsProvider": {
"CognitoIdentity": {
"Default": {
"PoolId": "[COGNITO IDENTITY POOL ID]",
"Region": "[REGION]"
}
}
},
"CognitoUserPool": {
"Default": {
"PoolId": "[COGNITO USER POOL ID]",
"AppClientId": "[COGNITO USER POOL APP CLIENT ID]",
"Region": "[REGION]"
}
},
"Auth": {
"Default": {
"authenticationFlowType": "USER_SRP_AUTH",
"OAuth": {
"WebDomain": "[YOUR COGNITO DOMAIN ]",
"AppClientId": "[COGNITO USER POOL APP CLIENT ID]",
"SignInRedirectURI": "[CUSTOM REDIRECT SCHEME AFTER SIGN IN, e.g. myapp://]",
"SignOutRedirectURI": "[CUSTOM REDIRECT SCHEME AFTER SIGN OUT, e.g. myapp://]",
"Scopes": [
"phone",
"email",
"openid",
"profile",
"aws.cognito.signin.user.admin"
]
}
}
}
}
}
}
}
```

- **CredentialsProvider**:
- **Cognito Identity**:
- **Default**:
- **PoolID**: ID of the Amazon Cognito Identity Pool (e.g. `us-east-1:123e4567-e89b-12d3-a456-426614174000`)
- **Region**: AWS Region where the resources are provisioned (e.g. `us-east-1`)
- **CognitoUserPool**:
- **Default**:
- **PoolId**: ID of the Amazon Cognito User Pool (e.g. `us-east-1_abcdefghi`)
- **AppClientId**: ID for the client used to authenticate against the user pool
- **Region**: AWS Region where the resources are provisioned (e.g. `us-east-1`)
- **Auth**:
- **Default**:
- **authenticationFlowType**: The authentication flow type, takes values `USER_SRP_AUTH`, `CUSTOM_AUTH`, and `USER_PASSWORD_AUTH`. Default is `USER_SRP_AUTH`.
- **OAuth**: Hosted UI Configuration (only include this if using the Hosted UI flow)
- **Scopes:** Scopes should match the scopes enables in Cognito under "App client settings"

If you are using a Cognito User Pool without a Cognito Identity Pool, you can omit the **CredentialsProvider** section in the configuration.

</Block>
</BlockSwitcher>
4 changes: 2 additions & 2 deletions src/fragments/lib/auth/existing-resources.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ import flutter0 from "/src/fragments/lib/auth/flutter/existing_resources/10_exis
- **Region**: AWS Region where the resources are provisioned (e.g. `us-east-1`)
- **Auth**:
- **Default**:
- **authenticationFlowType**: The authentication flow type, takes values `USER_SRP_AUTH`, `CUSTOM_AUTH`. Default is `USER_SRP_AUTH`.
- **authenticationFlowType**: The authentication flow type, takes values `USER_SRP_AUTH`, `CUSTOM_AUTH`, and `USER_PASSWORD_AUTH`. Default is `USER_SRP_AUTH`.
- **OAuth**: Hosted UI Configuration (only include this if using the Hosted UI flow)
- **Scopes:** Scopes should match the scopes enables in Cognito under "App client settings"

Note that before you can add an AWS resource to your application, the application must have the Amplify libraries installed. If you need to perform this step, see [Install Amplify Libraries](/lib/project-setup/create-application#n2-install-amplify-libraries).

If you are using a Cognito User Pool, without a Cognito Identity Pool, you can omit the **CredentialsProvider** section in the configuration.
If you are using a Cognito User Pool without a Cognito Identity Pool, you can omit the **CredentialsProvider** section in the configuration.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const amplifyconfig = ''' {
"profile",
"aws.cognito.signin.user.admin"
]
},
}
}
}
}
Expand Down
Loading