GithubHelp home page GithubHelp logo

almamedia / il-auth-at-edge Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 241 KB

Modified AWS sample enabling Cognito authentication @ cloudfront edge. Install on any account and link to cloudfront dostribution as needed.

License: Apache License 2.0

Shell 19.94% JavaScript 23.80% HTML 7.92% Python 48.34%

il-auth-at-edge's People

Contributors

mahe-work avatar

Stargazers

 avatar  avatar

Watchers

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

il-auth-at-edge's Issues

Lambda for token capture

Instead (or in addition to) of S3-distributed html page, provide a Lambda function that can be attached to Cloudfront (or later, ALB)

The Lambda function should:

  • Be able to handle both cloudfront's and ALB's requests and responses
  • Deliver to viewer's browser a simple page that parses Cognito's tokens from browser's location bar (they're coded to fragment part of the login return url which is not available server side)
    • The page should redirect to requested website's root OR arbitrary path if it can be somehow provided.

Changes to existing auth lambda function:

  • Somehow find out which redirect url to pass to Cognito (hardcoded to https:///il-auth-at-edge/signin/index.html ATM). This must be URL recognized by Cognito User pool (maybe dig out a list from there and decide based on request hostname?)
  • Somehow pass the original requested URL through Cognito to token capture function for redirect after token capture

Error creating user pool

The last cloudformation template fails with the following error:
UserPoolAndClient CREATE_FAILED Custom Resource failed to stabilize in expected time

Here is the log:

il-auth-at-edge
20 May 2019 14:26:06 CognitoUserPool CREATE_FAILED Embedded stack arn:aws:cloudformation:us-east-1:AWS_ACCOUNTID:stack/il-auth-at-edge-CognitoUserPool-14B6JQSBZT49N/56e94530-7b02-11e9-8f85-0a33c80c982c was not successfully created: The following resource(s) failed to create: [UserPoolAndClient].

il-auth-at-edge-CognitoUserPool-14B6JQSBZT49N
20 May 2019 14:23:31 il-auth-at-edge-CognitoUserPool-14B6JQSBZT49N CREATE_FAILED The following resource(s) failed to create: [UserPoolAndClient].
20 May 2019 14:23:27 UserPoolAndClient CREATE_FAILED Custom Resource failed to stabilize in expected time

Customize Cognito email and SMS

Include a file containing texts for Cognito's emails and SMSs (account verification etc.) in lambda deploy package and read them tehre when creating / updating userpool.

Token refresh

Capture also refresh token in token capture page and store it clientside (localstorage?).

Check access token expiration in auth lambda, redirect to a new page that refreshes tokens an sets new cookies & local storage.

Get Cognito's credentials to Lambda programmatically

Cognito's keys and client id are hardcoded to auth lambda deployment package by extracting the package, modifying the source code and repackaging, which is hideous.

Make Lambda fetch these on startup using AWS SDK. Make sure it has suitable policy to do this.

Make cloudformation stacks updatable

Application's Cloudformation stacks rely heavily on lambda-backed custom resources. These should be fixed to be properly updatable so that:

  • Lambda functions are updated, not recreated when code or resource properties change.
  • Cognito userpool, client and domain are updated, not recreated, when properties are changed

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.