Skip to content

Commit

Permalink
Merge branch 'fix/return-403-for-oauth-request' into 'develop'
Browse files Browse the repository at this point in the history
OEQ-1689 fix: return the proper response for failed OAUTH request

See merge request edalex-group/development/oeq/openequella!263
  • Loading branch information
PenghaiZhang committed Oct 2, 2023
2 parents 4fe5f7a + 08dde47 commit ae85c7a
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.tle.web.core.filter.UserStateResult.Result;
import com.tle.web.dispatcher.AbstractWebFilter;
import com.tle.web.dispatcher.FilterResult;
import java.io.IOException;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.servlet.http.HttpServletRequest;
Expand All @@ -57,7 +58,8 @@ public class TleSessionFilter extends AbstractWebFilter {
private PluginTracker<UserStateHook> userStateHooks;

@Override
public FilterResult filterRequest(HttpServletRequest request, HttpServletResponse response) {
public FilterResult filterRequest(HttpServletRequest request, HttpServletResponse response)
throws IOException {
final FilterResult result =
new FilterResult(
(request1, response1) -> {
Expand Down Expand Up @@ -99,7 +101,11 @@ public FilterResult filterRequest(HttpServletRequest request, HttpServletRespons
}
} catch (RuntimeException t) {
userService.logoutToGuest(userService.getWebAuthenticationDetails(request), false);
throw t;
if (t instanceof WebException) {
response.sendError(((WebException) t).getCode());
} else {
throw t;
}
}

return result;
Expand Down

0 comments on commit ae85c7a

Please sign in to comment.