Code Monkey home page Code Monkey logo

aspnetselfcreatedtokenauthexample's Introduction

ASP.NET Self-created token authentication example

A simple example of how to protect an ASP.NET 5 / MVC 6 project using simple self-created JWT bearer tokens for local username/password checking. Working against RC1 as of 19/11/2015 - see the beta8 and beta7 branches if you're using older framework versions.

DO NOT USE IN PRODUCTION

This example is to show the principles required to acheive local token authentication, and the following things should be changed before production usage:

  1. The random-generated private keys in Startup.cs should be changed and factored out to some sort of secure storage and shared amongst all app servers serving your site. Using the data protection API to ensure the keys are rotated and secured would be perfect, but I've not worked out how to do that yet (please submit a pull request if you get that working!).
  2. The error handling is very simple - and may leak application info to the end users as it returns the exception message.
  3. The username and password checking using an "if" statement should be replaced with checking against some sort of repository, and identities generated from that.

You can find more information about the principles in my StackOverflow answer here. This strategy is based on this StackOverflow answer to the same question by @mdekrey, updated for the RC1 and rationalised to be a slightly simpler, complete example.

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.