<@U04UQ68083H> Is it possible to add a custom redi...
# ory-copilot
c
@chilly-king-10285 Is it possible to add a custom redirect URL after registration using oidc in kratos ?
c
A message from kapa.ai
Yes, it is possible to add a custom redirect URL after registration in Ory Kratos. You can specify a redirect URL per Self-Service Flow in the configuration. Here is an example of how to set it up for the registration flow:
Copy code
yaml selfservice:     flows:       registration:         after:           default_browser_return_url: <https://end-up-here-after-registration/>
This configuration will redirect the user to
<https://end-up-here-after-registration/>
after successful registration. For OpenID Connect (OIDC) specifically, when you are self-hosting Ory Kratos and adding a social sign-in provider, you need to define a redirect URL following this pattern:
Copy code
http http(s)://<domain-of-ory-kratos>:<public-port>/self-service/methods/oidc/callback/<social-signin-provider-id>
This URL is where the user will be redirected after successful authentication with the OIDC provider. Please note that if you want to redirect someone back to the original URL after registration, you can append
?return_to=<original-url>
when initializing the Registration flow. However, to prevent Open Redirect Attacks, you need to whitelist the domain in your Ory Kratos config when using the
?return_to=
query parameter. Here is an example of how to add a domain to the whitelist:
Copy code
yaml selfservice:     allowed_return_urls:       - <https://www.myapp.com/>
In this example,
<https://www.myapp.com/>
is added to the whitelist, allowing you to specify a dynamic return URL like
?return_to=<https://www.myapp.com/blog/write>
. For more details, please refer to the [Ory Kratos Documentation](https://www.ory.sh/docs/kratos/concepts/browser-redirect-flow-completion#redirection).
c
@chilly-king-10285 I want this redirection only for the case: user registration using oidc provider for the rest it will be the same
c
A message from kapa.ai
In Ory Kratos, you can specify a custom redirect URL for the registration flow using an OIDC provider. This can be done by setting the
default_browser_return_url
under the
registration
flow in the configuration file. Here is an example:
Copy code
yaml selfservice:     flows:       registration:         after:           default_browser_return_url: <https://end-up-here-after-registration/>
This configuration will redirect the user to
<https://end-up-here-after-registration/>
after successful registration. However, please note that this configuration will apply to all registration methods, not just OIDC. Currently, Ory Kratos does not support setting a different redirect URL for each registration method. For the OIDC provider specifically, you need to define a callback URL when you set up the provider. This URL is where the user will be redirected after successful authentication with the OIDC provider:
Copy code
http http(s)://<domain-of-ory-kratos>:<public-port>/self-service/methods/oidc/callback/<social-signin-provider-id>
This URL is not the same as the redirect URL after registration. The callback URL is used to handle the response from the OIDC provider, while the redirect URL after registration is where the user is sent after the entire registration process is completed. For more details, please refer to the [Ory Kratos Documentation](https://www.ory.sh/docs/kratos/concepts/browser-redirect-flow-completion#redirection).