Skip to content

Commit

Permalink
Add swagger doc api path for oauth redirect (#567)
Browse files Browse the repository at this point in the history
* Add swagger doc api path for oauth redirect
  • Loading branch information
olivershen-wow authored Aug 8, 2023
1 parent e0a79ad commit ed4f5d4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,13 @@ public void getAccessToken(@RequestParam("code") String code, HttpServletRequest
String state = request.getParameter("state");
String prefix = Const.FrontEndPath.INDEX_PATH + "?" + Const.FrontEndPath.REDIRECT_PARAM + "=";

if (StringUtils.isNotEmpty(state) && state.startsWith(prefix)) {
String newUrl = state.replace(prefix, "");
if (LogUtils.isLegalStr(newUrl, Const.RegexString.URL, false)) {
if (StringUtils.isNotEmpty(state)) {
if (state.startsWith(prefix)) {
String newUrl = state.replace(prefix, "");
if (LogUtils.isLegalStr(newUrl, Const.RegexString.URL, false)) {
redirectUrl = state;
}
} else if (state.equals(Const.FrontEndPath.SWAGGER_DOC_PATH)) {
redirectUrl = state;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons
} else {
response.sendRedirect(authUtil.getLoginUrl());
}
} else if (requestURI.equals(Const.FrontEndPath.SWAGGER_DOC_PATH)) {
response.sendRedirect(authUtil.getLoginUrl(requestURI, null));
} else {
response.setStatus(HttpStatus.UNAUTHORIZED.value());
response.setHeader("Location", authUtil.getLoginUrl());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ interface FrontEndPath {
String INDEX_PATH = "/portal/index.html";
String ANCHOR = "#";
String REDIRECT_PARAM = "redirectUrl";
String SWAGGER_DOC_PATH = "/v3/api-docs";
}

interface RegexString {
Expand Down

0 comments on commit ed4f5d4

Please sign in to comment.