Giter Site home page Giter Site logo

aws-samples / aws-cognito-quicksight-auth Goto Github PK

View Code? Open in Web Editor NEW
77.0 32.0 39.0 1.77 MB

A simple JavaScript frontend and SAM template to spin up a serverless backend, federating Cognito User Pools users to QuickSight.

License: Apache License 2.0

JavaScript 98.66% HTML 1.34%

aws-cognito-quicksight-auth's Introduction

aws-cognito-quicksight-auth

A simple JavaScript frontend and SAM template to spin up a serverless backend, federating Cognito User Pools users to QuickSight.

Required Tools

Instructions

Get started by cloning the repository then editing some files described with more detail in steps 3-5:

  1. Using the AWS CLI, create an S3 bucket in the same region where you want all resources to be deployed:
aws s3 mb s3://<bucket-name> --region <AWS Region>
  1. Package the template with the following command and execute the resulting 'aws cloudformation deploy' output using the AWS CLI, referring to the S3 bucket created earlier:
aws cloudformation package --template-file quicksight.yaml --output-template-file quicksight-output.yaml --s3-bucket <S3 Bucket> 

The next command should be something similar to:

aws cloudformation deploy --template-file /Users/<full path>/quicksight-output.yaml --stack-name CognitoQuickSight --capabilities CAPABILITY_IAM

CloudFormation will automatically create and configure the following resources in your account:

  • CloudFront distribution
  • S3 static website
  • Cognito User Pools
  • Cognito Identity Pools
  • IAM Role for Authenticated Users
  • API Gateway API
  • Lambda Function

You can follow the progress of the stack creation from the AWS Console in CloudFormation. When the status of the “CognitoQuickSight” stack is CREATE_COMPLETE, execute the following command with the AWS CLI:

aws cloudformation describe-stacks --query 'Stacks[0].[Outputs[].[OutputKey,OutputValue]]|[]' --output text --stack-name CognitoQuickSight
  1. Either refer to the output of the "describe-stacks" command above or go to the CloudFormation console, select the stack created on item 2 and open the OUTPUTS tab. All resources we'll need will be there. Use the information to fill up the details in the file "auth.js" including the region.

  2. In the AWS Console, go to the Cognito User Pools section and select the pool named QuickSightUsers generated by CloudFormation. Under APP INTEGRATION -> DOMAIN NAME, create a Domain (be mindful domain names are unique to the region) and add the domain to the “auth.js” file accordingly.

  3. Under APP INTEGRATION -> APP CLIENT SETTINGS select the option COGNITO USER POOL. Add the CloudFront distribution address (with https://, as SSL is a requirement for the callback/sign out URLs) and make sure that the address matches the related settings in the “auth.js” file exactly. For ALLOWED OAUTH FLOWS, select IMPLICIT GRANT. For ALLOWED OAUTH SCOPES, select OPENID.

  4. Upload the four JS and HTML files from the root folder to the S3 bucket named “cognitoquicksight-s3website-xxxxxxxxx”. Make sure that all files are publicly readable.

  5. Access the CloudFront distribution address from a browser to authenticate and access QuickSight

aws-cognito-quicksight-auth's People

Contributors

akobig avatar awsed avatar chriscoombs avatar jpeddicord avatar vsnyc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aws-cognito-quicksight-auth's Issues

Cognito error

Failed to create the changeset: Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state Status: FAILED. Reason: Template format error: Unrecognized resource types: [AWS::Cognito::UserPool, AWS::Cognito::IdentityPoolRoleAttachment, AWS::Cognito::UserPoolClient, AWS::Cognito::IdentityPool]

IAM Role use

Hi - not an issue maybe but guidance, please. All works fine but I am using groups created in the User Pool in the claim of the Identify Pool Authentication provider (new role with rules). The default as provided in the stack works fine, but I'm battling to get a member of a group to login to Quicksight and see either dashboards specified as a resource or dashboards published to a group which is again specified in the IAM permissions. e.g. of IAM policy:

{
"Version": "2012-10-17",
"Statement": [
{
"Action": "quicksight:CreateReader",
"Effect": "Allow",
"Resource": ""
},
{
"Action": "quicksight:CreateGroupMembership",
"Effect": "Allow",
"Resource": "arn:aws:quicksight::
:group/default/"
}
]
}

I've changed this around a few times to use only the groupmembership action, RegisterUser and specified the dashboard ARN for resource without success. This may be me missing something on IAM knowledge but if it is please let me know!

blog url

The big-data blog post url no longer exists - does it live anywhere else ? Thanks

Can not getUserAttributes and updateUserAttributes

We used these library.

 <script src="aws-cognito-sdk.js"></script>
 <script src="amazon-cognito-auth.min.js"></script>

We got the error below.

Uncaught TypeError: cognitoUser.getUserAttributes is not a function

cognitoUser.getUserAttributes(function(err, result) {
        if (err) {
            alert(err);
            return;
        }
        userData = result;
    });

We followed the document

It seems that current library does not support getUserAttribute. Is there any possible way to get or update userAttribute?

Token expired or invalid signing out

Hi,
I have followed all mentioned steps to integrate AWS cognito to one end point (e.g, "https://google.com")
After finishing configuration part, I was successfully got opened out cloudFrount link for creating account, but I'm getting message like Token expired or invalid signing out! while signing up.

token expired

Please help me to solve this issue.

Not able to use specific user id token

Hi all,

How do I get the specific username of the person who logged in? Currently, it is showing on Quicksight as 'RoleName/CognitoCredentials'. Every cognito user that exist in my user pool can access this unique quicksight user using '/CognitoCredentials'.

For example, let's suppose that my cognito user pool has two users "user1" and "user2" and I want to restrict some dashboards for them. When "user1" or "user2" is logged in, the quicksight user is 'RoleName/CognitoCredentials'. In other words, the same quicksight user is accessed by the two cognito users and it is not possible to restrict dashboards for them.

Actually what I really wanna do is to have one Quicksight user for each Cognito user. It should be something like 'RoleName/UserCredentials' and not be using the cognito user pool credentials.

Is that possible? How can I use the user credentials (id token)?

Please, your prompt reply is highly appreciated.

Regards,
Bruno

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.