Giter Club home page Giter Club logo

dancer-plugin-auth-htpasswd's Introduction

NAME

Dancer::Plugin::Auth::Htpasswd - Basic HTTP authentication with htpasswd files in Dancer apps

VERSION

Version 0.014

SYNOPSIS

Dancer::Plugin::Auth::Htpasswd allows you to use Apache-style htpasswd files to implement basic HTTP authentication in Dancer web applications.

Add the plugin to your application:

use Dancer::Plugin::Auth::Htpasswd;

In the configuration file, list the paths that you want to protect and the htpasswd files to use:

plugins:
  "Auth::Htpasswd":
    paths:
      "/restricted": /path/to/htpasswd
      "/secret/documents":
        realm: "Top Secret Documents"
        passwd_file: /different/path/to/htpasswd

You can also enable authentication by calling the auth_htpasswd function in a before filter:

before sub {
    auth_htpasswd realm => 'Secret Files',
                  passwd_file => '/path/to/htpasswd';
};

or in a route handler:

get '/restricted' => sub {
    auth_htpasswd '/path/to/htpasswd';
    
    # Authenticated
    ...
};

DESCRIPTION

Dancer::Plugin::Auth::Htpasswd provides a simple way to implement basic HTTP authentication in Dancer web applications using Apache-style htpasswd files.

CONFIGURATION

To configure the plugin, add its options in the plugins section of your application's configuration file. The supported options are listed below.

paths

Defines one or more paths that will be protected, including sub-paths (so if the path is "/restricted", then "/restricted/secret/file.html" will also be protected). Each path can have the following parameters:

  • passwd_file

    Location of the htpasswd file.

  • realm

    Realm name that will be displayed in the authentication dialog. Default: "Restricted area"

Example:

plugins:
  "Auth::Htpasswd":
    paths:
      "/classified":
        realm: "Classified Files"
        passwd_file: /path/to/htpasswd
        

If you don't need to set the realm, you can use the simplified syntax with just the location of the htpasswd file:

plugins:
  "Auth::Htpasswd":
    paths:
      "/secret/documents": /path/to/htpasswd
      "/restricted": /another/path/to/htpasswd

SUBROUTINES

auth_htpasswd

Call this function in a before filter or at the beginning of a route handler. It checks the specified htpasswd file to verify if the client is authorized to access the requested path -- if not, it immediately returns a 401 Unauthorized response to prompt the user to authenticate.

You can call this function with a single parameter, which is the location of the htpasswd file to use:

auth_htpasswd '/path/to/htpasswd';

or, with a hash of parameters:

auth_htpasswd realm => 'Authorized personnel only',
              passwd_file => '/path/to/htpasswd';

Parameters:

  • passwd_file

    Location of the htpasswd file.

  • realm

    Realm name that will be displayed in the authentication dialog. Default: "Restricted area"

AUTHOR

Michal Wojciechowski, <odyniec at cpan.org>

BUGS

Please report any bugs or feature requests to bug-dancer-plugin-auth-htpasswd at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Dancer-Plugin-Auth-Htpasswd. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Dancer::Plugin::Auth::Htpasswd

You can also look for information at:

ACKNOWLEDGEMENTS

The plugin uses the Authen::Htpasswd module, written by David Kamholz and Yuval Kogman.

LICENSE AND COPYRIGHT

Copyright 2011 Michal Wojciechowski.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.

dancer-plugin-auth-htpasswd's People

Contributors

odyniec avatar

Watchers

Stefan Hornburg (Racke) avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.