add support for OIDC authentication to Swagger API

This commit is contained in:
Jason Roberts 2021-09-17 09:48:39 -04:00
parent b2d6f75964
commit 56920149bc
3 changed files with 18 additions and 3 deletions

View File

@ -262,6 +262,13 @@ public class OpenApiInterceptor {
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;
}
@ -336,12 +343,18 @@ public class OpenApiInterceptor {
String page = extractPageName(theRequestDetails, PAGE_SYSTEM);
context.setVariable("PAGE", page);
populateOIDCVariables(context);
String outcome = myTemplateEngine.process("index.html", context);
theResponse.getWriter().write(outcome);
theResponse.getWriter().close();
}
protected void populateOIDCVariables(WebContext context) {
context.setVariable("OAUTH2_REDIRECT_URL_PROPERTY", "");
}
private String extractPageName(ServletRequestDetails theRequestDetails, String theDefault) {
String[] pageValues = theRequestDetails.getParameters().get("page");
String page = null;
@ -354,7 +367,7 @@ public class OpenApiInterceptor {
return page;
}
private OpenAPI generateOpenApi(ServletRequestDetails theRequestDetails) {
protected OpenAPI generateOpenApi(ServletRequestDetails theRequestDetails) {
String page = extractPageName(theRequestDetails, null);
CapabilityStatement cs = getCapabilityStatement(theRequestDetails);

View File

@ -18,7 +18,7 @@ body
background: #fafafa;
}
.scheme-container, .information-container
.information-container
{
display: none
}

View File

@ -1,3 +1,4 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
@ -55,7 +56,8 @@
plugins: [
// SwaggerUIBundle.plugins.DownloadUrl
],
// layout: "StandaloneLayout"
// layout: "StandaloneLayout",
oauth2RedirectUrl: "[[${OAUTH2_REDIRECT_URL_PROPERTY}]]"
});
// End Swagger UI call region