2

I have an Keycloak server and using mod_auth on Apache to manage the request.

Currently, in my client application, when I face with a 401 request, I trigger an location.reload() and thus being redirected to Keycloak logging page. But this feel very unnatural.

I want to ask if there is another, office way that do the redirecting automatically from Keycloak side/server side?

//////Edited////

I use mod_auth_openidc for Apache, which mean there is no adapter on client-side

Keyckoak version:4.4.0

Loredra L
  • 1,485
  • 2
  • 16
  • 32
  • Which keycloak version do you use? Which adapter do you work with? Sending that kind of redirections works out of the box in Spring Security and Spring Boot adapters. – Aritz Sep 25 '18 at 09:54
  • @XtremeBiker: Added additional information. – Loredra L Sep 25 '18 at 10:42
  • Okey, then you might need to configure that module in some way that sends a redirect when a 401 error happens (you probably would like to do it for browser requests, meaning web page requests and not the REST API, if you have one). – Aritz Sep 25 '18 at 10:48

1 Answers1

-1

You can use OIDCUnAuthAction to configure the action to be taken on an incoming unauthenticated request, see: https://github.com/zmartzone/mod_auth_openidc/blob/v2.3.8/auth_openidc.conf#L697

This is a per-path/location/directory setting, so in your case you'd configure:

OIDCUnAuthAction auth

on that specific path.

Hans Z.
  • 50,496
  • 12
  • 102
  • 115