Description | manuals and libraries |
Kernel::System::Credential::OAuth2 - OAuth2 Credential
This class takes care about handling OAuth2 web tokens.
my $OAuth2 = Kernel::System::Credential::OAuth2->new(
ID => 123, # optional, the database identifier
Name => 'MyCredentialEntry', # required, the name of the credential entry
ValidID => 1, # required, the valid identifier
CreateTime => '2021-09-09 08:00:00', # optional, timestamp of the create time (now if not provided)
CreateBy => 123, # optional, UserID of the creator (1 if not given)
ChangeTime => '2021-09-09 08:00:00', # optional, timestamp of the last change time (now if not provided)
ChangeBy => 123, # optional, UserID of the last modifier (1 if not given)
Config => {
AuthURL => 'https://auth.resourceowner.com/auth', # optional, the URL to start the auth process
RedirectURL => 'https://mydomain.com/oauth-callback', # optional, the redirect URL after the auth process.
Tenant => 'abc123', # optional, the tenant for the service provider.
ClientID => 'superuser', # optional, the client id of the resource owner.
ClientSecret => 'topsecret', # optional, the client secret of the resource owner.
Scope => 'the_whole_world', # optional, the scope of the permission grant.
},
);
# redirect the consumer to start an authorization process with maybe a needed consent.
$Controller->redirect_to( $OAuth2->AuthURL() );
# Get or refresh access token / refresh token from resource owner.
$OAuth2->Refresh( Code => $AuthorizationCodeFromResourceOwner );
The authentication URL, that is used to start the authentication process.
The address the resource owner redirects to, after successful consent and/or authentication.
The tenant to be used for authentication.
The client id to be used for authentication.
The client secret to be used for authentication.
The scope to request permissions for (multiple scores are separated by spaces).
The access token, that is used for authentication.
Verifies if the related access token is present, valid and in a usable state.
my $State = $AuthCredential->Verify();
Returns
{
State => 'OK' # String representation of the state
UpdateNeeded => 0, # Indicator for a needed token update
ValidUntil => '2021-09-01 18:15:35',
}
Checks if the access token can be refreshed.
Performs needed operations to refresh the access token data.
Returns the bearer format of the token.
Returns an XOAuth2 compliant authentication signature.
Returns or sets the authorization url.