add support for OIDC authentication to Swagger API
This commit is contained in:
parent
b2d6f75964
commit
56920149bc
|
@ -262,6 +262,13 @@ public class OpenApiInterceptor {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (resourcePath.endsWith(".html")) {
|
||||||
|
theResponse.setContentType(Constants.CT_HTML);
|
||||||
|
theResponse.setStatus(200);
|
||||||
|
IOUtils.copy(resource, theResponse.getOutputStream());
|
||||||
|
theResponse.getOutputStream().close();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -336,12 +343,18 @@ public class OpenApiInterceptor {
|
||||||
String page = extractPageName(theRequestDetails, PAGE_SYSTEM);
|
String page = extractPageName(theRequestDetails, PAGE_SYSTEM);
|
||||||
context.setVariable("PAGE", page);
|
context.setVariable("PAGE", page);
|
||||||
|
|
||||||
|
populateOIDCVariables(context);
|
||||||
|
|
||||||
String outcome = myTemplateEngine.process("index.html", context);
|
String outcome = myTemplateEngine.process("index.html", context);
|
||||||
|
|
||||||
theResponse.getWriter().write(outcome);
|
theResponse.getWriter().write(outcome);
|
||||||
theResponse.getWriter().close();
|
theResponse.getWriter().close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void populateOIDCVariables(WebContext context) {
|
||||||
|
context.setVariable("OAUTH2_REDIRECT_URL_PROPERTY", "");
|
||||||
|
}
|
||||||
|
|
||||||
private String extractPageName(ServletRequestDetails theRequestDetails, String theDefault) {
|
private String extractPageName(ServletRequestDetails theRequestDetails, String theDefault) {
|
||||||
String[] pageValues = theRequestDetails.getParameters().get("page");
|
String[] pageValues = theRequestDetails.getParameters().get("page");
|
||||||
String page = null;
|
String page = null;
|
||||||
|
@ -354,7 +367,7 @@ public class OpenApiInterceptor {
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
|
|
||||||
private OpenAPI generateOpenApi(ServletRequestDetails theRequestDetails) {
|
protected OpenAPI generateOpenApi(ServletRequestDetails theRequestDetails) {
|
||||||
String page = extractPageName(theRequestDetails, null);
|
String page = extractPageName(theRequestDetails, null);
|
||||||
|
|
||||||
CapabilityStatement cs = getCapabilityStatement(theRequestDetails);
|
CapabilityStatement cs = getCapabilityStatement(theRequestDetails);
|
||||||
|
|
|
@ -18,7 +18,7 @@ body
|
||||||
background: #fafafa;
|
background: #fafafa;
|
||||||
}
|
}
|
||||||
|
|
||||||
.scheme-container, .information-container
|
.information-container
|
||||||
{
|
{
|
||||||
display: none
|
display: none
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
|
@ -55,7 +56,8 @@
|
||||||
plugins: [
|
plugins: [
|
||||||
// SwaggerUIBundle.plugins.DownloadUrl
|
// SwaggerUIBundle.plugins.DownloadUrl
|
||||||
],
|
],
|
||||||
// layout: "StandaloneLayout"
|
// layout: "StandaloneLayout",
|
||||||
|
oauth2RedirectUrl: "[[${OAUTH2_REDIRECT_URL_PROPERTY}]]"
|
||||||
});
|
});
|
||||||
// End Swagger UI call region
|
// End Swagger UI call region
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue