Dancer2::Plugin::Auth::HTTP::Basic::DWIW - HTTP Basic authentication plugin for Dancer2 that does what I want.
version 0.0801
package test; use Dancer2; use Dancer2::Plugin::Auth::HTTP::Basic::DWIW; http_basic_auth_handler check_login => sub { my ( $user, $pass ) = @_; # you probably want to check the user in a better way return $user eq 'test' && $pass eq 'bla'; }; http_basic_auth_handler no_auth => sub { template 'auth_error'; }; get '/' => http_basic_auth required => sub { my ( $user, $pass ) = http_basic_auth_login; return $user; }; 1;
This plugin gives you the option to use HTTP Basic authentication with Dancer2.
You can set a handler to check the supplied credentials. If you don't set a handler, every username/password combination will work.
Don't ever use HTTP Basic authentication over clear-text connections! Always use HTTPS!
The only case were using HTTP is ok is while developing an application. Don't use HTTP because you think it is ok in corporate networks or something alike, you can always have bad bad people in your network..
The realm presented by browsers in the login dialog.
Defaults to "Please login".
This is my first perl module published on CPAN. Please don't hurt me when it is bad and feel free to make suggestions or to fork it on GitHub.
Please report any bugs or feature requests to littlefox at fsfe.org, or through the web interface at https://github.com/LittleFox94/Dancer2-Plugin-Auth-HTTP-Basic-DWIW/issues. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
littlefox at fsfe.org
After installation you can find documentation for this module with the perldoc command:
perldoc Dancer2::Plugin::Auth::HTTP::Basic::DWIW
Mara Sophie Grosch (LittleFox) <littlefox@cpan.org>
This software is copyright (c) 2020 by Mara Sophie Grosch (LittleFox).
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Dancer2::Plugin::Auth::HTTP::Basic::DWIW, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Dancer2::Plugin::Auth::HTTP::Basic::DWIW
CPAN shell
perl -MCPAN -e shell install Dancer2::Plugin::Auth::HTTP::Basic::DWIW
For more information on module installation, please visit the detailed CPAN module installation guide.