CheckCredentialEvent
extends GenericHookEvent
in package
CheckCredentialEvent examines a credential and (if it validly represents a user-principal) then it reports the principal.
Table of Contents
Properties
- $credFormat : string
- Ex: 'Basic' or 'Bearer'
- $credValue : string
- $hookFields : array<string|int, mixed>
- $hookFieldsFlip : array<string|int, mixed>
- $hookValues : array<string|int, mixed>
- $principal : array<string|int, mixed>|null
- Authenticated principal.
- $rejection : string|null
- Rejection message - If you know that this credential is intended for your listener, and if it has some problem, then you can
- $requestPath : string
- $BLACKLIST : array<string|int, mixed>
- List of field names that are prohibited due to conflicts in the class-hierarchy.
- $returnValues : mixed
- Some legacy hooks expect listener-functions to return a value.
Methods
- __construct() : mixed
- __get() : mixed
- __isset() : mixed
- __set() : mixed
- __unset() : mixed
- accept() : void
- Accept the sub claim, matching the credentials to a specific user by civicrm contact id ('contactId'), CRM user id ('userId') or CRM username ('user'). This will cause authx to log in that user for the purposes of the current request.
- addReturnValues() : GenericHookEvent
- create() : GenericHookEvent
- Create a GenericHookEvent using key-value pairs.
- createOrdered() : GenericHookEvent
- Create a GenericHookEvent using ordered parameters.
- getHookValues() : array<string|int, mixed>
- getPrincipal() : array<string|int, mixed>|null
- getRejection() : string|null
- getRequestPath() : string
- getReturnValues() : mixed
- hasField() : bool
- Determine whether the hook supports the given field.
- reject() : void
- Emphatically reject the credential.
- assertValidHookFields() : mixed
Properties
$credFormat
Ex: 'Basic' or 'Bearer'
public
string
$credFormat
Tags
$credValue
public
string
$credValue
Tags
$hookFields
protected
array<string|int, mixed>
$hookFields
Ex: array(0 => 'contactID', 1 => 'contentPlacement').
$hookFieldsFlip
protected
array<string|int, mixed>
$hookFieldsFlip
Ex: array('contactID' => 0, 'contentPlacement' => 1).
$hookValues
protected
array<string|int, mixed>
$hookValues
Ex: array(0 => &$contactID, 1 => &$contentPlacement).
$principal
Authenticated principal.
protected
array<string|int, mixed>|null
$principal
= NULL
$rejection
Rejection message - If you know that this credential is intended for your listener, and if it has some problem, then you can
protected
string|null
$rejection
= NULL
$requestPath
protected
string
$requestPath
Ex: 'civicrm/dashboard' or '*'
This identifies the path(s) that the requestor wants to access. For a stateless HTTP request, that's a specific path. For stateful HTTP session or CLI pipe, that's a wildcard.
$BLACKLIST
List of field names that are prohibited due to conflicts in the class-hierarchy.
private
static array<string|int, mixed>
$BLACKLIST
= ['name', 'dispatcher', 'propagationStopped', 'hookBlacklist', 'hookValues', 'hookFields', 'hookFieldsFlip']
$returnValues
Some legacy hooks expect listener-functions to return a value.
private
mixed
$returnValues
= []
OOP listeners may set the $returnValue.
This field is not recommended for use in new hooks. The return-value convention is not portable across different implementations of the hook system. Instead, it's more portable to provide an alterable, named field.
Methods
__construct()
public
__construct(string $cred, string $requestPath) : mixed
Parameters
- $cred : string
-
Ex: 'Basic ABCD1234' or 'Bearer ABCD1234'
- $requestPath : string
-
Ex: 'civicrm/dashboard' or '*'
This identifies the path(s) that the requestor wants to access. For a stateless HTTP request, that's a specific path. For stateful HTTP session or CLI pipe, that's a wildcard.
__get()
public
& __get(mixed $name) : mixed
Parameters
- $name : mixed
Tags
__isset()
public
__isset(mixed $name) : mixed
Parameters
- $name : mixed
Tags
__set()
public
__set(mixed $name, mixed $value) : mixed
Parameters
- $name : mixed
- $value : mixed
Tags
__unset()
public
__unset(mixed $name) : mixed
Parameters
- $name : mixed
Tags
accept()
Accept the sub claim, matching the credentials to a specific user by civicrm contact id ('contactId'), CRM user id ('userId') or CRM username ('user'). This will cause authx to log in that user for the purposes of the current request.
public
accept(array<string|int, mixed> $principal) : void
The $principal must a mix of of 'user', 'userId', 'contactId' and 'credType':
-
'credType': (string) type of credential used to identify the principal. ('pass', 'api_key', 'jwt')
-
'contactId': (Authenticated) CiviCRM contact ID. If not specified, will be obtained from 'userId'.
-
'userId': (Authenticated) UF user ID. If not specified, will be obtained from 'user' or 'contactId'.
-
'user': (string). The username of the CMS user. Can be used instead of 'userId'.
-
'jwt': (Authenticated, Decoded) JWT claims (if applicable)
Note: Event propogation will stop after this, so subscribers with lower priorities will not be able to reject it.
Parameters
- $principal : array<string|int, mixed>
-
Must include credType and (contactId or (userId xor user))
addReturnValues()
public
addReturnValues(mixed $fResult) : GenericHookEvent
Parameters
- $fResult : mixed
Return values
GenericHookEventcreate()
Create a GenericHookEvent using key-value pairs.
public
static create(array<string|int, mixed> $params) : GenericHookEvent
Parameters
- $params : array<string|int, mixed>
-
Ex: array('contactID' => &$contactID, 'contentPlacement' => &$contentPlacement).
Return values
GenericHookEventcreateOrdered()
Create a GenericHookEvent using ordered parameters.
public
static createOrdered(array<string|int, mixed> $hookFields, array<string|int, mixed> $hookValues) : GenericHookEvent
Parameters
- $hookFields : array<string|int, mixed>
-
Ex: array(0 => 'contactID', 1 => 'contentPlacement').
- $hookValues : array<string|int, mixed>
-
Ex: array(0 => &$contactID, 1 => &$contentPlacement).
Return values
GenericHookEventgetHookValues()
public
getHookValues() : array<string|int, mixed>
Return values
array<string|int, mixed> —Ex: array(0 => &$contactID, 1 => &$contentPlacement).
getPrincipal()
public
getPrincipal() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|nullgetRejection()
public
getRejection() : string|null
Return values
string|nullgetRequestPath()
public
getRequestPath() : string
Return values
string —Ex: 'civicrm/dashboard'
getReturnValues()
public
getReturnValues() : mixed
hasField()
Determine whether the hook supports the given field.
public
hasField(string $name) : bool
The field may or may not be empty. Use isset() or empty() to check that.
Parameters
- $name : string
Return values
boolreject()
Emphatically reject the credential.
public
reject(string $message) : void
If you know that the credential is targeted at your provider, and if there is an error in it, then you may set a rejection message. This will can provide more detailed debug information. However, it will preclude other listeners from accepting the credential.
Parameters
- $message : string
assertValidHookFields()
private
static assertValidHookFields(array<string|int, mixed> $fields) : mixed
Parameters
- $fields : array<string|int, mixed>
-
List of field names.