| 1 | package OIDC::Client::Identity; | ||||||||||||
| 2 | 6 | ▶ | use utf8; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | 6 | ▶ | use Moose; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 6 | ▶ | use MooseX::Params::Validate; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 6 | ▶ | use namespace::autoclean; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | |||||||||||||
| 7 | 6 | has 'subject' => ( | |||||||||||
| 8 | is => 'ro', | ||||||||||||
| 9 | isa => 'Str', | ||||||||||||
| 10 | required => 1, | ||||||||||||
| 11 | ); | ||||||||||||
| 12 | |||||||||||||
| 13 | 6 | has 'claims' => ( | |||||||||||
| 14 | is => 'ro', | ||||||||||||
| 15 | isa => 'HashRef', | ||||||||||||
| 16 | required => 1, | ||||||||||||
| 17 | ); | ||||||||||||
| 18 | |||||||||||||
| 19 | 6 | has 'token' => ( | |||||||||||
| 20 | is => 'ro', | ||||||||||||
| 21 | isa => 'Str', | ||||||||||||
| 22 | required => 1, | ||||||||||||
| 23 | ); | ||||||||||||
| 24 | |||||||||||||
| 25 | 6 | has 'expires_at' => ( | |||||||||||
| 26 | is => 'ro', | ||||||||||||
| 27 | isa => 'Maybe[Int]', | ||||||||||||
| 28 | required => 0, | ||||||||||||
| 29 | ); | ||||||||||||
| 30 | |||||||||||||
| 31 | =encoding utf8 | ||||||||||||
| 32 | |||||||||||||
| 33 | =head1 NAME | ||||||||||||
| 34 | |||||||||||||
| 35 | OIDC::Client::Identity - Identity class | ||||||||||||
| 36 | |||||||||||||
| 37 | =head1 DESCRIPTION | ||||||||||||
| 38 | |||||||||||||
| 39 | Class representing an identity | ||||||||||||
| 40 | |||||||||||||
| 41 | =head1 ATTRIBUTES | ||||||||||||
| 42 | |||||||||||||
| 43 | =head2 subject | ||||||||||||
| 44 | |||||||||||||
| 45 | The subject identifier coming from the ID token. Required | ||||||||||||
| 46 | |||||||||||||
| 47 | =head2 claims | ||||||||||||
| 48 | |||||||||||||
| 49 | Hashref of claims coming from the ID token. Required | ||||||||||||
| 50 | |||||||||||||
| 51 | =head2 token | ||||||||||||
| 52 | |||||||||||||
| 53 | The string of the ID token. Required | ||||||||||||
| 54 | |||||||||||||
| 55 | =head2 expires_at | ||||||||||||
| 56 | |||||||||||||
| 57 | The expiration time of the identity (number of seconds since 1970-01-01T00:00:00Z) | ||||||||||||
| 58 | |||||||||||||
| 59 | =head1 METHODS | ||||||||||||
| 60 | |||||||||||||
| 61 | =head2 has_expired( $leeway ) | ||||||||||||
| 62 | |||||||||||||
| 63 | my $has_expired = $identity->has_expired(); | ||||||||||||
| 64 | |||||||||||||
| 65 | Returns whether the identity has expired. | ||||||||||||
| 66 | |||||||||||||
| 67 | Returns undef if the C<expires_at> attribute is not defined. | ||||||||||||
| 68 | |||||||||||||
| 69 | The list parameters are: | ||||||||||||
| 70 | |||||||||||||
| 71 | =over 2 | ||||||||||||
| 72 | |||||||||||||
| 73 | =item leeway | ||||||||||||
| 74 | |||||||||||||
| 75 | Number of seconds of leeway for the identity to be considered expired before it actually is. | ||||||||||||
| 76 | |||||||||||||
| 77 | =back | ||||||||||||
| 78 | |||||||||||||
| 79 | =cut | ||||||||||||
| 80 | |||||||||||||
| 81 | 8 | ▶ | sub has_expired { | ||||||||||
|
Subroutine
has_expired: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||
| 82 | 8 | my $self = shift; | |||||||||||
| 83 | 8 | my ($leeway) = pos_validated_list(\@_, { isa => 'Maybe[Int]', optional => 1 }); | |||||||||||
| 84 | 8 | ▶ | $leeway //= 0; | ||||||||||
|
Condition100%2/2
$leeway //= 0
MC/DC100%1/1
$leeway //= 0
$leeway
Truth table100%2/2
A
A= $leeway
| |||||||||||||
| 85 | |||||||||||||
| 86 | 8 | ▶ | return unless defined $self->expires_at; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 87 | |||||||||||||
| 88 | 6 | return ( $self->expires_at - $leeway ) < time; | |||||||||||
| 89 | } | ||||||||||||
| 90 | |||||||||||||
| 91 | 6 | __PACKAGE__->meta->make_immutable; | |||||||||||
| 92 | |||||||||||||
| 93 | 6 | 1; | |||||||||||