Giter VIP home page Giter VIP logo

nancy.authentication.forms.owin's Introduction

An example OWIN middleware that deciphers a Nancy forms auth cookie and puts a ClaimsPrincipal in the OWIN environment. This allows you authenticate a user with Nancy's Forms Authentication, and be able to identify that user in other middleware or frameworks, such as signalr.

Parts of note:

  1. The Startup class where we externally configure Nancy's Forms Auth crypto. We need this configuration in Nancy to encrypt the cookies and in our middleware to decypt it. Read more on Nancy's crypto.
  2. I use ClaimsPrincipal in the middleware and share that with the other owin middleware via "server.User" key. This is in line with other OWIN security middleware and povides compatiblity with frameworks that are aware of this.
  3. You need to provide an implementation of IClaimsPrincipalLookup to convert the Nancy guid user id stored in the nancy auth cookie to a ClaimsPrincipal to be stored in the owin environment dictionary.
  4. While you can still use Nancy's Context.CurrentUser within your Nancy app, there is an extension method to get the ClaimsPrincipal : Context.GetClaimsPrincipal()

Suggestions, feedback, pull requests welcome.

For now, you'll have to copy/paste the projects / code. If there is enough interest, then I'll create a NuGet package.

@randompunter

nancy.authentication.forms.owin's People

Contributors

damianh avatar

Watchers

 avatar  avatar

Forkers

savetrees

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.