We are having issue using PI with multiple realms through Keycloak.
Right now the authentication only works with users in the default realm. We did configure the Keycloak provider to send the corresponding realm for the tenant. The realm is properly being sent on the triggerchallenge request, but when sending the token request it seems that no realm at all is sent and therefore the default realm of PI is being used
Triggerchallenge request
[2022-09-17 10:39:38,619][32823][140254540224256][DEBUG][privacyidea.api.lib.utils:253] Update params in request POST https://mfa.example.org/auth with values.
[2022-09-17 10:39:38,634][32823][140254540224256][DEBUG][privacyidea.api.before_after:100] End handling of request '/auth?'
[2022-09-17 10:39:38,640][32823][140254380001024][DEBUG][privacyidea.api.before_after:85] Begin handling of request '/validate/triggerchallenge?'
[2022-09-17 10:39:38,641][32823][140254380001024][DEBUG][privacyidea.api.lib.utils:253] Update params in request POST https://mfa.example.org/validate/triggerchallenge with values.
[2022-09-17 10:39:38,641][32823][140254380001024][DEBUG][privacyidea.lib.user:186] Entering get_user_from_param with arguments ({'user': 'foo', 'realm': 'bar'},) and keywords {}
Token request:
[2022-09-17 10:39:39,482][32823][140254540224256][DEBUG][privacyidea.api.before_after:100] End handling of request '/auth?'
[2022-09-17 10:39:39,486][32823][140254380001024][DEBUG][privacyidea.api.before_after:85] Begin handling of request '/token/?user=foo'
[2022-09-17 10:39:39,487][32823][140254380001024][DEBUG][privacyidea.api.lib.utils:253] Update params in request GET https://mfa.example.org/token/ with values.
[2022-09-17 10:39:39,487][32823][140254380001024][DEBUG][privacyidea.lib.user:186] Entering get_user_from_param with arguments ({'user': 'foo'},) and keywords {}
[2022-09-17 10:39:39,488][32823][140254380001024][DEBUG][privacyidea.lib.user:186] Entering split_user with arguments ('foo',) and keywords {}
[2022-09-17 10:39:39,488][32823][140254380001024][DEBUG][privacyidea.lib.config:186] Entering get_from_config with arguments ('splitAtSign',) and keywords {'return_bool': True}
[2022-09-17 10:39:39,488][32823][140254380001024][DEBUG][privacyidea.lib.config:327] Cloning request-local config from shared config object
[2022-09-17 10:39:39,490][32823][140254380001024][DEBUG][privacyidea.lib.config:198] Exiting get_from_config with result True
[2022-09-17 10:39:39,490][32823][140254380001024][DEBUG][privacyidea.lib.user:198] Exiting split_user with result ('foo', '')
[2022-09-17 10:39:39,491][32823][140254380001024][DEBUG][privacyidea.lib.realm:186] Entering get_default_realm with arguments () and keywords {}
[2022-09-17 10:39:39,491][32823][140254380001024][DEBUG][privacyidea.lib.realm:198] Exiting get_default_realm with result defrealm
[2022-09-17 10:39:39,491][32823][140254380001024][DEBUG][privacyidea.lib.user:186] Entering __init__ with arguments (User(login='', realm='', resolver=''),) and keywords {'login': 'foo', 'realm': 'defrealm', 'resolver': None}
Is there anything we have to do on PI side to correctly match the users?
UPDATE: When manually assigning / generating a token, the authentication works. So it looks like there’s an issue with creating the token for a user on 1st login.