ClearPress
view release on metacpan or search on metacpan
lib/ClearPress/authenticator/session.pm view on Meta::CPAN
my $user_yaml = Dump($user_hash);
my $encrypted = $self->cipher->encrypt($user_yaml);
my $encoded = encode_base64($encrypted);
return $encoded;
}
sub decode_token {
my ($self, $token) = @_;
my $decoded = q[];
eval {
$decoded = decode_base64($token);
} or do {
carp q[Failed to decode token];
return;
};
my $decrypted = q[];
eval {
$decrypted = $self->cipher->decrypt($decoded);
} or do {
carp q[Failed to decrypt token];
return;
};
my $deyamled;
eval {
$deyamled = Load($decrypted);
} or do {
t/authenticator/session.t view on Meta::CPAN
is($auth->key, 'othersecretkey', 'key from accessor');
}
{
my $auth = $PKG->new();
my $ref = {
username => 'dummy',
metadata => 'stuff',
};
my $encoded = $auth->encode_token($ref);
my $decoded = $auth->decode_token($encoded);
is_deeply($decoded, $ref, 'one-pass encode/decode');
my $authen = $auth->authen_token($encoded);
is_deeply($authen, $ref, 'authen_token pass-through to decode_token');
}
{
my $auth = $PKG->new();
my $encoded = encode_base64('corruption');
trap {
( run in 0.415 second using v1.01-cache-2.11-cpan-26ccb49234f )