Giter Site home page Giter Site logo

aws-samples / websocket-api-cognito-auth-sample Goto Github PK

View Code? Open in Web Editor NEW
57.0 57.0 7.0 2.35 MB

Sample for how to implement WebSocket API authN/Z using Cognito JWT ID token.

License: MIT No Attribution

TypeScript 93.37% JavaScript 2.49% HTML 2.14% CSS 2.00%
aws cognito websocket

websocket-api-cognito-auth-sample's People

Contributors

amazon-auto avatar dependabot[bot] avatar tmokmss avatar yukinobu-mine 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

websocket-api-cognito-auth-sample's Issues

ID Token in url is not a security best practice

this.client = new w3cwebsocket(`${config.WebSocketEndpoint}?idToken=${jwtToken}`);

It is a not a good practice to put sensitive data such as passwords and tokens in the url.
Reason: Although, communication is encrypted and both query strings and headers are going through inside a TLS communication, it is a standard procedure to log $url at the backend (logging headers are not so common). This way ID Token can be visible in logs and could be disclosed. This increases attack surface. Current best practice is to retrieve short term ticket and use the ticket during the ws connection init (as a query string).

Suggestion: setting global: 'window' instead of {}

I have found this demo you made to be tremendously helpful for my project that combines the AWS backend stack + Phaser front-end. Thank you very much!

I have one suggestion for a small part of your code that might be able to help others in a similar boat as me.

In your vite.config, you defined global: {}.
While this is necessary for AWS Authenticator to work properly and works fine for building this app, I noticed this would cause building my app with Phaser to crash because Phaser.js has, somewhere in its lines, a declaration that involves global.somethingsomething.

I managed to get around this issue by declaring global: 'window' .

It took me a couple of hours of searching the internet to figure this out. I am pretty new to this space, maybe that is why and this is glaringly obvious to the pros out there, but I thought this might save some poor souls who are noobs like me :)

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.