Dancer2-Plugin-SPID

 view release on metacpan or  search on metacpan

CHANGES  view on Meta::CPAN

  Change: b96056c189625ae29ebf202f4be64f078f1f6607
  Author: Alessandro Ranellucci <alessandro@pintle.it>
  Date : 2018-08-06 21:22:33 +0000

    Apply some nice Bootstrap to the example app 

  Change: 740adaba378f7ce475bd2e934368821328828f89
  Author: Alessandro Ranellucci <alessandro@pintle.it>
  Date : 2018-08-06 21:06:58 +0000

    Added metadata_endpoint 

  Change: 7dfe9b4a6cd609cab24513ec2bae1fdc4b810897
  Author: Alessandro Ranellucci <alessandro@pintle.it>
  Date : 2018-08-06 21:02:10 +0000

    Update to the newest Net::SPID API 

  Change: 486cc691cd3a4125ea061532467baddafeed8608
  Author: Alessandro Ranellucci <alessandro@pintle.it>
  Date : 2018-08-06 20:27:12 +0000

example/app.pl  view on Meta::CPAN

        template 'user';
    } else {
        template 'index';
    }
};

# That's it. Seriously, that's all you need.
# Below you'll see how to customize the behavior further by configuring one or
# more hooks that the SPID plugin will call.

# This hook is called when the login endpoint is called and the AuthnRequest
# is about to be crafted.
hook 'plugin.SPID.before_login' => sub {
    # ...
};

# This hook is called after the SPID session was successfully initiated.
hook 'plugin.SPID.after_login' => sub {
    info "User " . spid_session->nameid . " logged in";
    
    # Here you might want to create the user in your local database or do more

lib/Dancer2/Plugin/SPID.pm  view on Meta::CPAN

    
    # Load Identity Providers from their XML metadata.
    $spid->load_idp_metadata($self->config->{idp_metadata_dir});

    return $spid;
}

sub _build_spid_button {
    my ($self, %args) = @_;
    
    return $self->_spid->get_button($self->config->{login_endpoint} . '?idp=%s');
}

sub spid_session :PluginKeyword {
    my ($self) = @_;
    return $self->dsl->session('__spid_session');
}

sub BUILD {
    my ($self) = @_;
    
    # Check that we have all the required config options.
    foreach my $key (qw(sp_entityid sp_key_file sp_cert_file idp_metadata_dir
        login_endpoint logout_endpoint)) {
        croak "Missing required config option for SPID: '$key'"
            if !$self->config->{$key};
    }
    
    # Create a hook for populating the spid_* variables in templates.
    $self->app->add_hook(Dancer2::Core::Hook->new(
        name => 'before_template_render',
        code => sub {
            my $vars = shift;
            

t/01_use.t  view on Meta::CPAN

use Dancer2;
use Test::More tests => 1;

BEGIN { # would usually be in config.yml
    set plugins => {
        SPID => {qw(
            sp_entityid         https://www.prova.it/
            sp_key_file         sp.key
            sp_cert_file        sp.pem
            idp_metadata_dir    idp_metadata/
            login_endpoint      /spid-login
            logout_endpoint     /spid-logout
            sso_endpoint        /spid-sso
            slo_endpoint        /spid-slo
        )},
    };
    use_ok('Dancer2::Plugin::SPID');
}

__END__

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 1.259 second using v1.00-cache-2.02-grep-82fe00e-cpan-4673cadbf75 )