[KEYCLOAK-9474] - Public endpoints are returning 403 with body when enforcement mode is disabled
This commit is contained in:
parent
366ee083ac
commit
4d5dff1d64
2 changed files with 22 additions and 3 deletions
|
@ -159,11 +159,9 @@ public class AuthenticatedActionsHandler {
|
|||
|
||||
if (session != null) {
|
||||
session.setAuthorizationContext(authorizationContext);
|
||||
|
||||
return authorizationContext.isGranted();
|
||||
}
|
||||
|
||||
return true;
|
||||
return authorizationContext.isGranted();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to enforce policy decisions.", e);
|
||||
}
|
||||
|
|
|
@ -211,6 +211,27 @@ public class PolicyEnforcerTest extends AbstractKeycloakTest {
|
|||
assertEquals(403, response.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPublicEndpointNoBearerAbortRequest() {
|
||||
KeycloakDeployment deployment = KeycloakDeploymentBuilder.build(getAdapterConfiguration("enforcer-bearer-only.json"));
|
||||
OIDCHttpFacade httpFacade = createHttpFacade("/api/public");
|
||||
AuthenticatedActionsHandler handler = new AuthenticatedActionsHandler(deployment, httpFacade);
|
||||
|
||||
assertTrue(handler.handledRequest());
|
||||
|
||||
oauth.realm(REALM_NAME);
|
||||
oauth.clientId("public-client-test");
|
||||
oauth.doLogin("marta", "password");
|
||||
|
||||
String code = oauth.getCurrentQuery().get(OAuth2Constants.CODE);
|
||||
OAuthClient.AccessTokenResponse response = oauth.doAccessTokenRequest(code, null);
|
||||
String token = response.getAccessToken();
|
||||
httpFacade = createHttpFacade("/api/resourcea", token);
|
||||
handler = new AuthenticatedActionsHandler(deployment, httpFacade);
|
||||
|
||||
assertFalse(handler.handledRequest());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMappedPathEnforcementModeDisabled() {
|
||||
KeycloakDeployment deployment = KeycloakDeploymentBuilder.build(getAdapterConfiguration("enforcer-disabled-enforce-mode-path.json"));
|
||||
|
|
Loading…
Reference in a new issue