Does anyone know how I can configure the request t...
# talk-kratos
m
Does anyone know how I can configure the request to
/self-service/methods/oidc/callback/:providerId
to redirect to my app's url? It's currently redirecting to
selfservice.default_browser_return_url
, which isn't ideal since I have multiple apps on separate subdomains. Perhaps there's an extra query param that I can add to the
/self-service/methods/oidc/callback
url, which will override the
default_browser_return_url
? For context, the
/self-service/methods/oidc/callback
endpoint is invoked by passing it as a
redirect_uri
query param to my OIDC provider's url, like so:
<https://myoktalogin.example.com/oauth2/v1/authorize?client_id=${myOidcClientId}&redirect_uri=${publicKratosBaseUrl}/self-service/methods/oidc/callback/my-okta-test&response_type=code&scope=email+profile+openid&state=${state}>
I have the rest of the OIDC flow working. Now I just need to customize the final redirect. I've included some logs below which show how this endpoint is being handled on my
oryd/kratos:v1.0.0
local deployment.
Notice how the last log message includes information about the response from this endpoint:
Copy code
http_response=map[
  headers:
    map[
      location:<http://127.0.0.1:4455/>
where
<http://127.0.0.1:4455/>
is equal to
selfservice.default_browser_return_url
. I want to override that to be the location where my app is hosted, but not for every login.
Here's a relevant portion of my config, if it helps
It seems like the redirect is calculated here: https://github.com/ory/kratos/blob/7c0e02efdc115b5ac9dcf7e6517a27e903c02643/selfservice/flow/login/hook.go#L145-L152 but I'm still getting familiar with this codebase...
Ah, it seems like I might be able to send a
return_to
query param in the
self-service/login
request... https://www.ory.sh/docs/kratos/reference/api#tag/frontend/operation/updateLoginFlow
Although it doesn't seem to be documented as an actual query param, and I'm not seeing this option in the Ory javascript client 🤔
Ah, ok I figured it out. I had to pass in the return url in by flow creation call, ie:
ory.createBrowserLoginFlow({ returnTo: '<http://127.0.0.1:8091>' })