Git Product home page Git Product logo

play-shiro's Introduction

Play Shiro Integration

This is a very simple integration between Apache Shiro, an authorization and authentication platform, and Play 2.3.

WARNING

This is in no way production level code. It is an experimental proof of concept, uploaded only out of idle interest; it may give you a leg up if you're already tasked with integration, but it is not going to help you if you want a turnkey authentication system. If that's what you're looking for, I recommend you use SecureSocial or Play-Authenticate.

In particular, Shiro assumes a stateful session strategy, which goes against Play's stateless application. Internally, Shiro uses a ThreadLocal to reference the session; shiro-web has a way of disabling session creation, but since Play isn't built on the Servlet model, I've created analogues for Play that will never create a session. I tested it using Firefox, Safari and Chrome on my Macbook Pro, and was able to log in with different credentials on each browser, but this is not a guarantee of safety.

Starting

To start the application, check the project out from Github, make sure you have Typesafe activator installed, then type

activator run

And run through the DB evolutions needed. Then go to http://localhost:9000.

How it works

When the Global object is called, it configures Shiro's security manager with security.SampleRealm.

When you hit the page, Play will look for a token called "email" in request.session, and find the email address corresponding to that token. That token is only set if we have successfully logged in.

When you login, User.authenticate will use Shiro's SecurityUtils.currentUser, call login on that, and that will go back to the Realm for digest checking. (Note that we use Jasypt to deal with password complexity.)

When you logout, User.logout will call Shiro to invalidate the current session.

play-shiro's People

Contributors

benmccann avatar kidaa avatar wsargent avatar

Watchers

 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.