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

How to pass in nonce? #135

Open
DanMossa opened this issue May 16, 2022 · 16 comments · May be fixed by #244 or #402
Open

How to pass in nonce? #135

DanMossa opened this issue May 16, 2022 · 16 comments · May be fixed by #244 or #402

Comments

@DanMossa
Copy link

Context:
You can not pass a rawNonce to signInWithGoogle.

When using signInWithGoogle on Android, the returned idToken does not return a nonce. This makes sense because a rawNonce is not passed in.

The same exact code when run on iOS, returns a hashed nonce in the idToken. This does not make sense since we can not pass in a nonce. Where is the nonce coming from?

@petea
Copy link
Contributor

petea commented Jun 13, 2022

In the case of Google Sign-In for iOS and macOS, nonce values are being generated by AppAuth and included with the auth request. During ID token validation, the nonce value of the ID token is then verified using the originally generated value.

@DanMossa
Copy link
Author

DanMossa commented Jun 13, 2022

@petea Oh interesting.
Now if I want to send this JWT with the hashed nonce, how can I get the original nonce used so that i can verify this myself on the backend?

How can I get the originally generated value?

I also see that the comment says

@discussion If this value is not explicitly set, this library will automatically add nonce and perform appropriate validation of the nonce in the ID Token.

Is there no way to explicitly set this value?

@petea
Copy link
Contributor

petea commented Jun 16, 2022

How can I get the originally generated value?

The nonce generated by AppAuth isn't available via the Google Sign-In API surface. Currently, the recommended approach to server-side validation of the ID token doesn't include validation of the nonce.

Is there no way to explicitly set this value?

AppAuth allows you to provide a specific nonce, if desired. However, Google Sign-In does not expose this capability in its API surface.

@DanMossa
Copy link
Author

@petea
Oh I see, thanks for the clarification!

The lack of getting the raw nonce or specifying the raw nonce is blocking a few different users.

Would a PR to fix this be welcome in the future?

@toshi0383
Copy link

toshi0383 commented Oct 25, 2022

We need nonce support, too.
Apple and LINE supports this, so please consider.
We want to prevent Replay Attack.

@petea
Copy link
Contributor

petea commented Oct 27, 2022

@DanMossa, PRs are always welcome. Can you provide more detail on the specific use cases that are blocked here? Are they all related to server-side verification of the nonce?

@toshi0383 is the existing automatic client-side nonce generation / validation not adequate for your needs?

@toshi0383
Copy link

automatic client-side nonce generation

@petea We generate nonce in our server-side, so we need manual way to do this.
I have a brand new branch for this, so will tackle in a PR in a few minutes!

@toshi0383 toshi0383 linked a pull request Oct 27, 2022 that will close this issue
@toshi0383
Copy link

Done!
#244

@mdmathias
Copy link
Collaborator

Hi all! Many apologies for the delay. Thanks for your patience.

Would you be able to share more information about your use-case? It seems to deviate from the typical use case where the nonce is generated by the client.

In general, it seems fine for GSI to provide an API to ingest a nonce to pass along to OIDAuthorizationRequest in AppAuth.

@hf
Copy link

hf commented Jul 20, 2023

The nonce generated by AppAuth isn't available via the Google Sign-In API surface. Currently, the recommended approach to server-side validation of the ID token doesn't include validation of the nonce.

This is not true. The OIDC spec which Google follows explicitly states:

nonce
String value used to associate a Client session with an ID Token, and to mitigate replay attacks. The value is passed through unmodified from the Authentication Request to the ID Token. If present in the ID Token, Clients MUST verify that the nonce Claim Value is equal to the value of the nonce parameter sent in the Authentication Request. If present in the Authentication Request, Authorization Servers MUST include a nonce Claim in the ID Token with the Claim Value being the nonce value sent in the Authentication Request. Authorization Servers SHOULD perform no other processing on nonce values used. The nonce value is a case sensitive string.

Please allow for people to be able to extract the nonce you send to Google.

@SunilKividor
Copy link

@petea @toshi0383 can u help me setting up nonce in the google sign in package? Its an urgent usecase

@toshi0383
Copy link

@SunilKividor Hire someone and leave.
I have nothing to do with ur use case.
Stop mentioning us for nothing.

@SunilKividor
Copy link

SunilKividor commented Apr 24, 2024

@toshi0383 Thankyou for the response. We have moved to google credential management for setting up authentication with nonce. I appreciate your time.

@Massimiliano-solutiontech

Any news on that? The only way to set the nonce is to use AppAuth?

@toshi0383
Copy link

FYI my fork is an option too. #244
We're using this in production without any issues.

@vonovak vonovak linked a pull request Apr 28, 2024 that will close this issue
@vonovak
Copy link

vonovak commented Apr 28, 2024

I have opened a PR to support this: #402

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