CGI-Application-Plugin-Authentication
view release on metacpan
or search on metacpan
Changes
view on Meta::CPAN
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | Fix failing tests on Win32
0.21 2017-03-15 22:54:23-05:00 America/Chicago
Fix list-context calls to CGI::param().
Fix failing tests with newer CGI versions.
0.20 Fri 29 Apr 2011
Use Test::ConsistentVersion rather than Test::CheckVersion
Fixed spelling errors and added descriptions - Closes
Removed now unused login_styles method from core module
Added more tests completing test coverage for the Cookie module.
Changed from using the Digest::SHA1 module to usuing Digest::SHA
instead - Closes
0.19 Wed 24 Nov 2010
Incoporated developer changes. Made pod tests only run when TEST_AUTHOR=1.
Automatically generate README.
0.18_2 Mon 20 Jul 2010
Separate out display code and provide Basic and Classic alternatives to
the login form. Added more examples. Implementd typo fix reported by
|
Changes
view on Meta::CPAN
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | Other updates
- Fix inconsistency in doc example (reported by POLETTIX)
0.11 Wed Jul 26 11:16:12 EDT 2006
- suppress warning about missing Color::Calc unless the user is actually
trying to use it (reported by Ron Savage) - explicitly load CGI.pm since some users may be using CGI::Simple
(reported by Ron Savage)
- Fixed bug in Cookie store where the expiry time of the cookie was ignored
(patch by POLETTIX)
0.10 Thu May 18 22:59:56 EDT 2006
- Add support for Authen::Simple (all Authen::Simple modules can
be used directly as Drivers)
- Made the login page much more customizable:
- change any of the text
- customize the colours - provide one base colour and lighter and
darker shades are automatically generated (requires Color::Calc)
|
Changes
view on Meta::CPAN
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | 0.08 Wed Nov 23 20:20:24 EST 2005
API Changes
- Removed ability to configure the DBI driver with a DSN and
username/password. CGI::Application::Plugin::DBH should be used for
that instead (Mark Stosberg)
- DBI driver defaults to $self ->dbh() if DBH not provided (Mark Stosberg)
Bug Fixes
- Made MIME::Base64, Digest::SHA1 and CGI::Cookie mandatory requirements
and load them at compile time instead of runtime in the Cookie store.
(fixes problem reported by Richard Jones)
Other updates
- Added Driver that can authenticate against htpasswd files
- Fixed typo in examples/sample.cgi
- Fixed typo in lc filter example (Mark Stosberg)
- Updated docs for initialize(), and made it return true value
(Mark Stosberg)
|
Changes
view on Meta::CPAN
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | - add ability to timeout logins based on last
successful login, or with a custom callback
(as well as the original last access timeout)
- add 'last_access' and 'last_login' methods
- add 'is_login_timeout' to show when a login
request is caused by an idle login session
- added lots more tests
Bug Fixes
- login timeouts were not working properly
- the Cookie Store was not honouring the EXPIRY option
- using :all in protected_runmodes now works
- fix test failure when Test::Warn not installed
(fixed by Shawn Sorichetti)
Experimental
- subroutine attributes: you can specify that a
runmode should be protected with a subroutine
attribute. example: sub my_rm :Authen { ... }
This conflicts with the AutoRunmode plugin right now
|
Changes
view on Meta::CPAN
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | cred_1 to __CREDENTIAL_1__
New Drivers
- Dummy Driver - accepts any credentials as valid
New Stuff
- Added little icons to the default login and password
fields (only works in Mozilla based browsers)
- if STORE config is not given , the plugin will detect if
you are already using the Session plugin, and use the Session Store instead of the Cookie Store.
- Added a lot of new documentation
Bug Fixes
- 'run_modes' method was incorrectly being used in the
test suite (reported by Ron Savage)
0.02 Fri Sep 16 00:19:10 EDT 2005
New Drivers
- DBI Driver
New Stores
- Cookie store (requires no server side storage)
New Stuff
- Added field encoding support for datastores that
keep passwords in an encoded format , like Unix crypt ,
or MD5.
- Added encoders for crypt , MD5 and SHA1
- Added some more methods to Driver.pm that can simplify
the building of new Driver modules (find_option, encode,
check_encoded, strip_field_names)
- Added lots more tests to the test suite
|
MANIFEST
view on Meta::CPAN
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | lib/CGI/Application/Plugin/Authentication/Driver/Dummy.pm
lib/CGI/Application/Plugin/Authentication/Driver/Filter/ crypt .pm
lib/CGI/Application/Plugin/Authentication/Driver/Filter/ lc .pm
lib/CGI/Application/Plugin/Authentication/Driver/Filter/md5.pm
lib/CGI/Application/Plugin/Authentication/Driver/Filter/sha1.pm
lib/CGI/Application/Plugin/Authentication/Driver/Filter/strip.pm
lib/CGI/Application/Plugin/Authentication/Driver/Filter/ uc .pm
lib/CGI/Application/Plugin/Authentication/Driver/Generic.pm
lib/CGI/Application/Plugin/Authentication/Driver/HTPasswd.pm
lib/CGI/Application/Plugin/Authentication/Store.pm
lib/CGI/Application/Plugin/Authentication/Store/Cookie.pm
lib/CGI/Application/Plugin/Authentication/Store/Session.pm
local /lib/perl5/Module/Build/API.pod
local /lib/perl5/Module/Build/Authoring.pod
local /lib/perl5/Module/Build/Base.pm
local /lib/perl5/Module/Build/Bundling.pod
local /lib/perl5/Module/Build/Compat.pm
local /lib/perl5/Module/Build/Config.pm
local /lib/perl5/Module/Build/ConfigData.pm
local /lib/perl5/Module/Build/Cookbook.pm
local /lib/perl5/Module/Build/Dumper.pm
local /lib/perl5/Module/Build/Notes.pm
local /lib/perl5/Module/Build/PPMMaker.pm
local /lib/perl5/Module/Build/Platform/Default.pm
local /lib/perl5/Module/Build/Platform/MacOS.pm
local /lib/perl5/Module/Build/Platform/Unix.pm
local /lib/perl5/Module/Build/Platform/VMS.pm
local /lib/perl5/Module/Build/Platform/VOS.pm
local /lib/perl5/Module/Build/Platform/Windows.pm
local /lib/perl5/Module/Build/Platform/aix.pm
|
README
view on Meta::CPAN
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | CGI::Application::Plugin::Authentication::Driver::DBI and,
CGI::Application::Plugin::Authentication::Driver::Dummy docs for more
information on how to use these drivers. And see the Authen::Simple suite of modules for information on those drivers.
Choosing a Store
The Store modules keep information about the authentication status of
the user persistent across multiple requests. The information that is
stored in the store include the username, and the expiry time of the
login. There are two Store modules included with this distribution. A
Session based store, and a Cookie based store. If your application is
already using Sessions (through the CGI::Application::Plugin::Session
module), then I would recommend that you use the Session store for authentication. If you are not using the Session plugin, then you can
use the Cookie store. The Cookie store keeps all the authentication in a cookie, which contains a checksum to ensure that users can not change
the information.
If you do not specify which Store module you wish to use , the plugin
will try to determine the best one for you.
Login page
The Authentication plugin comes with a default login page that can be
used if you do not want to create a custom login page. This login form
will automatically be used if you do not provide either a LOGIN_URL or
|
README
view on Meta::CPAN
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | ],
STORE
Here you can choose how we store the authenticated information after
a user has successfully logged in. We need to store the username so
that on the next request we can tell the user has already logged in,
and we do not have to present them with another login form. If you
do not provide the STORE option, then the plugin will look to see if
you are using the CGI::Application::Plugin::Session module and based
on that info use either the Session module, or fall back on the Cookie module. If the module requires extra parameters, you can pass
an array reference that contains as the first parameter the name of
the module, and the rest of the array should contain key value pairs
of options for this module. These storage modules generally live
under the CGI::Application::Plugin::Authentication::Store::
name-space, and this part of the package name can be left off when specifying the STORE parameter.
STORE => 'Session'
- or -
STORE => [ 'Cookie' ,
NAME => 'MYAuthCookie' ,
SECRET => 'FortyTwo' ,
EXPIRY => '1d' ,
]
POST_LOGIN_RUNMODE
Here you can specify a runmode that the user will be redirected to
if they successfully login.
POST_LOGIN_RUNMODE => 'welcome'
|
README
view on Meta::CPAN
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 | the only parameter.
Time values are specified in seconds. You can also specify the time
by using a number with the following suffixes (m h d w), which
represent minutes, hours, days and weeks. The default is 0 which
means the login will never timeout.
Note that the login is also dependent on the type of STORE that is
used. If the Session store is used, and the session expires, then
the login will also automatically expire. The same goes for the
Cookie store.
For backwards compatibility, if you set LOGIN_SESSION_TIMEOUT to a
time value instead of a hashref, it will be treated as an IDLE_FOR
time out.
LOGIN_SESSION_TIMEOUT => '15m'
|
example/basic.cgi
view on Meta::CPAN
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | my %config = (
DRIVER => [ 'Generic' , { test => '123' } ],
STORE => 'Cookie' ,
LOGOUT_RUNMODE => 'one' ,
LOGIN_FORM =>{
DISPLAY_CLASS => 'Basic' ,
},
);
SampleLogin->authen->config( %config );
SampleLogin->authen->protected_runmodes( 'two' );
sub setup {
my $self = shift ;
|
example/sample.cgi
view on Meta::CPAN
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | my %config = (
DRIVER => [ 'Generic' , { test => '123' } ],
STORE => 'Cookie' ,
LOGOUT_RUNMODE => 'one' ,
);
SampleLogin->authen->config( %config );
SampleLogin->authen->protected_runmodes( 'two' );
sub setup {
my $self = shift ;
$self ->start_mode( 'one' );
}
|
example/template.cgi
view on Meta::CPAN
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | use base ( "CGI::Application::Plugin::HTDot" , "CGI::Application" ); my %config = (
DRIVER => [ 'Generic' , { test => '123' } ],
STORE => 'Cookie' ,
LOGOUT_RUNMODE => 'one' ,
LOGIN_RUNMODE => 'login' ,
);
SampleLogin->authen->config( %config );
SampleLogin->authen->protected_runmodes( 'two' );
sub setup {
my $self = shift ;
$self ->start_mode( 'one' );
}
|
lib/CGI/Application/Plugin/Authentication.pm
view on Meta::CPAN
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | L<CGI::Application::Plugin::Authentication::Driver::DBI> and,
L<CGI::Application::Plugin::Authentication::Driver::Dummy> docs for more
information on how to use these drivers. And see the L<Authen::Simple> suite of modules for information on those drivers.
|
lib/CGI/Application/Plugin/Authentication.pm
view on Meta::CPAN
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | |
lib/CGI/Application/Plugin/Authentication.pm
view on Meta::CPAN
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 | and false if it is still active. This can allow you to be very selective about how the timeout system
works. The authen object will be passed in as the only parameter.
|
lib/CGI/Application/Plugin/Authentication.pm
view on Meta::CPAN
1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 | my ( $store_module , @store_config );
( $store_module , @store_config ) = @{ $config ->{STORE} } if $config ->{STORE} && ref $config ->{STORE} eq 'ARRAY' ;
if (! $store_module ) {
if ( $self ->_cgiapp->can( 'session' ) && UNIVERSAL::isa( $self ->_cgiapp->session, 'CGI::Session' )) {
( $store_module , @store_config ) = ( 'Session' );
} else {
( $store_module , @store_config ) = ( 'Cookie' );
}
}
my $store_class = _find_deligate_class(
'CGI::Application::Plugin::Authentication::Store::' . $store_module ,
$store_module
) || die "Store $store_module can not be found" ;
|
lib/CGI/Application/Plugin/Authentication/Store/Cookie.pm
view on Meta::CPAN
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | $CGI::Application::Plugin::Authentication::Store::Cookie::VERSION = '0.25' ;
our $SECRET = '' ;
|
lib/CGI/Application/Plugin/Authentication/Store/Cookie.pm
view on Meta::CPAN
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | Just use the resulting string as your secret.
|
lib/CGI/Application/Plugin/Authentication/Store/Cookie.pm
view on Meta::CPAN
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | sub initialize {
my $self = shift ;
my @options = $self ->options;
die "Invalid Store Configuration for the Cookie store - options section must contain a hash of values" if @options % 2;
my %options = @options ;
$self ->{cookie}->{options} = \ %options ;
my %cookies = CGI::Cookie->fetch;
if ( $cookies { $self ->cookie_name}) {
my $rawdata = $cookies { $self ->cookie_name}->value;
$self ->{cookie}->{data} = $self ->_decode( $rawdata );
}
return ;
}
|
lib/CGI/Application/Plugin/Authentication/Store/Cookie.pm
view on Meta::CPAN
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | my $self = shift ;
my $store = $self ->authen->store;
my $rawdata = $store ->_encode( $store ->{cookie}->{data});
my %cookie_params = (
-name => $store ->cookie_name,
-value => $rawdata ,
);
$cookie_params { '-expires' } = $store ->{cookie}->{options}->{EXPIRY} if $store ->{cookie}->{options}->{EXPIRY};
my $cookie = new CGI::Cookie( %cookie_params );
$self ->header_add( -cookie => [ $cookie ]);
return ;
}
sub _decode {
my $self = shift ;
my $rawdata = MIME::Base64::decode( shift );
|
lib/CGI/Application/Plugin/Authentication/Store/Cookie.pm
view on Meta::CPAN
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | my %hash = %$hash ;
my $checksum = Digest::SHA::sha1_base64( join ( "\0" , $self ->_secret, sort values %hash ));
$hash {c} = $checksum ;
my $rawdata = join ( "\0" , map { join ( '=' , $_ , $hash { $_ }) } keys %hash );
return MIME::Base64::encode( $rawdata , "" );
}
sub _secret {
my $self = shift ;
my $secret = $self ->{cookie}->{options}->{SECRET} || $SECRET ;
unless ( $secret ) {
$secret = Digest::SHA::sha1_base64( ref $self ->authen->_cgiapp );
warn "using default SECRET! Please provide a proper SECRET when using the Cookie store (See CGI::Application::Plugin::Authentication::Store::Cookie for details)" ;
}
return $secret ;
}
|
local/lib/perl5/Module/Build/API.pod
view on Meta::CPAN
1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 | [version 0.26]
Adds a new type of entry to the build process. Accepts a single
string specifying its type-name. There must also be a method defined
to process things of that type, e.g. if you add a build element called
C< 'foo' >, then you must also define a method called
C<process_foo_files()>.
See also
L<Module::Build::Cookbook/ "Adding new file types to the build process" >.
|
local/lib/perl5/Module/Build/API.pod
view on Meta::CPAN
2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 | Copyright (c) 2001-2006 Ken Williams. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
|
local/lib/perl5/Module/Build/Authoring.pod
view on Meta::CPAN
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | Bug reports are also welcome at
The latest development version is available from the Git
|
local/lib/perl5/Module/Build/Bundling.pod
view on Meta::CPAN
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | Development questions, bug reports, and patches should be sent to the
Module-Build mailing list at <module-build @perl .org>.
Bug reports are also welcome at
|
local/lib/perl5/Module/Build/Cookbook.pm
view on Meta::CPAN
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | |
t/03_destination.t
view on Meta::CPAN
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | taint_checking_ok( 'taint checking is on' );
my $cap_options =
{
DRIVER => [ 'Generic' , { user1 => '123' } ],
STORE => [ 'Cookie' , SECRET => "Shhh, don't tell anyone" , NAME => 'CAPAUTH_DATA ', EXPIRY => ' +1y'],
POST_LOGIN_CALLBACK => \ &TestAppAuthenticate::post_login ,
};
{
|
t/03_destination.t
view on Meta::CPAN
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | local $cap_options ->{LOGIN_FORM}->{DISPLAY_CLASS} = 'Basic' ;
my $query = CGI->new( { rm => 'two' } );
my $cgiapp = TestAppAuthenticate->new( QUERY => $query );
ok_regression( sub {make_output_timeless( $cgiapp ->run)}, "t/out/redirection_failure_basic" , "redirection_failure [Basic]" );
};
sub make_output_timeless {
my $output = shift ;
$output =~ s/^(Set-Cookie: CAPAUTH_DATA=\w+\%3D(?:\%3D)?\; path=\/\; expires=\w{3},\s\d{2}(?:\-|\s)\w{3}(?:\-|\s)\d{4}\s\d{2}:\d{2}:\d{2}\s\w{3})([\r\n\s]*)$/Set-Cookie: CAPAUTH_DATA=; path=\/; expires=;$2/m;
$output =~ s/^(Expires:\s\w{3},\s\d{2}\s\w{3}\s\d{4}\s\d{2}:\d{2}:\d{2}\s\w{3})([\r\n\s]*)$/Expires$2/m;
$output =~ s/^(Date:\s\w{3},\s\d{2}\s\w{3}\s\d{4}\s\d{2}:\d{2}:\d{2}\s\w{3})([\r\n\s]*)$/Date$2/m;
return $output ;
}
|
t/03_login_box.t
view on Meta::CPAN
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | taint_checking_ok( 'taint checking is on' );
$ENV {CGI_APP_RETURN_ONLY} = 1;
my $cap_options =
{
DRIVER => [ 'Generic' , { user1 => '123' } ],
STORE => [ 'Cookie' , SECRET => "Shhh, don't tell anyone" , NAME => 'CAPAUTH_DATA ', EXPIRY => ' +1y'],
POST_LOGIN_CALLBACK => \ &TestAppAuthenticate::post_login ,
};
{
|
t/03_login_box_basic.t
view on Meta::CPAN
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | taint_checking_ok( 'taint checking is on' );
$ENV {CGI_APP_RETURN_ONLY} = 1;
my $cap_options =
{
DRIVER => [ 'Generic' , { user1 => '123' } ],
STORE => [ 'Cookie' , SECRET => "Shhh, don't tell anyone" , NAME => 'CAPAUTH_DATA ', EXPIRY => ' +1y'],
POST_LOGIN_CALLBACK => \ &TestAppAuthenticate::post_login ,
LOGIN_FORM =>{
DISPLAY_CLASS => 'Basic' ,
},
};
{
|
t/03_login_box_other.t
view on Meta::CPAN
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | }
my $cap_options =
{
DRIVER => [ 'Generic' , { user1 => '123' } ],
STORE => [ 'Cookie' , SECRET => "Shhh, don't tell anyone" , NAME => 'CAPAUTH_DATA ', EXPIRY => ' +1y'],
POST_LOGIN_CALLBACK => \ &TestAppAuthenticate::post_login ,
};
{
|
t/03_login_box_other.t
view on Meta::CPAN
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | my $query = CGI->new( { rm => 'two' } );
my $cgiapp = TestAppAuthenticate->new( QUERY => $query );
ok_regression( sub {make_output_timeless( $cgiapp ->run)}, "t/out/grey2" , "grey" );
};
sub make_output_timeless {
my $output = shift ;
$output =~ s/^(Set-Cookie: CAPAUTH_DATA=\w+\%3D\%3D\; path=\/\; expires=\w{3},\s\d{2}(?:\-|\s)\w{3}(?:\-|\s)\d{4}\s\d{2}:\d{2}:\d{2}\s\w{3})([\r\n\s]*)$/Set-Cookie: CAPAUTH_DATA=; path=\/; expires=;$2/m;
$output =~ s/^(Expires:\s\w{3},\s\d{2}\s\w{3}\s\d{4}\s\d{2}:\d{2}:\d{2}\s\w{3})([\r\n\s]*)$/Expires$2/m;
$output =~ s/^(Date:\s\w{3},\s\d{2}\s\w{3}\s\d{4}\s\d{2}:\d{2}:\d{2}\s\w{3})([\r\n\s]*)$/Date$2/m;
return $output ;
}
|
t/03_missing_color.t
view on Meta::CPAN
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | taint_checking_ok( 'taint checking is on' );
my $cap_options =
{
DRIVER => [ 'Generic' , { user1 => '123' } ],
STORE => [ 'Cookie' , SECRET => "Shhh, don't tell anyone" , NAME => 'CAPAUTH_DATA ', EXPIRY => ' +1y'],
POST_LOGIN_CALLBACK => \ &TestAppAuthenticate::post_login ,
};
{
|
t/03_missing_color.t
view on Meta::CPAN
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | plan tests => 1;
my $query = CGI->new( { rm => 'two' } );
my $cgiapp = TestAppAuthenticate->new( QUERY => $query );
ok_regression( sub {make_output_timeless( $cgiapp ->run)}, "t/out/missing_color" , "Missing color" );
};
sub make_output_timeless {
my $output = shift ;
$output =~ s/^(Set-Cookie: CAPAUTH_DATA=\w+\%3D\%3D\; path=\/\; expires=\w{3},\s\d{2}(?:\-|\s)\w{3}(?:\-|\s)\d{4}\s\d{2}:\d{2}:\d{2}\s\w{3})([\r\n\s]*)$/Set-Cookie: CAPAUTH_DATA=; path=\/; expires=;$2/m;
$output =~ s/^(Expires:\s\w{3},\s\d{2}\s\w{3}\s\d{4}\s\d{2}:\d{2}:\d{2}\s\w{3})([\r\n\s]*)$/Expires$2/m;
$output =~ s/^(Date:\s\w{3},\s\d{2}\s\w{3}\s\d{4}\s\d{2}:\d{2}:\d{2}\s\w{3})([\r\n\s]*)$/Date$2/m;
return $output ;
}
Test::NoWarnings::had_no_warnings();
|
t/50_driver_missing_modules.t
view on Meta::CPAN
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | srand (0);
taint_checking_ok( 'taint checking is on' );
my $cap_options = {
STORE => [
'Cookie' ,
SECRET => "Shhh, don't tell anyone" ,
NAME => 'CAPAUTH_DATA' ,
EXPIRY => '+1y'
],
};
{
|
t/50_driver_undefined.t
view on Meta::CPAN
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | srand (0);
taint_checking_ok( 'taint checking is on' );
my $cap_options = {
STORE => [
'Cookie' ,
SECRET => "Shhh, don't tell anyone" ,
NAME => 'CAPAUTH_DATA' ,
EXPIRY => '+1y'
],
};
{
|
t/55_driver_missing_authensimple.t
view on Meta::CPAN
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | plan tests => 4;
srand (0);
my $cap_options = {
STORE => [
'Cookie' ,
SECRET => "Shhh, don't tell anyone" ,
NAME => 'CAPAUTH_DATA' ,
EXPIRY => '+1y'
],
};
{
|
t/60_parsimony.t
view on Meta::CPAN
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | '<html><head/><body>This is public.</body></html>' ,
'TestAppParsimony, unprotected'
);
}
{
my $app = TestAppParsimony->new();
$app ->query(CGI->new({ 'rm' => 'protected' , auth_username => 'test' , auth_password => '123' }));
response_like(
$app ,
qr{^Set-Cookie: CGISESSID=\w{1,100} ; path=/|Date: \w{3}, \d{1,2} \w{3} \d{4} \d{2}:\d{2}:\d{2} \d{3}|Content-Type: text/html; charset=ISO-8859-1$},
'<html><head/><body>This is private.</body></html>' ,
'TestAppParsimony, protected'
);
}
{
my $app = TestAppParsimony->new();
$app ->query(CGI->new({ 'rm' => 'unprotected' }));
response_like(
$app ,
|
t/60_store_cookie.t
view on Meta::CPAN
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | plan tests => 17;
{
__PACKAGE__->authen->config(
DRIVER => [ 'Generic' , { 'test' => '123' } ],
STORE => [ 'Cookie' , SECRET => "Shhh, don't tell anyone" , NAME => 'CUSTOM_NAME ', EXPIRY => ' +1y' ],
CREDENTIALS => [ qw(auth_username auth_password) ],
);
sub get_store_entries {
my $class = shift ;
my $cgiapp = shift ;
my $results = shift ;
my ( $capauth_data , $therest ) = $results =~ qr/^Set\-Cookie:\s+CUSTOM_NAME=([\d\w%]+);(.*)$/ m;
return undef unless $capauth_data ;
main::like( $therest , qr/expires=/ , 'Expiry on the cookie is set' );
my $data = CGI::Util::unescape( $capauth_data );
return $data ? $cgiapp ->authen->store->_decode( $data ) : undef ;
}
sub maintain_state {
my $class = shift ;
my $old_cgiapp = shift ;
my $old_results = shift ;
my $new_query = shift ;
delete $ENV { 'COOKIE' };
$old_results =~ qr/Set\-Cookie:\s+(CUSTOM_NAME=[\d\w%]+);/ ;
$ENV { 'COOKIE' } = $1 if $1;
}
sub clear_state {
my $class = shift ;
delete $ENV { 'COOKIE' };
$class ->SUPER::clear_state( @_ );
}
}
TestAppStoreCookie->run_store_tests;
|
t/61_cookie_badargs.t
view on Meta::CPAN
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | plan tests => 2;
{
__PACKAGE__->authen->config(
DRIVER => [ 'Generic' , { 'test' => '123' } ],
STORE => [ 'Cookie' , EXPIRY => '+1y' , 'YAH_BOO_SUCKS' ],
CREDENTIALS => [ qw(auth_username auth_password) ],
);
sub run_store_tests {
my $class = shift ;
my ( $cgiapp , $results , $store_entries );
throws_ok {
( $cgiapp , $results , $store_entries ) = $class ->run_app( { rm => 'unprotected' } );
} qr/Error executing run mode 'unprotected': Invalid Store Configuration for the Cookie store - options section must contain a hash of values/ , 'invalid args' ;
}
}
TestAppStoreCookie->run_store_tests;
|
t/61_store_cookie_noexpiry.t
view on Meta::CPAN
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | #!/usr/bin/perl
Readonly my $SECRET_WARN => qr/using default SECRET\! Please provide a proper SECRET when using the Cookie store/ ;
plan tests => 21;
{
__PACKAGE__->authen->config(
DRIVER => [ 'Generic' , { 'test' => '123' } ],
STORE => [ 'Cookie' ],
CREDENTIALS => [ qw(auth_username auth_password) ],
);
sub get_store_entries {
my $class = shift ;
my $cgiapp = shift ;
my $results = shift ;
my ( $capauth_data , $therest ) = $results =~ qr/^Set\-Cookie:\s+CAPAUTH_DATA=([\d\w%]+);(.*)$/ m;
return undef unless $capauth_data ;
main::unlike( $therest , qr/expires=/ , 'Expiry on the cookie is not set' );
my $data = CGI::Util::unescape( $capauth_data );
return $data ? $cgiapp ->authen->store->_decode( $data ) : undef ;
}
sub maintain_state {
my $class = shift ;
my $old_cgiapp = shift ;
my $old_results = shift ;
my $new_query = shift ;
delete $ENV { 'COOKIE' };
$old_results =~ qr/Set\-Cookie:\s+(CAPAUTH_DATA=[\d\w%]+);/ ;
$ENV { 'COOKIE' } = $1 if $1;
}
sub clear_state {
my $class = shift ;
delete $ENV { 'COOKIE' };
$class ->SUPER::clear_state( @_ );
}
sub run_store_tests {
|
t/61_store_cookie_noexpiry.t
view on Meta::CPAN
92 93 94 95 96 97 98 99 100 101 102 | ok( $cgiapp ->authen->is_authenticated, 'successful login' );
ok( $store_entries , "Store entry created when calling protected page with valid login" );
is( $store_entries ->{username}, 'test' , "Store entry contained the right username" );
ok(! $store_entries ->{login_attempts}, "Store entry cleared login_attempts" );
}
}
TestAppStoreCookie->run_store_tests;
|
t/61_store_cookie_other.t
view on Meta::CPAN
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | #!/usr/bin/perl
Readonly my $SECRET_WARN => qr/using default SECRET\! Please provide a proper SECRET when using the Cookie store/ ;
plan tests => 25;
{
__PACKAGE__->authen->config(
DRIVER => [ 'Generic' , { 'test' => '123' } ],
STORE => [ 'Cookie' , EXPIRY => '+1y' ],
CREDENTIALS => [ qw(auth_username auth_password) ],
);
sub get_store_entries {
my $class = shift ;
my $cgiapp = shift ;
my $results = shift ;
my ( $capauth_data , $therest ) = $results =~ qr/^Set\-Cookie:\s+CAPAUTH_DATA=([\d\w%]+);(.*)$/ m;
return undef unless $capauth_data ;
main::like( $therest , qr/expires=/ , 'Expiry on the cookie is set' );
my $data = CGI::Util::unescape( $capauth_data );
return $data ? $cgiapp ->authen->store->_decode( $data ) : undef ;
}
sub maintain_state {
my $class = shift ;
my $old_cgiapp = shift ;
my $old_results = shift ;
my $new_query = shift ;
delete $ENV { 'COOKIE' };
$old_results =~ qr/Set\-Cookie:\s+(CAPAUTH_DATA=[\d\w%]+);/ ;
$ENV { 'COOKIE' } = $1 if $1;
}
sub clear_state {
my $class = shift ;
delete $ENV { 'COOKIE' };
$class ->SUPER::clear_state( @_ );
}
sub run_store_tests {
|
t/61_store_cookie_other.t
view on Meta::CPAN
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | my %hash = ( c => 'I am not a checksum' , f => 'Bubble' );
my $rawdata = join ( "\0" , map { join ( '=' , $_ , $hash { $_ }) } keys %hash );
my $nonsense ;
warning_like {
$nonsense = $cgiapp ->authen->store->_decode(MIME::Base64::encode( $rawdata ));
} $SECRET_WARN , 'decode warning' ;
is( $nonsense , undef , 'decode nonsense' );
{
$CGI::Application::Plugin::Authentication::Store::Cookie::SECRET = 'you would never guess' ;
}
$nonsense = $cgiapp ->authen->store->_decode(MIME::Base64::encode( $rawdata ));
is( $nonsense , undef , 'decode nonsense with secret' );
}
}
TestAppStoreCookie->run_store_tests;
|
t/70_action_dispatch.t
view on Meta::CPAN
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | taint_checking_ok( 'taint checking is on' );
my $cap_options =
{
DRIVER => [ 'Generic' , { user1 => '123' } ],
STORE => [ 'Cookie' , SECRET => "Shhh, don't tell anyone" , NAME => 'CAPAUTH_DATA ', EXPIRY => ' +1y'],
POST_LOGIN_CALLBACK => \ &TestAppAuthenticate::post_login ,
};
{
|
t/70_action_dispatch.t
view on Meta::CPAN
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | ok_regression( sub {make_output_timeless( $cgiapp ->run)}, "t/out/success" , "success" );
ok( $cgiapp ->authen->is_authenticated, 'login success' );
is( $cgiapp ->authen->username, 'user1' , "login success - username set" );
is( $cgiapp ->authen->login_attempts, 0, "successful login - failed login count" );
is( $cgiapp ->param( 'post_login' ),1, 'successful login - POST_LOGIN_CALLBACK executed' );
};
sub make_output_timeless {
my $output = shift ;
$output =~ s/^(Set-Cookie: CAPAUTH_DATA=\w+\%3D\%3D\; path=\/\; expires=\w{3},\s\d{2}(?:\-|\s)\w{3}(?:\-|\s)\d{4}\s\d{2}:\d{2}:\d{2}\s\w{3})([\r\n\s]*)$/Set-Cookie: CAPAUTH_DATA=; path=\/; expires=;$2/m;
$output =~ s/^(Expires:\s\w{3},\s\d{2}\s\w{3}\s\d{4}\s\d{2}:\d{2}:\d{2}\s\w{3})([\r\n\s]*)$/Expires$2/m;
$output =~ s/^(Date:\s\w{3},\s\d{2}\s\w{3}\s\d{4}\s\d{2}:\d{2}:\d{2}\s\w{3})([\r\n\s]*)$/Date$2/m;
return $output ;
}
|
t/80_devpopup.t
view on Meta::CPAN
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | taint_checking_ok( 'taint checking is on' );
my $cap_options =
{
DRIVER => [ 'Generic' , { user1 => '123' } ],
STORE => [ 'Cookie' , SECRET => "Shhh, don't tell anyone" , NAME => 'CAPAUTH_DATA ', EXPIRY => ' +1y'],
POST_LOGIN_RUNMODE => 'protected' ,
};
{
|
t/80_devpopup.t
view on Meta::CPAN
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | my $cgiapp = TestAppAuthenticate->new( QUERY => $query );
ok_regression( sub {make_output_timeless( $cgiapp ->run)}, "t/out/success-dev" , "success" );
ok( $cgiapp ->authen->is_authenticated, 'login success' );
is( $cgiapp ->authen->username, 'user1' , "login success - username set" );
is( $cgiapp ->authen->login_attempts, 0, "successful login - failed login count" );
};
sub make_output_timeless {
my $output = shift ;
$output =~ s/^(Set-Cookie: CAPAUTH_DATA=\w+\%3D\%3D\; path=\/\; expires=\w{3},\s\d{2}(?:\-|\s)\w{3}(?:\-|\s)\d{4}\s\d{2}:\d{2}:\d{2}\s\w{3})([\r\n\s]*)$/Set-Cookie: CAPAUTH_DATA=; path=\/; expires=;$2/m;
$output =~ s/^(Expires:\s\w{3},\s\d{2}\s\w{3}\s\d{4}\s\d{2}:\d{2}:\d{2}\s\w{3})([\r\n\s]*)$/Expires$2/m;
$output =~ s/^(Date:\s\w{3},\s\d{2}\s\w{3}\s\d{4}\s\d{2}:\d{2}:\d{2}\s\w{3})([\r\n\s]*)$/Date$2/m;
return $output ;
}
|
t/out/crlf
view on Meta::CPAN
1 2 3 4 5 | Set-Cookie: CAPAUTH_DATA=; path=/; expires=;
Date
Content-Type: text/html; charset=ISO-8859-1
<html><body>TWO</body></html>
|
t/out/generic_login
view on Meta::CPAN
1 2 3 4 5 6 7 8 9 10 11 | Set-Cookie: CAPAUTH_DATA=; path=/; expires=;
Date
Content-Type: text/html; charset=ISO-8859-1
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<head>
<title>Sign In</title>
<meta http-equiv= "Content-Type" content= "text/html; charset=iso-8859-1" />
|
t/out/loginurl
view on Meta::CPAN
1 2 3 4 | Status: 302 Found
Set-Cookie: CAPAUTH_DATA=; path=/; expires=;
Date
|