public interface StaleStateProtectionService
StaleStateServiceException
, which will result in a Http Status code 409 error response.
Examples of key state changes in the admin include:
stale.state.protection.enabled = true
Second, the applicationContext-admin-security.xml file should be checked for the appropriate filter configuration:
...
<sec:custom-filter ref="blPreSecurityFilterChain" before="CHANNEL_FILTER"/>
<sec:custom-filter ref="blSecurityFilter" before="FORM_LOGIN_FILTER"/>
<sec:custom-filter ref="blAdminFilterSecurityInterceptor" after="EXCEPTION_TRANSLATION_FILTER"/>
<sec:custom-filter ref="blPostSecurityFilterChain" after="SWITCH_USER_FILTER"/>
</sec:http>
<bean id="blSecurityFilter" class="org.broadleafcommerce.openadmin.web.filter.AdminSecurityFilter" />
...
Specifically, the "blSecurityFilter" bean and its custom-filter reference config are key here. Note, if present,
the "blCsrfFilter" should be replaced with this config, as "blSecurityFilter" encompasses both CSRF protection, as well
as the stale state protection described here.
Finally, the mechanism of protection is provided by utilizing a state version token. The token is included in the body
of each page and represents the current session state for the user. When a key state change event takes place, the state
version token is updated in the user session on the server. When the system detects a mismatch between the token provided
by a request and the token that exists in the session, the system will emit a StaleStateServiceException
.Modifier and Type | Method and Description |
---|---|
void |
compareToken(String passedToken)
Compare the state version token provided by the request to what is resident in the user session.
|
String |
getStateVersionToken()
Retrieve the state version token resident in the user's session, or create one if it doesn't exist.
|
String |
getStateVersionTokenParameter()
Retrieve the parameter key used to harvest the state version token value from the request
|
void |
invalidateState()
Remove the current state version token in the user's session, if exists.
|
void |
invalidateState(boolean notify)
Remove the current state version token in the user's session, if exists.
|
boolean |
isEnabled()
Whether or not the protection provided by this service is active.
|
boolean |
sendRedirectOnStateChange(javax.servlet.http.HttpServletResponse response,
String... stateChangeParams)
Utility method to send a redirect for the current url with state change params cleared.
|
void compareToken(String passedToken)
StaleStateServiceException
is emitted.passedToken
- the state version token from the requestString getStateVersionToken()
void invalidateState()
void invalidateState(boolean notify)
notify
- Whether or not the request should be notified that state was invalidated. See sendRedirectOnStateChange(HttpServletResponse, String...)
.boolean isEnabled()
String getStateVersionTokenParameter()
boolean sendRedirectOnStateChange(javax.servlet.http.HttpServletResponse response, String... stateChangeParams) throws IOException
response
- the current http responsestateChangeParams
- any request parameter names being used by the system to drive state changeinvalidateState()
IOException
Copyright © 2022. All rights reserved.