In this case, we use this procedure from the frontend app. When a user registers on Keycloak, this user is only stored on Keycloak.
Keycloak is used as an authentication provider, a "login with". The user is registered in the app on first use, even if the account already exists in Keycloak.
so, calling "api.add_user_if_not_exists" can be used on every request, only the first has an effect.
The field request.jwt.claim.sub is called "subject", this is a unique identifier for the user (a GUID with Keycloak). This field is provisionned by Keycloak, the JWT token has been verified by Postgrest with all informations (Keys).
Damn ! Keycloak on HN homepage ! We use it in production for years. Such a great tool, we deployed a "as a service" version, with a free offer => https://please-open.it
In this case, we use this procedure from the frontend app. When a user registers on Keycloak, this user is only stored on Keycloak.
Keycloak is used as an authentication provider, a "login with". The user is registered in the app on first use, even if the account already exists in Keycloak.
so, calling "api.add_user_if_not_exists" can be used on every request, only the first has an effect.
The field request.jwt.claim.sub is called "subject", this is a unique identifier for the user (a GUID with Keycloak). This field is provisionned by Keycloak, the JWT token has been verified by Postgrest with all informations (Keys).