<@U04UQ68083H> The `default_browser_return_url` is...
# ory-copilot
p
@chilly-king-10285 The
default_browser_return_url
is used when I register via oidc, but not via password. Why is that?
c
A message from kapa.ai
The
default_browser_return_url
is a configuration key used in Ory's redirection flow. It specifies where the user should be redirected after a certain action, such as registration or login. In the context of registration, the
default_browser_return_url
can be overridden for specific methods. For example, if you're using the password method for registration, you can specify a different
default_browser_return_url
that will override the general one. This is done using the following configuration:
Copy code
yaml selfservice:     flows:       registration:         after:           # overrides url.default_browser_return_url           default_browser_return_url: <https://this-is-overridden-by-password/>           password:             # overrides selfservice.registration.after.default_browser_return_url             default_browser_return_url: <https://end-up-here-after-registration-with-password/>
(Source: [Post-registration redirection](https://www.ory.sh/docs/kratos/concepts/browser-redirect-flow-completion#post-registration-redirection)) Similarly, for the OIDC method, you can specify a different `default_browser_return_url`:
Copy code
yaml selfservice:     flows:       login:         after:           oidc:             # redirect after successful login or registration with `OIDC` method             default_browser_return_url: <https://end-up-here-after-login-with-oidc/>
(Source: [Login, registration, and settings](https://www.ory.sh/docs/concepts/redirects#login-registration-and-settings)) So, if you're not being redirected to the
default_browser_return_url
after registration via password, it's likely because a different URL has been specified for the password method.
p
@chilly-king-10285 no, I have not specified a different return URL for password registration.
c
A message from kapa.ai
If you have not specified a different return URL for password registration, the
default_browser_return_url
should be used. This is the default behavior as per the Ory documentation. Here is the relevant configuration:
Copy code
yaml selfservice:     default_browser_return_url: <https://end-up-here-per-default/>     flows:       registration:         after:           # overrides url.default_browser_return_url           default_browser_return_url: <https://this-is-overridden-by-password/>           password:             # overrides selfservice.registration.after.default_browser_return_url             default_browser_return_url: <https://end-up-here-after-registration-with-password/>
(Source: [Post-registration redirection](https://www.ory.sh/docs/kratos/concepts/browser-redirect-flow-completion#post-registration-redirection)) If the
default_browser_return_url
is not being used, it might be due to some other configuration issue or a bug. You might want to double-check your configuration and ensure that there are no errors. If the issue persists, consider reaching out to the Ory community or support for further assistance.
p
@chilly-king-10285 It is not. Here is my config:
Copy code
registration:
          after:
            default_browser_return_url: <https://blarg.net/userinfo>
            hooks:
            - config:
                body: <base64://ZnVuY3Rpb24oY3R4KSB7CiAgInRleHQiOiBjdHguaWRlbnRpdHkudHJhaXRzLnV>zZXJuYW1lICsgIiBoYXMgY3JlYXRlZCBhIG5ldyBhY2NvdW50IHZpYSAiICsgc3RkLnNwbGl0KGN0eC5mbG93LnVpLmFjdGlvbiwgIi8iKVsyXSArICIuXG5AaGVyZSBwbGVhc2UgaW5pdCBhbmQgYWN0aXZhdGUgdGhlIGFjY291bnQuIgp9Cg==
                method: POST
                response:
                  ignore: true
                url: <http://127.0.0.1/not-a-hook>
              hook: web_hook
            oidc:
              hooks:
              - hook: session
            password:
              hooks:
              - hook: session
          lifespan: 10m
          ui_url: <https://blarg.net/registration>
c
A message from kapa.ai
From your configuration, it appears that you have set the
default_browser_return_url
under the
registration
flow. This URL should be used as the default redirection after registration unless overridden by a specific method like
oidc
or
password
. However, in your configuration, you have not specified a different
default_browser_return_url
for the
password
method, so the default one (`https://blarg.net/userinfo`) should be used. If this is not happening, it might be due to some other configuration issue or a bug. You might want to double-check your configuration and ensure that there are no errors. If the issue persists, consider reaching out to the Ory community or support for further assistance. Here is the relevant part of your configuration for reference:
Copy code
yaml registration:   after:     default_browser_return_url: <https://blarg.net/userinfo>     hooks:     - config:         body: <base64 value>         method: POST         response:           ignore: true         url: <http://127.0.0.1/not-a-hook>       hook: web_hook     oidc:       hooks:       - hook: session     password:       hooks:       - hook: session   lifespan: 10m   ui_url: <https://blarg.net/registration>
Please note that the actual base64 value in the
body
field has been replaced with
<base64 value>
for readability.
p
@chilly-king-10285 a bug I guess. can you open an issue and post this thread?
c
A message from kapa.ai
I'm sorry for any confusion, but as an AI, I don't have the capability to open issues or post threads on external platforms. However, I can guide you on how to do it. To report a bug to the Ory community, you can open an issue on the appropriate GitHub repository. Here are the steps: 1. Go to the [Ory GitHub page](https://github.com/ory). 2. Navigate to the repository related to your issue. If it's related to the Ory Kratos service, go to the [Ory Kratos repository](https://github.com/ory/kratos). 3. Click on the "Issues" tab. 4. Click on the "New issue" button. 5. Choose the appropriate template for your issue. 6. Fill in the details of the issue in the provided fields. Be sure to include as much information as possible, including the configuration you're using and the behavior you're experiencing. 7. Click "Submit new issue" to create the issue. Remember to follow the guidelines for contributing to Ory, which include not using GitHub issues to disclose vulnerabilities. If you believe you've found a security vulnerability, please disclose it responsibly by emailing [email protected] as mentioned in the [Ory documentation](https://www.ory.sh/docs/ecosystem/contributing#disclosing-vulnerabilities).
p
@chilly-king-10285 looks like it's broken. I'm not going to open a ticket though. Here is my updated config
Copy code
registration:
          after:
            default_browser_return_url: <https://blarg.net/userinfo>
            oidc:
              default_browser_return_url: <https://blarg.net/userinfo>
              hooks:
              - hook: session
            password:
              default_browser_return_url: <https://blarg.net/userinfo>
              hooks:
              - hook: session
          lifespan: 10m
          ui_url: <https://blarg.net/registration>
c
A message from kapa.ai
Your updated configuration now includes a
default_browser_return_url
for both the
oidc
and
password
methods under the
registration
flow. This means that after registration via either of these methods, the user should be redirected to
<https://blarg.net/userinfo>
. Here is your updated configuration for reference:
Copy code
yaml registration:   after:     default_browser_return_url: <https://blarg.net/userinfo>     oidc:       default_browser_return_url: <https://blarg.net/userinfo>       hooks:       - hook: session     password:       default_browser_return_url: <https://blarg.net/userinfo>       hooks:       - hook: session   lifespan: 10m   ui_url: <https://blarg.net/registration>
If you're still experiencing issues with redirection after registration, it might be due to some other configuration issue or a bug. If the issue persists, consider reaching out to the Ory community or support for further assistance.
p
@chilly-king-10285 oidc registration goes to the return_url, password registration does not.
c
A message from kapa.ai
From your configuration, it appears that you have set the
default_browser_return_url
for both
oidc
and
password
methods under the
registration
flow. This means that after registration via either of these methods, the user should be redirected to
<https://blarg.net/userinfo>
. Here is your configuration for reference:
Copy code
yaml registration:   after:     default_browser_return_url: <https://blarg.net/userinfo>     oidc:       default_browser_return_url: <https://blarg.net/userinfo>       hooks:       - hook: session     password:       default_browser_return_url: <https://blarg.net/userinfo>       hooks:       - hook: session   lifespan: 10m   ui_url: <https://blarg.net/registration>
If the OIDC registration is correctly redirecting to the return URL but the password registration is not, it might be due to a bug or some other configuration issue. Unfortunately, without more information, it's hard to determine the exact cause of the issue. You might want to double-check your configuration and ensure that there are no errors. If the issue persists, consider reaching out to the Ory community or support for further assistance.
p
maybe @high-optician-2097 can confirm this is a bug.
@chilly-king-10285 For reference this is my onSubmit handler for registration. Why doesn't a password flow use the default browser return url?
Copy code
const onRegistrationSubmit = (body: UpdateRegistrationFlowBody) => {     
    // something unexpected went wrong and the flow was not set            
    if (!flow) return history.push('/registration', { replace: true });    
                                                                           
    ory                                                                    
      .updateRegistrationFlow({                                            
        flow: flow.id,                                                     
        updateRegistrationFlowBody: body,                                  
      })                                                                   
      .then(({ data }) => {                                                
        if ('continue_with' in data) {                                     
          for (const cw of data.continue_with ?? []) {                     
            if (cw.action === 'show_verification_ui') {                    
              const search = new URLSearchParams();                        
              search.set('flow', cw.flow.id);                              
              history.push(                                                
                {                                                          
                  pathname: '/verification',                               
                  search: search.toString(),                               
                },                                                         
                { replace: true }                                          
              );                                                           
              return;                                                      
            }                                                              
          }                                                                
        }                                                                  
                                                                           
        // history.push('/userinfo');                                      
      })                                                                   
      .catch(sdkErrorHandler);                                             
  };
c
A message from kapa.ai
The
default_browser_return_url
is used by Ory Kratos to redirect the user after a successful registration flow. However, in your
onRegistrationSubmit
function, it seems like you're manually handling the redirection using the
history.push
method. Here is your
onRegistrationSubmit
function for reference:
Copy code
javascript
const onRegistrationSubmit = (body: UpdateRegistrationFlowBody) => {     
  // something unexpected went wrong and the flow was not set            
  if (!flow) return history.push('/registration', { replace: true });    
                                                                        
  ory                                                                    
    .updateRegistrationFlow({                                            
      flow: flow.id,                                                     
      updateRegistrationFlowBody: body,                                  
    })                                                                   
    .then(({ data }) => {                                                
      if ('continue_with' in data) {                                     
        for (const cw of data.continue_with ?? []) {                     
          if (cw.action === 'show_verification_ui') {                    
            const search = new URLSearchParams();                        
            search.set('flow', cw.flow.id);                              
            history.push(                                                
              {                                                          
                pathname: '/verification',                               
                search: search.toString(),                               
              },                                                         
              { replace: true }                                          
            );                                                           
            return;                                                      
          }                                                              
        }                                                                
      }                                                                  
    })                                                                   
    .catch(sdkErrorHandler);                                             
};
In this function, you're using the
history.push
method to manually redirect the user to the
/verification
route if the
show_verification_ui
action is present in the
continue_with
array. If the
show_verification_ui
action is not present, no redirection occurs.
The
default_browser_return_url
is used by Ory Kratos to redirect the user after a successful registration flow. However, in your
onRegistrationSubmit
function, it seems like you're manually handling the redirection using the
history.push
method. Here is your
onRegistrationSubmit
function for reference:
Copy code
javascript const onRegistrationSubmit = (body: UpdateRegistrationFlowBody) => {        // something unexpected went wrong and the flow was not set               if (!flow) return history.push('/registration', { replace: true });                                                                                ory                                                                         .updateRegistrationFlow({                                                   flow: flow.id,                                                            updateRegistrationFlowBody: body,                                       })                                                                        .then(({ data }) => {                                                       if ('continue_with' in data) {                                              for (const cw of data.continue_with ?? []) {                                if (cw.action === 'show_verification_ui') {                                 const search = new URLSearchParams();                                     search.set('flow', cw.flow.id);                                           history.push(                                                               {                                                                           pathname: '/verification',                                                search: search.toString(),                                              },                                                                        { replace: true }                                                       );                                                                        return;                                                                 }                                                                       }                                                                       }                                                                       })                                                                        .catch(sdkErrorHandler);                                              };
In this function, you're using the
history.push
method to manually redirect the user to the
/verification
route if the
show_verification_ui
action is present in the
continue_with
array. If the
show_verification_ui
action is not present, no redirection occurs. If you want to use the
default_browser_return_url
for redirection after a successful password registration, you might need to adjust your function to handle this. However, without more information about your overall application structure and how you're handling Ory Kratos flows, it's hard to provide a specific solution. If you're still having issues, consider reaching out to the Ory community or support for further assistance.