Skip to content

Commit

Permalink
chore: version 4.3.1.sp1
Browse files Browse the repository at this point in the history
  • Loading branch information
yurem committed May 4, 2023
1 parent 6d5071d commit af5dc39
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions Server/src/main/java/org/gluu/oxauth/filter/CorsFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,32 +108,31 @@ public void init(final FilterConfig filterConfig) throws ServletException {
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
throws IOException, ServletException {
Collection<String> globalAllowedOrigins = null;
if (this.filterEnabled) {
try {
globalAllowedOrigins = doFilterImpl(servletRequest);
// Set temporary client allowed origins
Collection<String> clientAllowedOrigins = doFilterImpl(servletRequest);
setContextClientAllowedOrigins(servletRequest, clientAllowedOrigins);
} catch (Exception ex) {
log.error("Failed to process request", ex);
}
super.doFilter(servletRequest, servletResponse, filterChain);
setAllowedOrigins(globalAllowedOrigins);
} else {
filterChain.doFilter(servletRequest, servletResponse);
}
}

protected Collection<String> doFilterImpl(ServletRequest servletRequest)
throws UnsupportedEncodingException, IOException, ServletException {
Collection<String> globalAllowedOrigins = getAllowedOrigins();
List<String> clientAuthorizedOrigins = null;

if (StringHelper.isNotEmpty(servletRequest.getParameter("client_id"))) {
String clientId = servletRequest.getParameter("client_id");
Client client = clientService.getClient(clientId);
if (client != null) {
String[] authorizedOriginsArray = client.getAuthorizedOrigins();
if (authorizedOriginsArray != null && authorizedOriginsArray.length > 0) {
List<String> clientAuthorizedOrigins = Arrays.asList(authorizedOriginsArray);
setAllowedOrigins(clientAuthorizedOrigins);
clientAuthorizedOrigins = Arrays.asList(authorizedOriginsArray);
}
}
} else {
Expand All @@ -156,15 +155,14 @@ protected Collection<String> doFilterImpl(ServletRequest servletRequest)
if (client != null) {
String[] authorizedOriginsArray = client.getAuthorizedOrigins();
if (authorizedOriginsArray != null && authorizedOriginsArray.length > 0) {
List<String> clientAuthorizedOrigins = Arrays.asList(authorizedOriginsArray);
setAllowedOrigins(clientAuthorizedOrigins);
clientAuthorizedOrigins = Arrays.asList(authorizedOriginsArray);
}
}
}
}
}

return globalAllowedOrigins;
return clientAuthorizedOrigins;
}
}

0 comments on commit af5dc39

Please sign in to comment.