-
Notifications
You must be signed in to change notification settings - Fork 764
Added support different servlet root paths for the Authn RequestFilter #1033
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
One problem I spot is that the filter will now also trigger on an URL such as "/somethingelse/authorize". |
@praseodym but that's the purpose of the change: make this filter to capture authentication requests when the openid connect APIs are located on a sub context such as: "/oidc/authorize". If the intention was to guarantee that "/authorize" is always at the start of the request even when there's is sub context present; I could modify the validation code to something like:
Now when the pathInfo is not null, it has to be exactly "/authorize", this will be fully compatible with the original implementation. |
I see the reason behind the change, but it will break existing deployments. I think it would be best to do exact matching instead (i.e. |
I see. I updated the code accordingly. |
Just making sure I follow: the purpose of this change is to let you alter the paths of the server without changing the overall |
@jricher no, we are also chaning the issuer; as you said we also though that by changing the issuer to something like: "http://app.domain/appname/oidc/", everything will work transparently however that is not the case for the requests with optional parameters options covered by this filter, namely: prompt and max_age. |
Interesting, because that really should be the case here. The development setup uses a path component as part of the issuer and this filter definitely fires in those cases, so I'll look into it to see what's going on there. |
I can't replicate this behavior. In my test environment, we deploy to When deployed as What am I missing? |
Rather than changing the root context name, we are registering the dispatcher for the oidc APIs under the subcontext As a simple test you could modify the
and then try any authn request using the new pattern, e.g: You will see that the call will be handled normally, however the AuthorizationRequestFilter will skip it since the servlet path no longer starts with "/authorize" |
Interesting, that's definitely an off-label use and I can see why the filter would fail. The real question is why the |
My guess is that the spring library uses pattern matching instead of exact matching to cover these subtleties. WEB-INF/application-context.xml
AuthorizationRequestFilter: @Autowired(required = false)
private LoginHintExtracter loginHintExtracter = new RemoveLoginHintsWithHTTP();
@Autowired
private RequestMatcher authRequestMatcher;
@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) req;
HttpServletResponse response = (HttpServletResponse) res;
HttpSession session = request.getSession();
// skip everything that's not an authorize URL
if (!authRequestMatcher.matches(request)) {
chain.doFilter(req, res);
return;
}
...
} This shouldn't break any existing code and the deployer will have the flexibility to change the pattern if needed without having to patch the code. Thank you for your time |
I like that approach much better, and I'll put that in this morning. Looking through the Spring methods for |
The current AuthorizationRequestFilter assumes the APIs are always at the application root context: ("/authorize")
In our use case, since we have to support other authentication protocols (such as SAML); the openid connect APIs are under the sub servlet context "/oidc" therefore the authorize url will be "/oidc/authorize" for our application. Because of this change, the current version of the filter never
captures
authentication request, so any authentication request containing prompt are max_age do not work.This simple pull request changes that validation and includes the unit tests for such cases.
Notes:
javax.servlet:javax.servlet-api:3.0.1
was added to be able to use the class MockHttpServletRequest in the unit test.Thanks