Preauthentication via headers filters - Clear security context if preauth headers changed across queries #34
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a change needed specifically when using the georchestra gateway. See georchestra/georchestra-gateway#14 for the context.
I suspect that we don't encounter the same issue when running behind the security-proxy because in the case of the SP, the JSESSIONID are kept server-side and managed by the SP, and the security context geoserver-side is reloaded at each request depending on its value. When behind the gateway, the cookies are sent to the browser, so once we obtain a admin session, we keep it as long as we have the cookie.
In any way, clearing the context in both following cases:
should address the issue, but I am not a security expert.
Thanks @groldan for the hints ; a similar mechanism already exists on geoserver-cloud here and was mainly the inspiration for this one:
https://github.com/geoserver/geoserver-cloud/blob/main/src/starters/security/src/main/java/org/geoserver/cloud/security/gateway/GatewayPreAuthenticationFilter.java#L42
Tests: