The augmentSecurityContext trigger
The augmentSecurityContext trigger, defined in the authentication configuration, can reference a script that is executed after successful authentication. These scripts can populate the security context of the authenticated user. If the authenticated user is not found in the resource specified by queryOnResource, the augmentSecurityContext can provide the required authorization map.
These scripts have access to the following bindings:
-
security- includes theauthenticationIdand theauthorizationkey, which includes themoduleId.The main purpose of an
augmentSecurityContextscript is to modify theauthorizationmap that is part of thissecuritybinding. The authentication module determines the value of theauthenticationId, and IDM attempts to populate theauthorizationmap with the details that it finds, related to thatauthenticationIdvalue. These details include the following:-
security.authorization.component- the resource that contains the account (by default, this will always be the same as the value ofqueryOnResource). -
security.authorization.id- the internal_idvalue that is associated with the account. -
security.authorization.roles- any roles that were determined, either from reading theuserRolesproperty of the account or from calculation. -
security.authorization.moduleId- the authentication module responsible for performing the original authentication.
You can use the
augmentSecurityContextscript to change any of theseauthorizationvalues. The script can also add new values to theauthorizationmap, which will be available for the lifetime of the session. -
-
properties- corresponds to thepropertiesmap of the related authentication module. -
httpRequest- a reference to theRequestobject that was responsible for handling the incoming HTTP request.This binding is useful to the augment script because it has access to all of the raw details from the HTTP request, such as the headers. The following code snippet shows how you can access a header using the
httpRequestbinding. This example accesses theauthTokenrequest header:httpRequest.getHeaders().getFirst('authToken').toString()
For more information, refer to Roles, authentication, and the Security Context.