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

#4 OAuth2 option: add optional client secret #3

Closed
wants to merge 1 commit into from
Closed

#4 OAuth2 option: add optional client secret #3

wants to merge 1 commit into from

Conversation

darioalessandro
Copy link

@darioalessandro darioalessandro commented Jul 23, 2022

Closes #4

OAuth2 providers like google require client_secret.

Test:

Jul-22-2022 22-15-54

@darioalessandro darioalessandro changed the title OAuth2 option: add optional client secret #4 OAuth2 option: add optional client secret Jul 23, 2022
@ctron
Copy link
Owner

ctron commented Jul 25, 2022

Thanks for the PR.

To my understanding, the secret should not be put into a frontend application, as it is "secret". So adding a secret into a frontend application would be a bad idea IMHO.

I guess that is what "public clients" (without a secret) are for: https://oauth.net/2/client-types/

@junderw
Copy link

junderw commented Jul 26, 2022

The client (browser) should never hold the client (web service) secret.

Remember, if the "client" in client_id and client_secret was referring to the browser client, why do all of your visitors use the same client_id and client_secret?

This should tell you that "client" in this context is the website server maintainer.

The frontend code sent to the browser should only contain "client_id".

@junderw
Copy link

junderw commented Jul 26, 2022

Here's a simple OAuth2 setup (though it is nodeJS) that is easy to follow and I think demonstrates the flow of OAuth2 very very well.

https://www.youtube.com/watch?v=qTsqpYz5cGE

@darioalessandro
Copy link
Author

Hey friends, thank you so much for your feedback. @ctron i am planning to use this lib in the context of an electron app, so it is similar to the desktop app flow described here:

https://developers.google.com/identity/protocols/oauth2

"Installed applications

The Google OAuth 2.0 endpoint supports applications that are installed on devices such as computers, mobile devices, and tablets. When you create a client ID through the Google API Console, specify that this is an Installed application, then select Android, Chrome app, iOS, Universal Windows Platform (UWP), or Desktop app as the application type.

The process results in a client ID and, in some cases, a client secret, which you embed in the source code of your application. (In this context, the client secret is obviously not treated as a secret.)"

@darioalessandro
Copy link
Author

It might be the case that I should create a different crate for desktop apps so that this crate remains focused on the web client scenario (which is the most common use case for yew anyways).

@ctron
Copy link
Owner

ctron commented Jul 26, 2022

Taking a look at "Mobile & Desktop Apps", which I guess an Electron app would, it doesn't mention client secrets though: https://developers.google.com/identity/protocols/oauth2/native-app and only has a warning that client secrets aren't secure:

Note: incremental authorization with installed apps is not supported due to the fact that the client cannot keep the client_secret confidential.

I am ok with adding this in general. I just don't want it to look like that using this is a good idea :)

So adding this, I would ask you make a dedicated note on the field, explaining the situation. Also, I would ask to move the value out of the standard Config::new function, maybe let the user override later. Maybe create a with_secret function. But having this as the part of the default new function makes it look like using this is a good idea, which in most cases I believe it is not.

@darioalessandro
Copy link
Author

I hear you and it makes sense 😄

@ctron
Copy link
Owner

ctron commented Oct 6, 2022

Sorry, wrong thread.

@ctron ctron mentioned this pull request Feb 23, 2023
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.

Client secret param
3 participants