generated from NHSDigital/nhs-notify-repository-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
41 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,4 @@ | ||
# These are the settings for the dev user pool | ||
USER_POOL_ID=eu-west-2_fhHtnXS3G | ||
USER_POOL_CLIENT_ID=<client ID> | ||
HOSTED_LOGIN_DOMAIN=<domain> | ||
USER_POOL_ID=<user pool ID> # Check the README.md | ||
USER_POOL_CLIENT_ID=<client ID> # Check the README.md | ||
USE_LOCAL_AUTH='true' # when true will create a new cognito sandbox | ||
|
||
# These are settings to allow redirects from auth | ||
AWS_APP_ID=<templates AWS app ID> | ||
NOTIFY_SUBDOMAIN=<templates subdomain> | ||
NOTIFY_DOMAIN_NAME=<templates domain name> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,20 @@ | ||
import { DeepPartialAmplifyGeneratedConfigs } from '@aws-amplify/plugin-types'; | ||
import { ClientConfig } from '@aws-amplify/client-config'; | ||
import { defineAuth } from '@aws-amplify/backend'; | ||
|
||
const appId = process.env.AWS_APP_ID; | ||
const subdomain = process.env.NOTIFY_SUBDOMAIN; | ||
const domainName = process.env.NOTIFY_DOMAIN_NAME; | ||
|
||
export const authConfig: DeepPartialAmplifyGeneratedConfigs<ClientConfig> = { | ||
auth: { | ||
aws_region: 'eu-west-2', | ||
user_pool_id: process.env.USER_POOL_ID, | ||
user_pool_client_id: process.env.USER_POOL_CLIENT_ID, | ||
oauth: { | ||
identity_providers: [], | ||
domain: process.env.HOSTED_LOGIN_DOMAIN ?? 'no-domain', | ||
scopes: [ | ||
'openid', | ||
'email', | ||
'profile', | ||
'phone', | ||
'aws.cognito.signin.user.admin', | ||
], | ||
redirect_sign_in_uri: [ | ||
`https://${subdomain}.${appId}.amplifyapp.com/auth/`, | ||
`https://${subdomain}.${domainName}/auth/`, | ||
'http://localhost:3000/auth/', | ||
'http://localhost/auth/', | ||
], | ||
redirect_sign_out_uri: [ | ||
`https://${subdomain}.${appId}.amplifyapp.com/`, | ||
`https://${subdomain}.${domainName}/`, | ||
'http://localhost:3000/templates/create-and-submit', | ||
'http://localhost/templates/create-and-submit', | ||
], | ||
response_type: 'code', | ||
export const remoteAuthConfig: DeepPartialAmplifyGeneratedConfigs<ClientConfig> = | ||
{ | ||
auth: { | ||
aws_region: 'eu-west-2', | ||
user_pool_id: process.env.USER_POOL_ID, | ||
user_pool_client_id: process.env.USER_POOL_CLIENT_ID, | ||
}, | ||
username_attributes: ['email'], | ||
standard_required_attributes: ['email'], | ||
user_verification_types: ['email'], | ||
unauthenticated_identities_enabled: false, | ||
password_policy: { | ||
min_length: 8, | ||
require_lowercase: true, | ||
require_uppercase: true, | ||
require_numbers: true, | ||
require_symbols: true, | ||
}; | ||
|
||
export const sandboxAuthConfig = { | ||
auth: defineAuth({ | ||
loginWith: { | ||
email: true, | ||
}, | ||
}, | ||
}), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
import { defineBackend } from '@aws-amplify/backend'; | ||
import { authConfig } from './auth/resource'; | ||
import { remoteAuthConfig, sandboxAuthConfig } from './auth/resource'; | ||
|
||
const backend = defineBackend({}); | ||
backend.addOutput(authConfig); | ||
let backend; | ||
|
||
if (process.env.USE_LOCAL_AUTH === 'true') { | ||
backend = defineBackend(sandboxAuthConfig); | ||
} else { | ||
backend = defineBackend({}); | ||
backend.addOutput(remoteAuthConfig); | ||
} | ||
|
||
export default backend; |