Egg-Release-Authorize
view release on metacpan or search on metacpan
lib/Egg/Model/Auth/Plugin/Keep.pm view on Meta::CPAN
$checksum eq sha1_hex($c->{check_sum}. $data{___input_password}) || return do {
$self->e->debug_out(__PACKAGE__. ' - The checksum is bad.');
$self->next::method(1);
};
$data{___start_interval}= time- ($self->config->{interval}+ 60);
$self->next::method(\%data);
}
sub remove_bind_id {
my($self)= @_;
my $name= $self->config->{plugin_keep}{cookie}{name} || 'aa';
$self->e->request->cookie_more( $name => 'deny' );
$self->e->response->cookies->{$name}= { value=> "", expires=> '-1d' };
$self->e->debug_out(__PACKAGE__. ' - Cookie was removed.');
$self->next::method;
}
sub __setup_data {
my $self= shift;
return $self->next::method(@_) if $_[0];
my $data= $self->next::method(@_);
my($e, $c)= ($self->e, $self->config->{plugin_keep});
return $data unless $e->request->params->{$c->{param_name}};
my $checksum= sha1_hex($c->{check_sum}. $data->{___input_password});
my $plain = join $c->{delimiter}, ($checksum, @{$data}{@Items});
my %cookie= %{$c->{cookie}};
$e->response->cookies->{$cookie{name}}=
{ %cookie, value=> $self->__keep_cbc->encrypt_hex($plain) };
$data;
}
1;
__END__
=head1 NAME
Egg::Model::Auth::Plugin::Keep - The attestation is maintained by Cookie.
=head1 SYNOPSIS
package MyApp::Model::Auth::MyAuth;
..........
__PACKAGE__->config(
check_sum => 'abcdefghijklmnopqrstu',
delimiter => ' : ',
param_name => '__auto_login',
cookie => {
...........
},
crypt => {
...........
},
);
__PACKAGE__->setup_plugin(qw/ Keep /);
__PACKAGE__->setup_session('SessionKit');
=head1 DESCRIPTION
The attestation session to which the code that can be decoded to Cookie is set
and the session cut is revived. As a result, the attestation is maintained to
perpetuity.
'plugin_keep' is set to the configuration to use it, and 'Keep' is included in
the list of 'setup_session' method.
__PACKAGE__->setup_plugin(qw/ Keep /);
It and the session component are needed.
__PACKAGE__->setup_session( FileCache => qw/ Bind::Cookie / );
When 'login_check' is called, Cookie for the perpetuity attestation is set if
the input parameter concerning 'The next automatic log in' is effective.
Attestation information is acquired from Cookie if the attestation session doesn't
exist when 'is_login' is called and the attestation session is revived at the
following.
It is necessary to note it very when using it to preserve attestation
information in Cookie.
=head1 CONDIFGURATION
The following items are set and used in 'plugin_keep'.
=head3 check_sum
Character string of 20-40 suitable digit to generate checksum.
=head3 delimiter
Each attestation data delimiter.
Default is ' : '.
=head3 param_name
Name of the form data for flag to do perpetuity attestation effectively.
Default is '__auto_login'.
=head3 cookie
The content is a parameter to pass it to 'cookie' method of L<Egg::Response>.
name ..... Name of Cookie. Default is 'aa'.
expires ..... Validity term of Cookie for perpetuity attestation. Default is '+7D'.
=head3 crypt
The content is an option to pass to L<Crypt::CBC>.
=head1 METHODS
=head2 is_login
If the attestation session exists and doesn't exist, attestation information is
acquired from Cookie, and the attestation session is revived.
And, processing is passed to 'is_login' of L<Egg::Model::Auth::Base>.
( run in 0.452 second using v1.01-cache-2.11-cpan-5b529ec07f3 )