Skip to content

Not all ouath endpoints generated in Swagger #327

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

Closed
Marx2 opened this issue Jan 7, 2020 · 6 comments
Closed

Not all ouath endpoints generated in Swagger #327

Marx2 opened this issue Jan 7, 2020 · 6 comments
Labels
enhancement New feature or request

Comments

@Marx2
Copy link

Marx2 commented Jan 7, 2020

I have Oauth configuration like this:

public static final String OAUTH_PATH = "/oauth/token";

openAPI.addSecurityItem(new SecurityRequirement().addList(SECURITY_SCHEMA_OAUTH2, Collections.emptyList()))
       .components(
		       new Components()
				       .addSecuritySchemes(SECURITY_SCHEMA_OAUTH2,
				                           new SecurityScheme()
						                           .type(SecurityScheme.Type.OAUTH2)
						                           .bearerFormat(BEARER_FORMAT)
						                           .flows(new OAuthFlows()
								                                  .password(new OAuthFlow()
										                                            .refreshUrl(OAUTH_PATH)
										                                            .tokenUrl(OAUTH_PATH)
										                                            .scopes(new Scopes())))));


However generated documentation have only:
auth-controller
/whoAmI
/oauth/token/revokeById/{tokenId}
/tokens/revokeRefreshToken/{tokenId}

I miss /oauth/token endpoint, which is used to generate and refresh tokens.
Of course oauth flow is working ok

@bnasslahsen
Copy link
Collaborator

Hi @Marx2,

For the code you mention, only the following will should filled.
tokenUrl":"/oauth/token","refreshUrl":"/oauth/token"
If you have addtional enpoint that you need to display on the ui, you need to add the springdoc-openapi-ui dependency to your autorisation-server as well.
Or you on your other apps, you can reference them as external APIs (that should be reachable without authentication), using :

SwaggerUiConfigProperties.addGroup("myOauthserver", "http://localhost:8080/v3/api-docs");

@Marx2
Copy link
Author

Marx2 commented Jan 8, 2020

The problem is that "/oauth/token" endpoint is NOT visible in Swagger documentation.
My service is client and server at the same time, so it should list all endpoints for oauth, and the most important is "/oauth/token", which is not displayed. I'm attaching screenshot of generated documentation, "/oauth/token" is missing:

image

I think task should be reopened

@kdanko
Copy link

kdanko commented Jan 11, 2020

I observe same issue when adding swagger UI to authorization server - all default endpoints, provided by spring-security-oauth2 authorization server are not displayed in Swagger UI, only custom controllers are displayed. This issue does not exist when using old Springfox Swagger library.

@bnasslahsen bnasslahsen reopened this Jan 11, 2020
@bnasslahsen
Copy link
Collaborator

bnasslahsen commented Jan 11, 2020

Hi @kdanko and @Marx2 ,

We will add introduce the support of spring-security-oauth2 authorization server, in the next release v1.2.27:
You can have a look at snapshot and test it in advance.
Make sure you reference also:

 <dependency>
      <groupId>org.springdoc</groupId>
      <artifactId>springdoc-openapi-security</artifactId>
      <version>1.2.27</version>
   </dependency>

@Marx2
Copy link
Author

Marx2 commented Jan 13, 2020

I have some problem referencing snapshots:
[ERROR] Failed to execute goal on project (...) Failed to collect dependencies at org.springdoc:springdoc-openapi-security:jar:1.2.27: Failed to read artifact descriptor for org.springdoc:springdoc-openapi-security:jar:1.2.27: Could not transfer artifact org.springdoc:springdoc-openapi-security:pom:1.2.27 from/to jcenter-snapshots (http://oss.jfrog.org/artifactory/oss-snapshot-local/): Transfer failed for http://oss.jfrog.org/artifactory/oss-snapshot-local/org/springdoc/springdoc-openapi-security/1.2.27/springdoc-openapi-security-1.2.27.pom 409 -> [Help 1]

@kdanko
Copy link

kdanko commented Jan 22, 2020

It works now with 1.2.27 version. Thank you!

@bnasslahsen bnasslahsen added the enhancement New feature or request label Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants