« blib/lib/Langertha/Knarr/Handler/Raider.pm
↑ Summary
blib/lib/Langertha/Knarr/CLI/Role/GlobalOptions.pm »
| 1 | package Langertha::Knarr::TokenStore; | ||||||||||
| 2 | # ABSTRACT: Role for the stores token_auth looks access tokens up in | ||||||||||
| 3 | 2 | our $VERSION = '1.103'; | |||||||||
| 4 | 2 | ▶ | use Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 2 | ▶ | use Digest::SHA qw( sha256_hex ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 2 | ▶ | use Log::Any qw( $log ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | |||||||||||
| 9 | 2 | requires qw( lookup_f lookup available ); | |||||||||
| 10 | |||||||||||
| 11 | 2 | has on_invalidate => ( | |||||||||
| 12 | is => 'rw', | ||||||||||
| 13 | isa => 'Maybe[CodeRef]', | ||||||||||
| 14 | ); | ||||||||||
| 15 | |||||||||||
| 16 | 1 | ▶ | sub start { } | ||||||||
|
Subroutine
start: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 17 | |||||||||||
| 18 | 1 | ▶ | sub poll { } | ||||||||
|
Subroutine
poll: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 19 | |||||||||||
| 20 | 5 | ▶ | sub invalidate { | ||||||||
|
Subroutine
invalidate: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 21 | 5 | my ($self, $reason) = @_; | |||||||||
| 22 | 5 | ▶ | my $cb = $self->on_invalidate or return; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | 4 | ▶ | eval { $cb->($reason); 1 } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | or $log->errorf( 'token store: invalidate listener failed: %s', $@ ); | ||||||||||
| 25 | 4 | return; | |||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | 24 | ▶ | sub hash_token { | ||||||||
|
Subroutine
hash_token: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 29 | 24 | my ($self, $token) = @_; | |||||||||
| 30 | 24 | my $bytes = $token; | |||||||||
| 31 | 24 | ▶ | utf8::downgrade( $bytes, 1 ) or utf8::encode($bytes); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | 24 | return lc sha256_hex($bytes); | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 2 | 1; | |||||||||
| 36 | |||||||||||
| 37 | __END__ | ||||||||||