Hello :wave::skin-tone-4: We're using Ory Kratos ...
# ory-network
r
Hello šŸ‘‹šŸ½ We're using Ory Kratos to enable OIDC login against an Ory Hydra instance. Is there a way to have the Ory Hydra login session associated to an Ory Kratos session be logged out upon deletion of the Ory Krato session? i.e. when we log out a user from our application by triggering the logout flow, we would also like to have the associated Ory Hydra login session deleted. Use case: when a user has logged into our application, and they would like to log in with another account, they are automatically logged in to the previous account since the Ory Hydra session is still active. (Note: in this case, since it's a 1st party app, we've set
skip_consent=True
for the hydra client)
šŸ‘‚ 1
r
I don't think the login UI will be skipped if you are logged out of Kratos but still logged into Hydra. Have you tried this?
r
Hi @refined-kangaroo-48640 - thanks for your response. So the Kratos login isn't skipped, but the Hydra login is. Once the user is presented with the Ory Login Experience page, and they click on "Sign in with {Our OIDC}", the OAuth flow starts. • Since the user is already logged into Hydra, they don't get an OAuth login screen • Since we've set
skip_consent=True
, they don't see a consent screen • Therefore the OAuth flow completes, and they get logged in to Kratos
r
Sorry, I'm confused. Do you start the login flow via
/oauth2/auth
(Hydra) or at
/login
(Kratos)? In Ory Network, you will be presented a login page (slightly different) either way. Does your Hydra redirect to your Kratos instance (default configuration in Ory Network)? I don't believe it is possible for the login screen to be skipped if Hydra redirects to Kratos but you have no Kratos session.
r
Hi @refined-kangaroo-48640 - thanks for engaging. Perhaps I can explain a bit better. For our use case, we have 2 Ory Network workspaces: Workspace 1 (has Hydra enabled, using our own custom authentication backend) - our customers' platform Workspace 2 (has Kratos enabled) - our developers' platform The reason for this separation is that the 2 workspaces handle different kinds of users within our ecosystem (i.e. end user customers & developers); There are some users of Workspace 2 (developers) that also happen to be our customers, and so we allow them to log in to our developer platform using their customer credentials. This is where our set up comes in: in Workspace 2, we allow developers to log in (Kratos) with their Workspace 1 account (via Hydra OIDC). The flow is: 1. User starts on our developer platform, clicks "Log In" 2. They get presented with the Ory Kratos login screen ("Sign in with your {Customer} account" - i.e. allow them to sign in via the Workspace 1 Hydra) 3. They go through the OAuth flow, which connects to Workspace 1 Hydra, then redirects them back to the dashboard, having an Ory Kratos session issued a. So at this point, there are 2 sessions in the browser: i. An Ory Kratos session ii. An Ory Hydra session 4. When the user logs out, we're telling Workspace 2 Kratos: "invalidate this user's Kratos session" a. Now, only the Ory Hydra session exists on the browser 5. Let's say the user wants to log in with a different account; when the navigate to "Log In" again, and choose "Sign in with your {Customer} account", the Workspace 1 OAuth flow starts again a. Since there's still an Ory Hydra session available on the browser, they don't get presented with the Workspace 1 Hydra login screen (i.e. because Hydra already detects an available session and says the user is auth'd) b. Since we also have
skip_consent=True
, we don't prompt the user for consent again Back to my question: at step 5, is it possible to always force the user to log in afresh? (e.g. by configuring Kratos to pass in the
prompt=login
when initiating the OAuth flow?)
r
Interesting setup, makes sense now. Kratos cannot currently be configured to pass
prompt=login
when starting the OAuth flow unconditionally. The mechanism to achieve that is described here but requires a custom UI. You could hack around this, provided
Workspace 2 Kratos
is the only OAuth client configured in
Workspace 1 Hydra
, by overriding the Webfinger Auth URL (https://console.ory.sh/projects/current/oauth/openid) to include
?prompt=login
in
Workspace 1 Hydra
.
Another option would be to implement a custom handler for OpenID connect backchannel logout which revokes Kratos sessions in
Workspace 2
for a given
subject
. Logging out of
Kratos Workspace 2
would then proceed by way of an OAuth2 logout flow in
Workspace 1
.
r
@refined-kangaroo-48640 Thanks for the suggestions above. Unfortunately it's not the only OAuth client, so forcing
prompt=login
isn't feasible at the moment. For now, we've opted to perform an additional Hydra logout when the Kratos logout URL is requested, since we have access to the
subject
.
šŸ‘ 1
Longer term we'll move to our custom UI, so we may be able to tweak a few more things; for now this will suffice.