Skip to content
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

Add swagger doc api path for oauth redirect #567

Merged
merged 2 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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));

Check warning

Code scanning / CodeQL

URL redirection from remote source

Untrusted URL redirection depends on a [user-provided value](1).
} 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