Skip to content
Kelvin Mo edited this page Jul 31, 2021 · 3 revisions

Events (SimpleID 2)

In SimpleID 2, hooks are migrated to PSR-14 events.

Description of events

acr

Event class: SimpleID\Util\Events\BaseDataCollectionEvent

Event to collect an authentication context class reference the authentication scheme module implemented in relation to the current user.

SimpleID\Auth\AutoAutoEvent

Event class: SimpleID\Auth\AutoAutoEvent

Event to attempt to automatically login using credentials presented by the user agent.

See the source code documentation of this class for further information on this event.

SimpleID\Protocols\Connect\ConnectClaimsBuildEvent

Event class: SimpleID\Protocols\Connect\ConnectClaimsBuildEvent

Event to collect a set of claims to be included in an ID token or UserInfo response.

See the source code documentation of this class for further information on this event.

connect_configuration

Event class: SimpleID\Util\Events\BaseDataCollectionEvent

Event to collect additional OpenID Connect configuration parameters. These are used in the OpenID Provider Configuration endpoint.

consent_revoke

Event class: SimpleID\Models\ConsentEvent

Invoked when authorisation given to client app is revoked from the user's app page.

dashboard_blocks

Event class: SimpleID\Util\Events\UIBuildEvent

Event to collect additional blocks to be displayed in the user's dashboard

A block is coded as an array in accordance with the specifications set out in MyModule.

SimpleID\Base\IndexEvent

Event class: SimpleID\Base\IndexEvent

An event requesting processing of the root route (i.e. /).

See the source code documentation of this class for further information on this event.

SimpleID\Auth\LoginEvent

Event class: SimpleID\Auth\LoginEvent

An event to log in a user.

See the source code documentation of this class for further information on this event.

login_form_build

Event class: SimpleID\Forms\FormBuildEvent

Provides additional form items when displaying the login form.

The state of the form (which can be obtained by calling getFormState() in the event object) is an array which, at a minimum, contains the following elements:

  • mode the authentication mode

Other modules may insert additional elements into the array.

login_form_cancel

Event class: SimpleID\Forms\FormSubmitEvent

Processes a login form where the user has requested to cancel the login. Typically this involves creating a cancel message and sending it back to the requesting party (through a redirect or otherwise).

The form state contains the same elements as per the login_form_build event.

If the cancellation is processed successfully, listeners should call the stopPropagation() method on the event object to prevent further processing.

login_form_submit

Event class: SimpleID\Forms\LoginFormSubmitEvent

Processes a login form.

Typically listeners will verify the set of credentials supplied by the login form for a specified user.

Listeners should use the Fat-Free Framework's Base::get() function to access data submitted by the user in the form.

The form state contains the same elements as per the login_form_build event.

This function should do one of the following:

  • if the user should not be logged in (e.g. because the supplied credentials do not match), it should call the setInvalid() method of the event object
  • if the credentials match, call the addAuthModuleName() method of the event object to pass on the name of the authentication module, and do one or more of the following:
    • call the setUser() method to set the user whose credentials are matching
    • call the setAuthLevel() method to set the authentication level supported by this module

login_form_validate

Event class: SimpleID\Forms\FormSubmitEvent

Validates a login form.

Listeners should use the Fat-Free Framework's Base::get() function to access data submitted by the user in the form.

The form state contains the same elements as per the login_form_build event.

While the FormSubmitEvent is stoppable, listeners should not call the stopPropagation() method. This is because a better user experience is provided if all the validation errors are displayed at once.

SimpleID\Auth\LogoutEvent

Event class: SimpleID\Auth\LogoutEvent

An event to log out a user.

See the source code documentation of this class for further information on this event.

nav

Event class: SimpleID\Util\Events\BaseDataCollectionEvent

Event to collect navigation menu items.

SimpleID\Protocols\OAuth\OAuthAuthGrantEvent

Event class: SimpleID\Protocols\OAuth\OAuthAuthGrantEvent

An event triggered when an authorisation request has been granted.

See the source code documentation of this class for further information on this event.

oauth_auth_check

Event class: SimpleID\Protocols\OAuth\OAuthEvent

Checks an OAuth authorisation request for protocol compliance.

Listeners can use getRequest() and getResponse() to obtain the request and response respectively and modify them, generate errors, etc.

oauth_auth_resolve

Event class: SimpleID\Protocols\OAuth\OAuthEvent

Resolves an OAuth authorisation request.

Under certain OAuth-based protocols, the authorisation request may contain parameters which require resolution before the request can be processed further. For example, under OpenID Connect, the request_uri parameter will require a query to obtain the request object

Listeners can use getRequest() and getResponse() to obtain the request and response respectively and modify them, generate errors, etc.

oauth_consent_form_build

Event class: SimpleID\Forms\FormBuildEvent

Provides additional form items when displaying the OAuth authorisation request form

The state of the form (which can be obtained by calling getFormState() in the event object) is an array which, at a minimum, contains the request and response (which can be obtained from the getRequest() and getResponse() methods).

oauth_consent_form_submit

Event class: SimpleID\Forms\FormSubmitEvent

Processes the OAuth authorisation request consent form.

The form state contains the same elements as per the oauth_consent_form_build event.

SimpleID\Protocols\OAuth\OAuthInitClientEvent

Event class: SimpleID\Protocols\OAuth\OAuthInitClientEvent

An event to authenticate an OAuth client.

See the source code documentation of this class for further information on this event.

SimpleID\Protocols\OAuth\OAuthInitTokenEvent

Event class: SimpleID\Protocols\OAuth\OAuthInitTokenEvent

An event to authenticate an access token.

See the source code documentation of this class for further information on this event.

SimpleID\Protocols\OAuth\OAuthProcessAuthRequestEvent

