Infinite redirect loop when using Keycloak SSO and authorization fails

Created on 18 April 2022, almost 3 years ago
Updated 14 March 2023, almost 2 years ago

Problem/Motivation

If you have "Replace Drupal login with Keycloak single sign-on (SSO)" enabled, and the authentication fails for some reason (e.g. from logic in hook_openid_connect_pre_authorize()), the user will get stuck in a infinite redirect loop until the state token gets invalid and the user is rendered a access result forbidden.

So what happens is:

I enter /user/login
Gets redirected to keycloak base URL
I authenticate, get redirected to redirect URL (/openid-connect/keycloak)
hook_openid_connect_pre_authorize fails the authorization
I get redirect to /user, and as I'm not authenticated, I get redirected back to /user/login

and it repeats until the state token gets invalidated.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ’¬ Support request
Status

Postponed: needs info

Version

1.0

Component

Code

Created by

πŸ‡ΈπŸ‡ͺSweden johnwebdev

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024