Reputation: 552
I'm trying to use the Dancer2 plugin: Dancer2::Plugin::Auth::Extensible with my own authentication provider because there is an existing one in the project I'm working on.
I have adapted the given example, however I need to pass a couple of parameters to both the authenticate_user
and users
subroutine. The parameter is dynamic, so I can't add it via the configuration file.
I have an inelegent method to pass it in with the username as a string (concatenated) and then split it inside the authenticate_user
, but this won't work with the users
subroutine. And this just isn't the right way to do it.
I also tried passing it as a regular parameter, like
sub authenticate_user {
my ($self, $username_course, $password, $realm,$param) = @_;
but this didn't work (not sure why), and it won't work for users
, which no parameters.
I've thought that since this is a Dancer2::Plugin that I could leverage some of that, but not exactly how to adapt the existing Plugin. This is what I've tried:
package Dancer2::Plugin::Auth::Extensible::Provider::Test;
use Moo;
with "Dancer2::Plugin::Auth::Extensible::Role::Provider";
has authen_param => (is => 'rw');
plugin_keywords 'set_param'; # this fails compilation
sub set_param {
my ($self,$p) = @_;
$self->authen_param($p);
}
sub authenticate_user {
my ($self, $username, $password) = @_;
# use authen_param to authenticate
}
1
Upvotes: 1
Views: 484
Reputation: 552
It appears that I can use the session to store the information that I need. I need to make sure that I store the parameter in the session and then can retrieve it using $self->plugin->dsl->session->data->{param_name}
.
Upvotes: 1