|
NAMEGantry::Plugins::AuthCookie - Plugin for cookie based authenticationSYNOPSISPlugin must be included in the Applications use statment.<Perl> use MyApp qw{ -Engine=CGI -TemplateEngine=TT -PluginNamespace=your_module_name AuthCookie }; </Perl> Bigtop: config { engine MP20; template_engine TT; plugins AuthCookie; ... There are various config options. Apache Conf: <Location /controller> PerlSetVar auth_deny yes PerlSetVar auth_require valid-user </Location> Gantry Conf: <GantryLocation /authcookie/sqlite/closed> auth_deny yes auth_require valid-user </GantryLocation> Controller Config: (putting auth restictions on the method/action) sub controller_config { my ( $self ) = @_; { authed_methods => [ { action => 'do_delete', group => '' }, { action => 'do_add', group => '' }, { action => 'do_edit', group => '' }, ], } } # END controller_config Controller Config via Bigtop: method controller_config is hashref { authed_methods do_delete => ``, do_edit => ``, do_add => ``; } DESCRIPTIONThis plugin mixes in a method that will supply the login routines and accessors that will store the authed user row and user groups.Note that you must include AuthCookie in the list of imported items when you use your base app module (the one whose location is app_rootp). Failure to do so will cause errors. CONFIGURATIONAuthentication can be turned on and off by setting 'auth_deny' or auth_optional.$self->auth_deny( 'yes' ); If 'yes', then validation is turned on and the particular location will require that the user is authed. Just like Apache, you must define the type of auth, valid-user or group. $self->auth_require( 'valid-user' ); # default or $self->auth_require( 'group' ); After successful login the user row, groups (if any) will be set into the Gantry self object and can be retrieved using: $self->auth_user_row $self->auth_user_groups For example, to access the username $self->auth_user_row->username or whatever you have set for your auth_user_field see "Gantry::Plugins::AuthCookie#CONFIG OPTIONS" And to access the groups my $groups = $self->auth_user_groups(); foreach my $group ( keys %{ $groups } ) { print $group; } AuthCookie assumes that you have the following tables: table user ( id int, username varchar, password varchar, ) table user_group ( id int, ident int, ) # join table table user_groups ( user user_group ) Optionally you can modify some the table expections like so: $self->auth_table( 'my_usertable' ); $self->auth_user_field( 'myusername' ); $self->auth_password_field( 'mypassword' ); $self->auth_group_table( 'user_group' ); $self->auth_group_join_table( 'user_user_group' ); CONFIG OPTIONSauth_deny 'no' / 'yes' # default 'off' auth_table 'user_table' # default 'user' auth_file '/path/to/htpasswd_file' # Apache htpasswd file auth_user_field 'ident' # default 'ident' auth_password_field 'password' # default 'password' auth_require 'valid-user' or 'group' # default 'valid-user' auth_groups 'group1,group2' # allow these groups auth_secret 'encryption_key' # default 'w3s3cR7' auth_cookie_name 'my_auth_cookie' # default 'auth_cookie' auth_cookie_domain 'www.example.com' # default URL full domain auth_group_table 'user_group' auth_group_join_table 'user_groups' METHODS
CONFIGURATION ACCESSORS
PRIVATE SUBROUTINES
SEE ALSOGantry AUTHORTimotheus Keefer <tkeefer@gmail.com>COPYRIGHT AND LICENSECopyright (C) 2006 Timotheus KeeferThis library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.
Visit the GSP FreeBSD Man Page Interface. |