Skip to content
Snippets Groups Projects

Fix error where Drupal anon client tokens would fail to authenticate

Merged Martin Lowe requested to merge malowe/main/oauth-filter-anon-client-fix into main
1 file
+ 7
1
Compare changes
  • Side-by-side
  • Inline
@@ -13,6 +13,7 @@ package org.eclipsefoundation.efservices.request;
import org.eclipsefoundation.efservices.models.AuthenticatedRequestWrapper;
import org.eclipsefoundation.http.config.OAuth2SecurityConfig;
import org.eclipsefoundation.utils.exception.FinalForbiddenException;
import org.eclipsefoundation.utils.helper.TransformationHelper;
import org.jboss.resteasy.reactive.server.ServerRequestFilter;
import org.slf4j.Logger;
@@ -47,7 +48,12 @@ public class OAuthFilter {
public void filter(ContainerRequestContext requestContext, UriInfo uri, ResourceInfo info) {
if (Boolean.TRUE.equals(config.filter().enabled())) {
if (wrappedToken.isAuthenticated()) {
LOGGER.trace("User authenticated - {}", wrappedToken.getCurrentUser().name());
try {
LOGGER.trace("User authenticated - {}", wrappedToken.getCurrentUser().name());
} catch (FinalForbiddenException e) {
// current user will throw if this is a no-user client, which is a valid state
LOGGER.trace("Token authenticated, no user associated with token");
}
} else {
LOGGER.trace("User not authenticated for current request to {}", TransformationHelper.formatLog(uri.getPath()));
}
Loading