Skip to content

springdoc-openapi-security: support custom login processing endpoints#1430

Merged
bnasslahsen merged 3 commits intospringdoc:masterfrom
dotpredicate:security-add-custom-paths
Jan 8, 2022
Merged

springdoc-openapi-security: support custom login processing endpoints#1430
bnasslahsen merged 3 commits intospringdoc:masterfrom
dotpredicate:security-add-custom-paths

Conversation

@dotpredicate
Copy link
Copy Markdown

My application uses a reverse proxy with only /api/** routes being available to the Spring server. Unfortunately, the login processing endpoint path in springdoc-openapi-security currently is fixed to /login so I had to make some changes in the code.
The new code uses the requiresAuthenticationRequestMatcher field of usernamePasswordAuthenticationFilter (it's private on AbstractAuthenticationProcessingFilter with no getter so we need to use the Reflection API) to find the login processing endpoint path.
I supported only AntPathRequestMatcher matchers because it is used by all default Spring Security filters when configuring with HttpSecurity. This should cover most use cases.
I also have added a test app8 that verifies if a login processing URL set as /api/login is properly reflected in API schema.

predicate@bonzo added 3 commits January 7, 2022 13:52
* access AbstractAuthenticationProcessingFilter class directly instead
of calling getSuperclass()
* catch ClassCastException for matchers that are not
instances of AntPathRequestMatcher
* ignore authentication filters that produce errors (such as wrong login
endpoints) instead of assuming /login path
@bnasslahsen
Copy link
Copy Markdown
Collaborator

Thank you @lipniak for your contribution!

@bnasslahsen bnasslahsen merged commit 46483c9 into springdoc:master Jan 8, 2022
@dotpredicate dotpredicate deleted the security-add-custom-paths branch January 8, 2022 13:16
@ABoat365
Copy link
Copy Markdown

@lipniak Can support webflux?

mpleine pushed a commit to mpleine/springdoc-openapi that referenced this pull request May 17, 2025
springdoc-openapi-security: support custom login processing endpoints
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants