Plack::Middleware::Auth::BrowserID - Plack Middleware to integrate with Mozilla Persona (Auth by email)


version 0.0.7


    #.. on PSGI file

    use Plack::Builder;
    use Plack::Session;


    builder {
        enable 'Session', store => 'File';

        mount '/auth' => builder {
            enable 'Auth::BrowserID', audience => 'http://localhost:8082/';

        mount '/'     => $app;


Mozilla Persona is a secure solutions, to identify users based on email address.

"Simple, privacy-sensitive single sign-in: let your users sign into your website with their email address, and free yourself from password management."

Some Javascript code is needed in the client side. First include the dependencies:

    <script src="//"></script>
    <script src="//"></script>
    <script src=""></script>"

Setup the watch with email and url's for login and logout (as defined in the PSGI "mount '/auth'"):

    email = $.cookie('email') || null;{
      loggedInUser: email,
      onlogin: function(assertion) {
        return $.post('/auth/signin', {
          assertion: assertion
        }, function(data) {
          return window.location.reload();
      onlogout: function() {
        return window.location = '/auth/signout';

And map the events in the DOM with the watch from Mozilla:

    var signinLink = document.getElementById('signin');
    if (signinLink) {
      signinLink.onclick = function() {; };

    var signoutLink = document.getElementById('signout');
    if (signoutLink) {
      signoutLink.onclick = function() {; };

Please look for the example and read the Mozilla Persona info on MDN.

In the web application get the Plack::Session (example):

    use Dancer2;
    use Plack::Session;

    get '/' => sub {
        my $session = Plack::Session->new( shift->env );
        'Hi! do you wanna dance? ' . $session->get('email');

See the functional example on the examples folder.

  plackup -s Starman -r -p 8082 -E development -I lib example/app.psgi


Plack::Middleware::Session LWP::Protocol::https Net::BrowserID::Verify


João Bolila <>


This software is copyright (c) 2013 by J. Bolila.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.