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

Customizable redirect URL through LoginOptions #20

Merged
merged 2 commits into from Nov 16, 2023
Merged

Customizable redirect URL through LoginOptions #20

merged 2 commits into from Nov 16, 2023

Conversation

Tommy-ASD
Copy link
Contributor

Description

I have made enhancements to the LoginOptions structure in the Yew-OAuth2 crate to provide better flexibility and functionality. The changes include:

  • Added a new field redirect_url to allow users to define a custom redirect URL.
  • Modified the start_login function to consider the provided redirect_url if available, otherwise fallback to the current URL.

Related issues

Closes #14

@ctron
Copy link
Owner

ctron commented Nov 16, 2023

Thanks for the PR! I think it looks good. I would just prefer to make a few tweaks. Mainly things I (or clippy) might do differently in Rust.

I am happy to merge the PR as is, and follow up with that myself. Or I can tell you what I mean, and leave that to you. As you like, don't feel pressured.

Also, I think (from what I say) the change should be mostly backwards compatible. Except for creating a new structure (so good idea with the new function). I guess this would mean creating a new minor release, which it fine, just checking.

@Tommy-ASD
Copy link
Contributor Author

Thanks for taking the time to review the PR! I'm glad to hear that you find the changes generally good. I appreciate your willingness to make a few tweaks for Rust conventions and Clippy suggestions.

I trust your expertise, and I'm more than happy to have you handle those adjustments.

Regarding the backward compatibility and the potential need for a new minor release, I agree, and I believe it's a reasonable step to ensure a smooth transition for users.

Feel free to let me know how you'd like to proceed, and thanks again for your time and feedback!

@ctron ctron merged commit d7e29d9 into ctron:main Nov 16, 2023
3 checks passed
@ctron
Copy link
Owner

ctron commented Nov 16, 2023

Clippy was actually happy, it was just me :) … here is what I changed, just some small things: d51af31

I also upticked the version to 0.8.0 … I those changes look good from your side, just ping me and I will do the 0.8.0 release.

@Tommy-ASD
Copy link
Contributor Author

This looks great! Feel free to release whenever you like.

@ctron
Copy link
Owner

ctron commented Nov 16, 2023

And released as 0.8.0. Many thanks for the PR!

@AlexandreRoba
Copy link
Contributor

Hi @ctron, I might be doing something wrong but I can't seem to have the login options to work.
This is how I configure the 0Auth2Context:

let login_options = LoginOptions::new()
        .with_redirect_url(Url::parse("http://localhost:3000/callback").unwrap());
    html!(
        <>
            <OAuth2 {config}
                scopes={vec!["openid".into(),"email".into(),"offline_access".into(),"api:call".into()]}
                audience={"http://localhost:8081/api"}
                options={login_options}>
                <Content/>
            </OAuth2>
        </>
    )

The generated signin url query string contains:

response_type: code
client_id: XXXXXXXXXXXX
state: eMhCkjz4-qTShr93Iw-qmw
code_challenge: lwo9FNEKznQ7xgho_ylMrxU_71zHzQoHlq907uQ83yY
code_challenge_method: S256
redirect_uri: http://localhost:3000/
scope: openid openid email offline_access api:call
audience: http://localhost:8081/api
nonce: B4qwU8ekDmymf9b6Mzongw

@AlexandreRoba
Copy link
Contributor

AlexandreRoba commented Jan 8, 2024

I'm using Auth0 as IDP and they do not support wildcard redirect url... So I was planning to use a /callback?return_url= in order to perform a redirection on my side... is this a good idea? I do not see how to do this otherwise :(. Thanks for any help.

@ctron
Copy link
Owner

ctron commented Jan 9, 2024

I am not sure I understand what's wrong or what the context is. Maybe it makes sense taking this to a dedicated issue or discussion.

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

Successfully merging this pull request may close these issues.

Not configurable 'redirect_url' for a openidclient
3 participants