Event class: SimpleID\Protocols\OAuth\OAuthProcessAuthRequestEvent

An event to process an OAuth authorisation request to determine whether the user has granted access.

See the source code documentation of this class for further information on this event.

oauth_response_types

Event class: SimpleID\Util\Events\BaseDataCollectionEvent

Event to collect the OAuth response types available.

SimpleID\Protocols\OAuth\OAuthTokenGrantEvent

Event class: SimpleID\Protocols\OAuth\OAuthTokenGrantEvent

An event triggered when an access token is being issued.

See the source code documentation of this class for further information on this event.

SimpleID\Protocols\OpenID\OpenIDCheckEvent

Event class: SimpleID\Protocols\OpenID\OpenIDCheckEvent

An event to process an OpenID authentication request.

See the source code documentation of this class for further information on this event.

openid_consent_form_build

Event class: SimpleID\Forms\FormBuildEvent

Provides additional form items when displaying the relying party consent form.

The state of the form (which can be obtained by calling getFormState() in the event object) is an array which, at a minimum, contains the following elements:

  • the request and response (which can be obtained from the getRequest() and getResponse() methods on the form state object)
  • prefs the user preferences for this relying party

openid_consent_form_submit

Event class: SimpleID\Forms\FormSubmitEvent

Processes the relying party consent form.

This provides listeners with the opportunity to modify the OpenID response or the change the user's preferences by editing the form state.

The form state contains the same elements as per the openid_consent_form_build event.

SimpleID\Protocols\OpenID\OpenIDResponseBuildEvent

Event class: SimpleID\Protocols\OpenID\OpenIDResponseBuildEvent

An event to allow modification of an OpenID response.

See the source code documentation of this class for further information on this event.

post_init

Event class: SimpleID\Util\Events\BaseStoppableEvent

Event triggered to perform initialisation functions which can only be done after all modules have been loaded.

This hook is not invoked during the upgrade process.

post_logout

Event class: SimpleID\Util\Events\BaseStoppableEvent

Provides additional user interface actions after a user has been logged out. User interface actions can include redirecting to a different URI, or displaying another form.

Note that this hook is invoked only if the log out is initiated by the user. It is not invoked if the user is logged out automatically.

The hook is responsible for all aspects of the rendering of the user interface.

profile_blocks

Event class: SimpleID\Util\Events\UIBuildEvent

Event to collect additional blocks to be displayed in the user's profile page

A block is coded as an array in accordance with the specifications set out in MyModule.

SimpleID\Protocols\ScopeInfoCollectionEvent

Event class: SimpleID\Protocols\ScopeInfoCollectionEvent

An event to collect scope information.

See the source code documentation of this class for further information on this event.

upgrade_list

Event class: SimpleID\Util\Events\BaseDataCollectionEvent

Event to collect a list of upgrade functions.

The list should be set out as an array, with the keys being the version to be upgraded, and the value being another array of function names to be called as part of the upgrade.

If the current version of SimpleID is older than the version the version specified in the keys, then the functions in the value will be called.

The results added by listeners should be an array, with the keys being the version number and the value being an array of upgrade functions.

user_secret_data_paths

Event class: SimpleID\Util\Events\BaseDataCollectionEvent

Event to collect a list data paths from the User object that should be hidden from view.

Data paths should be in a format that is parsable by SimpleID\Util\ArrayWrapper::pathSet().

Appendix - Migration of SimpleID hooks to events

The following tables set out the mapping between the hooks defined in the old hook system and their replacement events.

AuthHooks

Hook Name Event name
acr acr
autoAuth SimpleID\Auth\AutoAuthEvent
login SimpleID\Auth\LoginEvent
loginForm login_form_build
loginFormCancelled login_form_cancel
loginFormSubmit login_form_submit
loginFormValidate login_form_validate
logoutComplete post_logout
logout SimpleID\Auth\LogoutEvent
secretUserDataPaths user_secret_data_paths

ConnectHooks

Hook Name Event name
connectBuildClaims SimpleID\Protocols\Connect\ConnectClaimsBuildEvent
connectConfiguration connect_configuration

IndexHooks

Hook Name Event name
index SimpleID\Base\IndexEvent

ModuleHooks

Hook Name Event name
init post_init
upgradeList upgrade_list

MyHooks

Hook Name Event name
dashboardBlocks dashboard_blocks
nav nav
profileBlocks profile_blocks
revokeApp consent_revoke

OAuthHooks

Hook Name Event name
oAuthConsentForm oauth_consent_form_build
oAuthConsentFormSubmit oauth_consent_form_submit
oAuthGrantAuth SimpleID\Protocols\OAuth\OAuthAuthGrantEvent
oAuthInitAccessToken SimpleID\Protocols\OAuth\OAuthInitTokenEvent
oAuthInitClient SimpleID\Protocols\OAuth\OAuthInitClientEvent
oAuthResolveAuthRequest oauth_auth_resolve
oAuthCheckAuthRequest oauth_auth_check
oAuthProcessAuthRequest SimpleID\Protocols\OAuth\OAuthProcessAuthRequestEvent
oAuthResponseTypes oauth_response_types
oAuthToken SimpleID\Protocols\OAuth\OAuthTokenGrantEvent
scopes SimpleID\Protocols\ScopeInfoCollectionEvent

OpenIDHooks

Hook Name Event name
openIDCheckExtension SimpleID\Protocols\OpenID\OpenIDCheckEvent
openIDCheckIdentity SimpleID\Protocols\OpenID\OpenIDCheckEvent
openIDConsentForm openid_consent_form_build
openIDConsentFormSubmit openid_consent_form_submit
openIDResponse SimpleID\Protocols\OpenID\OpenIDResponseBuildEvent
xrdsTypes xrds_types