add implicit flow for swagger

This commit is contained in:
Timo Bejan 2024-03-12 16:06:59 +02:00
parent c88c7851f9
commit 77a5b81b2c
2 changed files with 12 additions and 9 deletions

View File

@ -119,16 +119,18 @@ public class SpringDocConfiguration {
private OAuthFlows createOAuthFlows(SpringDocProperties springDocProperties) {
OAuthFlow flow = createAuthorizationCodeFlow(springDocProperties);
return new OAuthFlows().authorizationCode(flow);
}
private OAuthFlow createAuthorizationCodeFlow(SpringDocProperties springDocProperties) {
return new OAuthFlow().authorizationUrl(springDocProperties.getAuthServerUrl() + PROTOCOL_URL_FORMAT + "/auth")
var codeFlow = new OAuthFlow().authorizationUrl(springDocProperties.getAuthServerUrl() + PROTOCOL_URL_FORMAT + "/auth")
.tokenUrl(springDocProperties.getAuthServerUrl() + PROTOCOL_URL_FORMAT + "/token");
var flows = new OAuthFlows().authorizationCode(codeFlow);
if (springDocProperties.isShowImplicitFlow()) {
var implicitFlow = new OAuthFlow().authorizationUrl(springDocProperties.getAuthServerUrl() + PROTOCOL_URL_FORMAT + "/auth")
.tokenUrl(springDocProperties.getAuthServerUrl() + PROTOCOL_URL_FORMAT + "/token");
flows.implicit(implicitFlow);
}
return flows;
}
}

View File

@ -23,6 +23,7 @@ public class SpringDocProperties {
private String title ="Service Open API Documentation";
private String description ="Service Open API Documentation";
private String version = "1.0";
private boolean showImplicitFlow = true;
private List<String> packagesToScan = new ArrayList<>();