Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Merged
merged 3 commits into from
Jan 8, 2022
Merged

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

merged 3 commits into from
Jan 8, 2022

Conversation

dotpredicate
Copy link

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 /# 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/# 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 /# path
@bnasslahsen
Copy link
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

@lipniak Can support webflux?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants