0

I want to authenticate against Keycloak from a Cake app using the Auth-Middleware. I mocked it in AppController which worked out well, and I am pretty sure that it's going to work with the middleware as well. I wrote 2 new Authenticator and 1 Identifier class for that

However, there is a problem I didn't see: I need to redirect to the keycloak instance from one of the Authenticator classes. I tried to throw UnauthenticatedException, but get an error, that Authentication is required to continue.

The exception throw wasn't my fav anyway, as it seemed difficult to store the state for csrf protection that way.

So: could anyone advice me how to redirect from inside an Authenticator class?

harpax
  • 5,986
  • 5
  • 35
  • 49
  • 1
    I can't test it right now, but I think this should be still valid in 4.x, except that the exception has been renamed to `AuthenticationRequiredException`: **https://stackoverflow.com/questions/54067100/how-to-properly-redirect-from-a-cakephp-authentication-authenticator-for-openid/54067364#54067364** – ndm May 28 '20 at 17:56
  • Thanks a lot .. the renamed Exception was the problem .. – harpax May 29 '20 at 15:00

0 Answers0