Code Monkey home page Code Monkey logo

token_auth_playground's Introduction

Token Authentication Playground

Some small experiments with token-based authentication and JWTs


These are some small experiments with token-based authentication, specifically related to single-page apps.

I will be starting by working through the tutorial at https://auth0.com/blog/2014/01/07/angularjs-authentication-with-cookies-vs-token/


Update

(These notes more for future Dan than the general public, but you can feel free to read them)

I was able to successfully implement token-based auth for api routes. When a user successfully logs in, the server sends back a token which is stored in the browser's session storage. This token can then be sent back via ajax to authenticate further api requests.

From what I understand, storing tokens in the browser's session storage may not be all that secure. This was done only for the purposes of testing, as chrome does weird things with cookies on localhost domains. In production it would probably be better to store tokens in a cookie, as they have some built-in security.

At this point it's unclear to me how to send tokens with client requests that come from <a> tags, as there's no way to manually set the headers. This isn't a huge issue in single-page apps, but adds another layer of complexity if you want to navigate to new pages.

This was tested with postman, logging in via /users/login and posting new messages to /message.

token_auth_playground's People

Contributors

dmtopp avatar

Watchers

James Cloos avatar  avatar

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.