Deadbolt 2
With Membership
Suggested price

Deadbolt 2

Powerful authorization for your Play 2 application

About the Book

Deadbolt 2 is an authorization module for the Play 2 framework.  It features idiomatic Java and Scala APIs and a comprehensive range of tools to help secure your web application.

This book, written by the author of the module, covers all aspects of integrating Deadbolt 2 into your code.

About the Author

Steve Chaloner
Steve Chaloner

Steve Chaloner has been a software developer, consultant and mentor since 1999. He specialises in Java and Scala, but believes in using the right tool for the job. The right tool for him, for web-based applications, is the Play framework.

He is the author of several open-source projects, the most successful of which is Deadbolt, an authorization system for Play.

In 2011, he was selected as one of the Expert Reviewers for the Play! Framework Cookbook, along with the creator of Play and one of its oldest contributors. Since then, he has been an expert reviewer for four other books on Play, covering Java, Scala and reactive programming.

In 2012, Steve co-founded the Belgian Play Framework User Group with Ben Verbeken. This later merged with BeScala, the Belgian Scala User Group.

Steve blogs at and tweets at

About the Contributors

Daryl Greensill
Daryl Greensill
Francis De Brabandere
Francis De Brabandere
Peter Hilton
Peter Hilton

Table of Contents

    • 1. Deadbolt 2
      • 1.1 About the author
      • 1.2 About the book
    • 2. Introduction
      • 2.1 History
      • 2.2 Java versus Scala
      • 2.3 Versions
      • 2.4 Target audience
      • 2.5 Acknowledgements
      • 2.6 Feedback
    • 3. Root concepts
      • 3.1 Template-level constraints
      • 3.2 Controller-level restrictions
      • 3.3 Core entities
      • 3.4 Hooks
      • 3.5 Static and dynamic constraints
  • I Deadbolt for Java
    • 4. Using Deadbolt 2 with Play 2 Java projects
      • 4.1 The Deadbolt Handler
      • 4.2 Expose your DeadboltHandlers with a HandlerCache
      • 4.3 application.conf
    • 5. Java controller constraints
      • 5.1 SubjectPresent
      • 5.2 SubjectNotPresent
      • 5.3 Restrict
      • 5.4 RoleBasedPermissions
      • 5.5 Dynamic
      • 5.6 Pattern
      • 5.7 Unrestricted
      • 5.8 Deferring method-level annotation-driven interceptors
      • 5.9 Invoking DeadboltHandler#beforeAuthCheck independently
      • 5.10 Customising the inputs of annotation-driven actions
    • 6. Deadbolt Java Templates
      • 6.1 subjectPresent
      • 6.2 subjectNotPresent
      • 6.3 Restrict
      • 6.4 Pattern
      • 6.5 Dynamic
    • 7. A deeper look at dynamic rules
      • 7.1 Using sessions and requests in your rules
      • 7.2 Strategies for using dynamic resource handlers
    • 8. Integrating with authentication providers
      • 8.1 Play’s built-in authentication support
      • 8.2 Third-party user management
  • II Deadbolt for Scala
    • 9. Using Deadbolt 2 with Play 2 Scala projects
      • 9.1 The Deadbolt Handler
      • 9.2 Expose your DeadboltHandlers with a HandlerCache
      • 9.3 application.conf
      • 9.4 Using compile-time dependency injection
      • 9.5 Tweaking Deadbolt
    • 10. Scala controller constraints
      • 10.1 Controller constraints with the action builder
      • 10.2 Controller constraints with action composition
      • 10.3 SubjectPresent
      • 10.4 SubjectNotPresent
      • 10.5 Restrict
      • 10.6 Pattern
      • 10.7 Dynamic
    • 11. Deadbolt Scala Templates
      • 11.1 Handlers
      • 11.2 SubjectPresent
      • 11.3 SubjectNotPresent
      • 11.4 Restrict
      • 11.5 Pattern
      • 11.6 Dynamic

The Leanpub 60-day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms

80% Royalties. Earn $16 on a $20 book.

We pay 80% royalties. That's not a typo: you earn $16 on a $20 sale. If we sell 5000 non-refunded copies of your book or course for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earnedover $12 millionwriting, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub