NAME
Kernel::System::AccessToken::Storage::OIDC
DESCRIPTION
Authorization tokens database storage class.
METHODS
Create()
Creates/adds a new access-token or key to the database.
# Add a new token.
my $AccessToken = $Storage->Create(
Entity => 'AccessToken',
UUID => '...',
Token => '...',
UserID => '...',
UserType => '...',
ExpiresTime => '...',
CreateTime => '...',
LastAccessTime => '...',
);
# Add a new key.
my $Key = $Storage->Create(
Entity => 'Key',
Value => '...',
CreateTime => '...',
);
Returns
# access-token
{
UUID => '...',
Token => '...',
UserID => '...',
UserType => '...',
ExpiresTime => '...',
CreateTime => '...',
LastAccessTime => '...',
};
# key
{
Value => '...',
CreateTime => '...',
};
or C<undef> in case any error occurs.
List()
Get a list of access-tokens or keys records.
my $List = $Storage->List(
Entity => '...',
Filters => {
UUID => '...' # optional
UserID => '...' # optional
UserType => '...' # optional
ExpiresTime => '...' # optional
LastAccessTime => '...' # optional
ExpiresTimeLower => '...' # optional
}
);
Returns
C<undef> - in case any error occurs
[] - in case no data was found for the entity
[
{
UUID => '...',
UserID => '...',
UserType => '...',
CreateTime => '...',
ExpiresTime => '...',
LastAccessTime => '...',
},
...
]
Update()
Update access tokens in the database.
# update create-time of all access tokens.
my $Result = $Storage->Update(Data => {CreateTime => '2018-03-02'});
# update last-access-time and create-time off all the access tokens for user-id X.
my $Result = $Storage->Update(
Filters => {UserID => 'X'},
Data => {LastAccessTime => '2018-03-02', CreateTime => '2018-03-01'}
);
Returns
1 - in case of success.
C<undef> - in case any error occurs.
Count()
Return the number of records that exists in the storage that match the passed filters.
# Get the total of access-tokens.
my $Count = $Storage->Count( Entity => 'AccessToken', );
# Get the total of access-tokens for the user-id X.
my $Count = $Storage->Count( Entity => 'AccessToken', Filters => { UserID => 'X', }, );
Returns
number - in case of success.
C<undef> - in case any error occurs.
Decode()
Decode a jwt-token
.
my $TokenData = $AccessTokenObject->Decode(
Token => '...' # jwt-token
# claims (optional)
VerifyIss => '',
VerifyAud => '',
VerifyExp => 0,
);
Returns
C<undef> - in case any error occurs
hashref - token data
PRIVATE METHODS
_GetDBColumnMapForParams()
Get the mapping of params to database columns.
# mapping for all params
my $Map = $Self->_GetDBColumnMapForParams();
# mapping only for the needed params
my $Map = $Self->_GetDBColumnMapForParams(
Want => [qw( UserType ExpiresTime )],
);
Returns
a map/dictionary with the param and respective column name.