Cortex Servlet Filters
Each API request executes Cortex Servlet Filters before any internal processing.
Sequence of Executing Servlet Filters
The following Servlet Filters are executed in sequence, with the highest rank executing first:
VaryHeaderFilter, Rank 108 ep-commerce
This filter is responsible for returning the Vary: authorization, accept, accept-language, x-ep-account-shared-id, x-ep-user-traits, x-ep-user-id, x-ep-user-roles, x-ep-user-scopes, x-ep-data-policy-segments header value in the response. This header instructs the browser that the response body is influenced by the value of certain request headers. This will ensure that cached requests on the browser will use the specified header values as part of the cache key, so that cached responses aren't returned when these header values change.
The default list of headers returned in the Vary response can be overridden by specifying the cortex.response.header.vary JVM parameter.
ReferrerPolicyHeaderFilter, Rank 105 api-platform
This filter is responsible for returning the Referrer-Policy: no-referrer header value in the response. This header instructs the browser to avoid sending referrer information along with requests from the page.
XXSSProtectionHeaderFilter, Rank 104 api-platform
This filter is responsible for returning the X-XSS-Protection: 0 header value in the response. This header disables the XSS Filter of Internet Explorer 8, which prevents some categories of cross-site-scripting attacks.
ContentSecurityPolicyHeaderFilter, Rank 103 api-platform
This filter is responsible for returning the Content-Security-Policy: default-src 'none' header value in the response. This header instructs the browser to only allow images, scripts, AJAX, and CSS from the same origin and reject any other resources to load (e.g., object, frame, media, etc.).
XContentTypeOptionsHeaderFilter, Rank 102 api-platform
This filter is responsible for returning the X-Content-Type-Options: nosniff header value in the response. This header instructs the browser to always use the MIME type that is declared in the Content-Type header rather than trying to determine the MIME type based on the file's content.
HeadersRemoverFilter, Rank 100 api-platform
This filter is responsible for removing headers from the request that are normally set by the AuthorizationHeaderFilter. The following headers are removed:
x-ep-user-idx-ep-user-rolex-ep-user-rolesx-ep-user-scopex-ep-user-scopesx-ep-user-metadata
If the auth.mode JVM parameter is set to TRUSTED_HEADER, then this filter is disabled.
CustomerCreationFilter, Rank 20 ep-commerce
This filter is responsible for creating a customer record if no customer with a shared ID matching x-ep-user-id can be found in the database.
This filter is only enabled if the auth.mode JVM parameter is set to TRUSTED_HEADER and the COMMERCE/SYSTEM/CUSTOMER/identifier setting is set to GUID or SHARED_ID.
AuthorizationHeaderFilter, Rank 10 api-platform
This filter is responsible for processing the Authorization HTTP header. It interprets it either as an access token or a JWT token, converting it into a DTO object. It updates HTTP request headers so downstream filters can identify the user, role, scope, and other data.
AuthorizationHeaderFilter Workflow
- Read value from the
AuthorizationHTTP header. - Populate
AccessTokenDtoobject either usingTokenStoreStrategy (ep-commerce)orJwtTokenStrategy (api-platform).- Attempts on both strategies occur, and the value of the successful strategy is accepted.
- Mutate the following HTTP request header values using the data from
AccessTokenDto:x-ep-user-idx-ep-user-rolex-ep-user-scopesx-ep-user-metadatax-ep-issuerx-ep-account-shared-id
ConvertUserIdHeaderFilter, Rank 9 ep-commerce
This filter is responsible for converting the value of the x-ep-user-id HTTP header to the user’s GUID. If the client authenticated with a JWT Token or using trusted headers, the x-ep-user-id header value might represent a shared ID or an attribute value. The COMMERCE/SYSTEM/CUSTOMER/identifier setting indicates how the value is interpretted. All downstream filters assume that the x-ep-user-id header value represents the user GUID.
For more information about how to configure COMMERCE/SYSTEM/CUSTOMER/identifier, see Cortex Authentication.
ConvertUserIdHeaderFilter Workflow
- Read values from the
x-ep-user-id,x-ep-user-scopes, andx-ep-issuerHTTP headers. - Use the
x-ep-issuervalue to read the appropriateCOMMERCE/SYSTEM/CUSTOMER/identifiercontext value. - Invoke the appropriate customer identifier strategy to lookup the user record and read the GUID value.
- Mutate the
x-ep-user-idHTTP request header value.
UserIdFallbackFilter, Rank 5 ep-commerce
If the client authenticated with a JWT Token, it can request a single session user rather than a registered user. It does this by leaving the sub field blank instead of specifying a metadata field that contains a JSON blob with details about the user. This filter reads the metadata information and attempts to find a single session user in the database with the specified shared ID. If a record cannot be found, it creates a new single-session user with the specified shared ID.
For more information about the JWT Token format, see JWT Token Authentication.
UserIdFallbackFilter Workflow
- If
x-ep-user-idhas not been specified andx-ep-user-metadatahas been specified:- Use decoded values in
x-ep-user-metadatato find or create a single session user. - Mutate the
x-ep-user-idHTTP request header. - Set the
x-ep-user-rolesHTTP request header toPUBLIC.
- Use decoded values in
ValidateHeadersFilter, Rank 4 ep-commerce
This filter is responsible for ensuring that all required HTTP headers are set properly.
ValidateHeadersFilter Workflow
- Read value from the
x-ep-user-idHTTP header and return401 unauthorizedif missing. - Read value from the
x-ep-user-rolesHTTP header and return401 unauthorizedif missing, contains more than one, or is set to anything other thanPUBLICorREGISTERED. - Read value from the
x-ep-user-scopesHTTP header and return401 unauthorizedif missing or contains more than one.
RoleToPermissionsExpandingFilter, Rank 3 ep-commerce
This filter is responsible for determining what Elastic Path role a user should have, expanding that role
into all associated Shiro roles, and updating the x-ep-user-roles HTTP header.
For more information about roles, see Cortex Authorization.
RoleToPermissionsExpandingFilter Workflow
- Read values from the
x-ep-user-id,x-ep-user-scopes, andx-ep-account-shared-idHTTP headers. - If the account header is set, read the Elastic Path role from the account-user association record.
- If the account header is not set, read the Elastic Path role from the Store record.
- Expand the Elastic Path role into the associated Shiro roles.
- Mutate the
x-ep-user-rolesHTTP request header value.
HeaderToSubjectLifecycleFilter, Rank 2 api-platform
This filter is responsible for taking the user authentication headers from the HTTP request header and
transferring these values into the subjectStorage Thread Local so they can be accessed by Cortex resources.
HeaderToSubjectLifecycleFilter Workflow
- Read values from the
x-ep-user-id,x-ep-user-roles,x-ep-user-scopes, andx-ep-account-shared-idHTTP headers. - Populate the subject in
subjectStorageusing these values.