question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding /login endpoint to documentation

See original GitHub issue

Hi.

I added Swagger and it generated my docs correctly. But I have /login endpoint which I want to document as well. It is the Spring Security default endpoint that means I don’t have any controller in my package for it.

I am looking for solution for 2 days without success. I actually find this http://springfox.github.io/springfox/docs/current/#example-apilistingscannerplugin but it doesn’t work as expected.

Problems:

  1. How to replace “default” as controller name to something else?

  2. How to filter out error controller. Before implementing above plugin, following solution worked well.

new Docket()........paths(paths())

...

    private Predicate<String> paths() {
        return or(
                regex("/login.*"),
                regex("/product.*"),
                regex("/group.*"),
                regex("/order.*"),
//                regex("/cart.*"),
//                regex("/springsRestController.*"),
                regex("/cart.*"));
    }


Check attached image and you will understand my problems.

Any hint, suggestion or solution?

Thanks for help. screenshot_2017_06_29_12_49_45

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:15 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
simplyicommented, Dec 18, 2018

@dilipkrish do you know any documentation or example that demonstrates how to use SpringFox to document the /login url provided by Spring Security?

I use Spring Boot with Spring Security and all my RESTful Web Service endpoints required an Authorization header(JWT) to be provided. To get the Authorization header value(JWT), user first needs to login. The /login is provided by Spring Security. Once user successfully logs in, Authorization header will be returned. So my Swagger UI Documentation needs to document the /login URL which is provided by Spring Security. I cannot find any documentation on how to document the provided by Spring Security /login endpoint.

Are you aware of any? Can you advise?

The only solution I was able to use these days is to simply create my own /login endpoint and provide SpringFox annotations for it do document Request and Response details. And when Swagger UI is used to send a /login request, Spring Security overrides the request and it works. Which is great. So my own /login endpoint is a kind of Fake login which only serves the documentation purpose. Since Spring Security overwrites it, the code inside of my own, fake /login never gets triggered, which is great and which is what I want. But I wondered how it is properly done with SpringFox? How to use SpringFox to document the /login Web Service Endpoint provided by Spring Security?

2reactions
FlasH-RUScommented, Mar 15, 2019

@simplyi, we’ve just had the same requirement to document Spring’s /oauth/* endpoints. Eventually a custom ApiListingScannerPlugin plugin worked as in the example - just added the @Component and @Order(SwaggerPluginSupport.SWAGGER_PLUGIN_ORDER). Note that the group you provide to ApiDescription is NOT the group from your Docket (i.e. it’s not the one in drop-down at right top page corner), so by default your ApiDescriptions will appead in every Docket you have under “defaut” section.

In order to change the section name you need to provide a tag (surprise, surprise!) for OperationBuilder inside your ApiDescription. And I don’t know what ApiDescription group is then…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Login endpoint - Amazon Cognito - AWS Documentation
The /login endpoint signs the user in. It loads the login page and presents the authentication options configured for the client to the...
Read more >
SpringFox and Swagger UI - How to document the /login ...
I use Spring Security and the /login endpoint accepts: email and password for user to be able to login. How can I add...
Read more >
Add Login Using the Authorization Code Flow - Auth0
Learn how to add login to your regular web application using the Authorization Code Flow.
Read more >
Access and authentication for the REST API
To generate a token from the /jwt/login endpoint ; authString, <authentication string> ; Content-type, application/x-www-form-urlencoded ...
Read more >
Authentication - Swagger
After you have defined the security schemes in the securitySchemes section, you can apply them to the whole API or individual operations by...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found