aws-cognito-angular-quickstart | page app utilizing Amazon Cognito , S3 , and DynamoDB | AWS library
kandi X-RAY | aws-cognito-angular-quickstart Summary
kandi X-RAY | aws-cognito-angular-quickstart Summary
An Angular(v5)-based QuickStart single-page app utilizing Amazon Cognito, S3, and DynamoDB (Serverless architecture)
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of aws-cognito-angular-quickstart
aws-cognito-angular-quickstart Key Features
aws-cognito-angular-quickstart Examples and Code Snippets
Community Discussions
Trending Discussions on aws-cognito-angular-quickstart
QUESTION
Recently I was using the Sign-up and Sign-in template similar this one developed by Vladimir Budilov.
But now, I've been modifying my application to use the hosted UI developed by Amazon. So my application redirects to the hosted UI, all the authentication is made there and they send me the authentication token, more os less as explained in this tutorial.
Summarizing, I call the hosted UI and do login: https://my_domain/login?response_type=token&client_id=my_client_id&redirect_uri=https://www.example.com
I'm redirected to: https://www.example.com/#id_token=123456789tokens123456789&expires_in=3600&token_type=Bearer
So, I have now the token_id but I can't get the current user or user parameters from this. Could anyone help me with informations or some directions?
I've tried the methods in Amazon developer guide .
It works well when I was using Vladimir Budilov's template but trying to use the token_id, I'm not succeeding. Thanks in advance for your time and help.
...ANSWER
Answered 2018-May-24 at 02:15The attributes you configure to be added as claims are already available inside the id_token with base64 encoding (Since its a JWT token).
You can decode the token and access these attributes both at Client Side using Javascript and on Server.
For more info refer the StackOverflow question How to decode JWT tokens in JavaScript.
Note: If you need to trust these attributes for a backend operation, make sure you verify the JWT signature before trusting the attributes.
QUESTION
I am building an app using Angular and NodeJS.
I've heard about AWS Cognito and would like to use it in my app. However it is very unclear in the documentation how it is supposed to work.
There is an example on how to use Cognito with an Angular SPA, but there is no word on how I can use it to authenticate users on my backened NodeJS server.
How is NodeJS supposed to know if a user is logged in? I can think of several possible answers, but none appear in the documentation and there is surprisingly no code sample. So I decided to ask here before investing a lot of time in trial and error.
...ANSWER
Answered 2017-Dec-20 at 01:29You can use AWS Cognito Userpools in your backend NodeJS server to authenticate users. The steps are as follows.
- Create a Cognito Userpool and setup an App Client.
- Create a Cognito Userpool ( Optionally Cognito Federated Identities if you want your users to directly allow controlled access to AWS services).
- Configure Cognito Hosted UI ( Built in Signin page and optionally Signup page).
- For User Signin, redirect the User to this Domain URL for Signin.
- Setup an App Client with redirect URLs to your App for Oauth2 flow.
- After user Signin, you will receive an id_token (e.g In implicit grant flow) in URL which you can forward to your NodeJS server where you can validate it using NodeJS middleware.
- You can decide whether to store the id_token in a cookie or in browser storage and implement the storage and validation accordingly for subsequent requests.
Note: Since the id_token is a standard JavaScript Web Token (JWT) you can find a library to validate it. Refer AWS documentation Using Tokens with User Pools for more details.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install aws-cognito-angular-quickstart
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page