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

Implement #174 to handle additional token errors. #312

Closed
wants to merge 7 commits into from

Conversation

HofmannZ
Copy link
Contributor

@HofmannZ HofmannZ commented Oct 8, 2021

As described in #174, there are a couple of scenarios where verifyIdToken was throwing an error, where it could actually be handled more gracefully.

This PR:

This PR also brings RFC issue #265 one step closer to being ready for launch 🚀.

@vercel
Copy link

vercel bot commented Oct 8, 2021

@HofmannZ is attempting to deploy a commit to the Gladly Team on Vercel.

A member of the Team first needs to authorize it.

@codecov
Copy link

codecov bot commented Oct 8, 2021

Codecov Report

Merging #312 (9d1e4d9) into v1.x (769e21e) will increase coverage by 0.20%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             v1.x     #312      +/-   ##
==========================================
+ Coverage   99.59%   99.80%   +0.20%     
==========================================
  Files          25       25              
  Lines         495      505      +10     
  Branches      176      182       +6     
==========================================
+ Hits          493      504      +11     
+ Misses          2        1       -1     
Impacted Files Coverage Δ
src/firebaseAdmin.js 100.00% <100.00%> (+2.32%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 769e21e...9d1e4d9. Read the comment docs.

@HofmannZ
Copy link
Contributor Author

HofmannZ commented Oct 8, 2021

@kmjennison - Ran the failing test locally without my changes, and it fails with the same error. Any idea why that might be?

@kmjennison
Copy link
Contributor

@HofmannZ I'm not sure. Could you confirm your dependencies match the lockfile?

@HofmannZ
Copy link
Contributor Author

HofmannZ commented Oct 8, 2021

@kmjennison - Yeah they do.

Copy link
Contributor

@kmjennison kmjennison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! A few changes:

@kmjennison
Copy link
Contributor

@HofmannZ Hmm, ok. I don't have much time to debug at the moment but will try to take a look when I can.

@HofmannZ
Copy link
Contributor Author

HofmannZ commented Oct 8, 2021

@kmjennison - I will have a look at #174.

@HofmannZ HofmannZ changed the title fix: check for 'auth/argument-error' when verifying token Implement #174 to handle additional token errors. Oct 10, 2021
@HofmannZ
Copy link
Contributor Author

@kmjennison - Ready for review! 👀

@HofmannZ HofmannZ requested a review from kmjennison October 10, 2021 10:26
Copy link
Contributor

@kmjennison kmjennison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking on this PR! Requested a few small changes.

src/firebaseAdmin.js Show resolved Hide resolved
src/createAuthUser.js Outdated Show resolved Hide resolved
index.d.ts Outdated Show resolved Hide resolved
src/__tests__/firebaseAdmin.test.js Outdated Show resolved Hide resolved
src/__tests__/firebaseAdmin.test.js Outdated Show resolved Hide resolved
src/firebaseAdmin.js Outdated Show resolved Hide resolved
firebaseUser = null
break
default:
// Otherwise, throw.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessarily a change in this PR but wanted to ask your input: I'm wondering if it makes sense to return an unauthenticated user for any error, then call an optional onAuthError callback provided by user for the unexpected errors (ones we don't handle above). My thinking is that it's not particularly easy for developers to catch errors in withAuthUserSSR and in most cases an unauthed user + optional error log is preferable to a 500 error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a good idea, bit out of scope for this PR. Will add a new PR for that when I find the time for it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I plan to take this work on soon.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented this in #366.

@kmjennison
Copy link
Contributor

Thanks, @HofmannZ! Merged in #361.

@kmjennison kmjennison closed this Dec 10, 2021
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.

2 participants