Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OAuth2 Redirect URL Incorrectly Formatted When Using # in AUTHORIZATION_URL #112

Open
jalozanoAirzone opened this issue Jan 29, 2025 · 0 comments

Comments

@jalozanoAirzone
Copy link

Hi,
Im implementing oauth with a url that contains a # and the redirection on the login modal is bad formatted.
my AUTHORIZATION_URL is 'https://<base_url>/#/oauth' and with this url, the login page that open the modal is bad formatted.
The method onShowViewLoginOAuth2 on the oAuth2Callback.on(('url') emit on the socket this url

https://callback.athom.com/oauth2/?token=&url=https%3A%2F%2F<base_url>%2F%23%2Foauth%3Fstate%3D81c3d08b-11b6-4e89-982e-c36c46e04ef0%26client_id%3D<client_id>%26response_type%3Dcode%26scope%3Dmy_scope%26redirect_uri%3Dhttps%253A%252F%252Fcallback.athom.com%252Foauth2%252Fcallback

This url makes a redirect to our login page bad formmated, the url redirectioned is
https://<base_url>/?state=#/oauth?state=&client_id=<client_id>&response_type=code&scope=my_scope&redirect_uri=https%3A%2F%2Fcallback.athom.com%2Foauth2%2Fcallback

and should be like

https://<base_url>/#/oauth?state=&client_id=<client_id>&response_type=code&scope=my_scope&redirect_uri=https%3A%2F%2Fcallback.athom.com%2Foauth2%2Fcallback

I'm implementing OAuth2 with an AUTHORIZATION_URL that contains a hash (#), but the redirection in the login modal is incorrectly formatted.

My AUTHORIZATION_URL is: https://<base_url>/#/oauth

However, when the login modal opens, the emitted URL in the onShowViewLoginOAuth2 method via oAuth2Callback.on('url') is:

https://callback.athom.com/oauth2/?token=<token>&url=https%3A%2F%2F<base_url>%2F%23%2Foauth%3Fstate%3D<state>%26client_id%3D<client_id>%26response_type%3Dcode%26scope%3Dmy_scope%26redirect_uri%3Dhttps%253A%252F%252Fcallback.athom.com%252Foauth2%252Fcallback

This URL results in an incorrectly formatted redirect to our login page:

https://<base_url>/?state=<state>#/oauth?state=<state>&client_id=<client_id>&response_type=code&scope=my_scope&redirect_uri=https%3A%2F%2Fcallback.athom.com%2Foauth2%2Fcallback

Instead, the expected redirect should be:

https://<base_url>/#/oauth?state=<state>&client_id=<client_id>&response_type=code&scope=my_scope&redirect_uri=https%3A%2F%2Fcallback.athom.com%2Foauth2%2Fcallback

Expected Behavior
The redirect should preserve the fragment (#) and not insert additional query parameters before it.

Actual Behavior
The fragment (#) is being interpreted incorrectly, causing query parameters to be misplaced.

Steps to Reproduce

  1. Set AUTHORIZATION_URL to a URL containing # (e.g., https://<base_url>/#/oauth).
  2. Trigger the OAuth2 flow.
  3. Observe the emitted URL and the resulting redirection.

Additional Notes
It seems like the hash fragment (#) is being URL-encoded as %23, which might be causing the incorrect behavior.

Would appreciate any insights or potential fixes. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant