84 | {
85 | formType === 'signUp' && (
86 |
116 | )
117 | }
118 | {
119 | formType === 'confirmSignUp' && (
120 |
121 |
128 |
131 |
132 | )
133 | }
134 | {
135 | formType === 'signIn' && (
136 |
137 |
144 |
152 |
155 |
toggleFormType('signUp')} className={stateToggleStyle}>
156 | Need an account? Sign up.
157 |
158 |
159 | )
160 | }
161 | {
162 | formType === 'signedIn' && (
163 |
164 |
Hello, {user.username}
165 |
168 |
169 | )
170 | }
171 |
172 | )
173 | }
174 |
175 | const profileContainerStyle = css`
176 | display: flex;
177 | flex-direction: column;
178 | `
179 |
180 | const stateToggleStyle = css`
181 | color: ${primaryColor};
182 | cursor: pointer;
183 | text-align: center;
184 | margin-top: 25px;
185 | &:hover {
186 | opacity: .8;
187 | }
188 | `
189 |
190 | const formContainerStyle = css`
191 | display: flex;
192 | flex-direction: column;
193 | width: 400px;
194 | margin: 0 auto;
195 | margin-top: 100px;
196 | `
197 |
198 | const inputStyle = css`
199 | outline: none;
200 | border: none;
201 | border-bottom: 2px solid ${primaryColor};
202 | margin: 4px 0px 0px;
203 | height: 40px;
204 | font-size: 20px;
205 | `
206 |
207 | const buttonStyle = css`
208 | outline: none;
209 | border: none;
210 | cursor: pointer;
211 | font-size: 18px;
212 | margin-top: 20px;
213 | background-color: ${primaryColor};
214 | color: white;
215 | height: 50px;
216 | text-shadow: 1px 1px 1px 1px rgba(0, 0, 0, .2);
217 | box-shadow: 1px 1px 1px 1px rgba(0, 0, 0, .2);
218 | &:hover {
219 | opacity: .85;
220 | }
221 | `
--------------------------------------------------------------------------------
/amplify/backend/auth/customauthenticationd831e6d5/customauthenticationd831e6d5-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 | sharedId:
78 | Type: String
79 |
80 | resourceName:
81 | Type: String
82 |
83 | authSelections:
84 | Type: String
85 |
86 | useDefault:
87 | Type: String
88 |
89 | userPoolGroupList:
90 | Type: CommaDelimitedList
91 |
92 | dependsOn:
93 | Type: CommaDelimitedList
94 |
95 | Conditions:
96 | ShouldNotCreateEnvResources: !Equals [ !Ref env, NONE ]
97 |
98 | Resources:
99 |
100 |
101 | # BEGIN SNS ROLE RESOURCE
102 | SNSRole:
103 | # Created to allow the UserPool SMS Config to publish via the Simple Notification Service during MFA Process
104 | Type: AWS::IAM::Role
105 | Properties:
106 | RoleName: !If [ShouldNotCreateEnvResources, 'customd831e6d5_sns-role', !Join ['',[ 'sns', 'd831e6d5', !Select [3, !Split ['-', !Ref 'AWS::StackName']], '-', !Ref env]]]
107 | AssumeRolePolicyDocument:
108 | Version: "2012-10-17"
109 | Statement:
110 | - Sid: ""
111 | Effect: "Allow"
112 | Principal:
113 | Service: "cognito-idp.amazonaws.com"
114 | Action:
115 | - "sts:AssumeRole"
116 | Condition:
117 | StringEquals:
118 | sts:ExternalId: customd831e6d5_role_external_id
119 | Policies:
120 | -
121 | PolicyName: customd831e6d5-sns-policy
122 | PolicyDocument:
123 | Version: "2012-10-17"
124 | Statement:
125 | -
126 | Effect: "Allow"
127 | Action:
128 | - "sns:Publish"
129 | Resource: "*"
130 | # BEGIN USER POOL RESOURCES
131 | UserPool:
132 | # Created upon user selection
133 | # Depends on SNS Role for Arn if MFA is enabled
134 | Type: AWS::Cognito::UserPool
135 | UpdateReplacePolicy: Retain
136 | Properties:
137 | UserPoolName: !If [ShouldNotCreateEnvResources, !Ref userPoolName, !Join ['',[!Ref userPoolName, '-', !Ref env]]]
138 |
139 | Schema:
140 |
141 | -
142 | Name: email
143 | Required: true
144 | Mutable: true
145 |
146 |
147 |
148 |
149 | AutoVerifiedAttributes: !Ref autoVerifiedAttributes
150 |
151 |
152 | EmailVerificationMessage: !Ref emailVerificationMessage
153 | EmailVerificationSubject: !Ref emailVerificationSubject
154 |
155 | Policies:
156 | PasswordPolicy:
157 | MinimumLength: !Ref passwordPolicyMinLength
158 | RequireLowercase: false
159 | RequireNumbers: false
160 | RequireSymbols: false
161 | RequireUppercase: false
162 |
163 | MfaConfiguration: !Ref mfaConfiguration
164 | SmsVerificationMessage: !Ref smsVerificationMessage
165 | SmsConfiguration:
166 | SnsCallerArn: !GetAtt SNSRole.Arn
167 | ExternalId: customd831e6d5_role_external_id
168 |
169 |
170 | UserPoolClientWeb:
171 | # Created provide application access to user pool
172 | # Depends on UserPool for ID reference
173 | Type: "AWS::Cognito::UserPoolClient"
174 | Properties:
175 | ClientName: customd831e6d5_app_clientWeb
176 |
177 | RefreshTokenValidity: !Ref userpoolClientRefreshTokenValidity
178 | UserPoolId: !Ref UserPool
179 | DependsOn: UserPool
180 | UserPoolClient:
181 | # Created provide application access to user pool
182 | # Depends on UserPool for ID reference
183 | Type: "AWS::Cognito::UserPoolClient"
184 | Properties:
185 | ClientName: customd831e6d5_app_client
186 |
187 | GenerateSecret: !Ref userpoolClientGenerateSecret
188 | RefreshTokenValidity: !Ref userpoolClientRefreshTokenValidity
189 | UserPoolId: !Ref UserPool
190 | DependsOn: UserPool
191 | # BEGIN USER POOL LAMBDA RESOURCES
192 | UserPoolClientRole:
193 | # Created to execute Lambda which gets userpool app client config values
194 | Type: 'AWS::IAM::Role'
195 | Properties:
196 | RoleName: !If [ShouldNotCreateEnvResources, !Ref userpoolClientLambdaRole, !Join ['',['upClientLambdaRole', 'd831e6d5', !Select [3, !Split ['-', !Ref 'AWS::StackName']], '-', !Ref env]]]
197 | AssumeRolePolicyDocument:
198 | Version: '2012-10-17'
199 | Statement:
200 | - Effect: Allow
201 | Principal:
202 | Service:
203 | - lambda.amazonaws.com
204 | Action:
205 | - 'sts:AssumeRole'
206 | DependsOn: UserPoolClient
207 | UserPoolClientLambda:
208 | # Lambda which gets userpool app client config values
209 | # Depends on UserPool for id
210 | # Depends on UserPoolClientRole for role ARN
211 | Type: 'AWS::Lambda::Function'
212 | Properties:
213 | Code:
214 | ZipFile: !Join
215 | - |+
216 | - - 'const response = require(''cfn-response'');'
217 | - 'const aws = require(''aws-sdk'');'
218 | - 'const identity = new aws.CognitoIdentityServiceProvider();'
219 | - 'exports.handler = (event, context, callback) => {'
220 | - ' if (event.RequestType == ''Delete'') { '
221 | - ' response.send(event, context, response.SUCCESS, {})'
222 | - ' }'
223 | - ' if (event.RequestType == ''Update'' || event.RequestType == ''Create'') {'
224 | - ' const params = {'
225 | - ' ClientId: event.ResourceProperties.clientId,'
226 | - ' UserPoolId: event.ResourceProperties.userpoolId'
227 | - ' };'
228 | - ' identity.describeUserPoolClient(params).promise()'
229 | - ' .then((res) => {'
230 | - ' response.send(event, context, response.SUCCESS, {''appSecret'': res.UserPoolClient.ClientSecret});'
231 | - ' })'
232 | - ' .catch((err) => {'
233 | - ' response.send(event, context, response.FAILED, {err});'
234 | - ' });'
235 | - ' }'
236 | - '};'
237 | Handler: index.handler
238 | Runtime: nodejs10.x
239 | Timeout: '300'
240 | Role: !GetAtt
241 | - UserPoolClientRole
242 | - Arn
243 | DependsOn: UserPoolClientRole
244 | UserPoolClientLambdaPolicy:
245 | # Sets userpool policy for the role that executes the Userpool Client Lambda
246 | # Depends on UserPool for Arn
247 | # Marked as depending on UserPoolClientRole for easier to understand CFN sequencing
248 | Type: 'AWS::IAM::Policy'
249 | Properties:
250 | PolicyName: customd831e6d5_userpoolclient_lambda_iam_policy
251 | Roles:
252 | - !Ref UserPoolClientRole
253 | PolicyDocument:
254 | Version: '2012-10-17'
255 | Statement:
256 | - Effect: Allow
257 | Action:
258 | - 'cognito-idp:DescribeUserPoolClient'
259 | Resource: !GetAtt UserPool.Arn
260 | DependsOn: UserPoolClientLambda
261 | UserPoolClientLogPolicy:
262 | # Sets log policy for the role that executes the Userpool Client Lambda
263 | # Depends on UserPool for Arn
264 | # Marked as depending on UserPoolClientLambdaPolicy for easier to understand CFN sequencing
265 | Type: 'AWS::IAM::Policy'
266 | Properties:
267 | PolicyName: customd831e6d5_userpoolclient_lambda_log_policy
268 | Roles:
269 | - !Ref UserPoolClientRole
270 | PolicyDocument:
271 | Version: 2012-10-17
272 | Statement:
273 | - Effect: Allow
274 | Action:
275 | - 'logs:CreateLogGroup'
276 | - 'logs:CreateLogStream'
277 | - 'logs:PutLogEvents'
278 | Resource: !Sub
279 | - arn:aws:logs:${region}:${account}:log-group:/aws/lambda/${lambda}:log-stream:*
280 | - { region: !Ref "AWS::Region", account: !Ref "AWS::AccountId", lambda: !Ref UserPoolClientLambda}
281 | DependsOn: UserPoolClientLambdaPolicy
282 | UserPoolClientInputs:
283 | # Values passed to Userpool client Lambda
284 | # Depends on UserPool for Id
285 | # Depends on UserPoolClient for Id
286 | # Marked as depending on UserPoolClientLambdaPolicy for easier to understand CFN sequencing
287 | Type: 'Custom::LambdaCallout'
288 | Properties:
289 | ServiceToken: !GetAtt UserPoolClientLambda.Arn
290 | clientId: !Ref UserPoolClient
291 | userpoolId: !Ref UserPool
292 | DependsOn: UserPoolClientLogPolicy
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 | # BEGIN IDENTITY POOL RESOURCES
301 |
302 |
303 | IdentityPool:
304 | # Always created
305 | Type: AWS::Cognito::IdentityPool
306 | Properties:
307 | IdentityPoolName: !If [ShouldNotCreateEnvResources, 'customauthenticationd831e6d5_identitypool_d831e6d5', !Join ['',['customauthenticationd831e6d5_identitypool_d831e6d5', '__', !Ref env]]]
308 |
309 | CognitoIdentityProviders:
310 | - ClientId: !Ref UserPoolClient
311 | ProviderName: !Sub
312 | - cognito-idp.${region}.amazonaws.com/${client}
313 | - { region: !Ref "AWS::Region", client: !Ref UserPool}
314 | - ClientId: !Ref UserPoolClientWeb
315 | ProviderName: !Sub
316 | - cognito-idp.${region}.amazonaws.com/${client}
317 | - { region: !Ref "AWS::Region", client: !Ref UserPool}
318 |
319 | AllowUnauthenticatedIdentities: !Ref allowUnauthenticatedIdentities
320 |
321 |
322 | DependsOn: UserPoolClientInputs
323 |
324 |
325 | IdentityPoolRoleMap:
326 | # Created to map Auth and Unauth roles to the identity pool
327 | # Depends on Identity Pool for ID ref
328 | Type: AWS::Cognito::IdentityPoolRoleAttachment
329 | Properties:
330 | IdentityPoolId: !Ref IdentityPool
331 | Roles:
332 | unauthenticated: !Ref unauthRoleArn
333 | authenticated: !Ref authRoleArn
334 | DependsOn: IdentityPool
335 |
336 |
337 | Outputs :
338 |
339 | IdentityPoolId:
340 | Value: !Ref 'IdentityPool'
341 | Description: Id for the identity pool
342 | IdentityPoolName:
343 | Value: !GetAtt IdentityPool.Name
344 |
345 |
346 |
347 |
348 | UserPoolId:
349 | Value: !Ref 'UserPool'
350 | Description: Id for the user pool
351 | UserPoolName:
352 | Value: !Ref userPoolName
353 | AppClientIDWeb:
354 | Value: !Ref 'UserPoolClientWeb'
355 | Description: The user pool app client id for web
356 | AppClientID:
357 | Value: !Ref 'UserPoolClient'
358 | Description: The user pool app client id
359 | AppClientSecret:
360 | Value: !GetAtt UserPoolClientInputs.appSecret
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
--------------------------------------------------------------------------------