ClearPress

 view release on metacpan or  search on metacpan

lib/ClearPress/authenticator/session.pm  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
50
51
52
53
54
55
56
57
58
59
  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

44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
  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.328 second using v1.01-cache-2.11-cpan-5f2e87ce722 )