feat: Add login endpoint configuration with example values for username and password - #3323
Open
Mattias-Sehlstedt wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds two new configuration properties that let users define example values for the
usernameandpasswordfields of the auto-generated Spring Security login endpoint, so those examples show up in the OpenAPI document and Swagger UI "Try it out" form.New configuration properties
springdoc.login-endpoint.username-exampleusernamefield of the login request body.springdoc.login-endpoint.password-examplepasswordfield of the login request body.Example:
The new
app13tests are copied from the existingapp6tests to showcase the the previous behavior withspringdoc.show-login-endpoint=trueis not affected.Fixes: #3321
An alternative design would be a single boolean flag (e.g. springdoc.login-endpoint.show-credentials=true) that reads the application's actual configured username/password (such as spring.security.user.name / spring.security.user.password) and injects them as examples. That was deliberately not chosen, as a separation of concerns as well as a safety measure.
Documentation examples are a documentation concern; they should not be coupled to, or reach into, security configuration internals. Such a solution could easily result in the user setting the property to true in the root
application.properties, and it thus affecting theprodsettings too. This solution forces the user to specify the exact credentials, which could only do harm if the user has the same credentials intestandprod.