Skip to content

feat(examples/firebase-auth-firestore): avoid auth rate limiting#3417

Merged
kentcdodds merged 1 commit intoremix-run:mainfrom
penx:firebase-avoid-rate-limiting
Jun 8, 2022
Merged

feat(examples/firebase-auth-firestore): avoid auth rate limiting#3417
kentcdodds merged 1 commit intoremix-run:mainfrom
penx:firebase-avoid-rate-limiting

Conversation

@penx
Copy link
Contributor

@penx penx commented Jun 8, 2022

Use the Firebase Auth REST API client side to avoid rate limiting.

This:

  • does not require the Firebase SDK client side
  • falls back to a standard form post and server side auth
  • has a very small client side bundle impact.

Reservations have already been made at #3362 (comment), and I have no objection to this being closed if it's not wanted, however if server side auth is rate limited to 150 requests/IP address/hour (which I understand to be the case based on reports here and here but have not tested) then the current example would not be suitable for many production applications. I am opening this as draft to discuss issues with and alternatives to this approach.

This is in draft:

  • pending information from Firebase support on rate limiting from the SignInWithPassword Firebase REST endpoint (I have contacted Firebase support)
  • if SignInWithPassword is rate limited, to see if Firebase support can suggest alternatives for server side auth

The best official source I can find is the following. Though specific rates for login per IP address are not mentioned, I think it may fall under "Verification requests":

Closes: Discussion at:

f

  • Docs
  • Tests


const handleSubmit = useCallback(
async (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this line is my main issue with this approach, as if something fails after this point it will not fall back to the form post + server side auth

Copy link
Member

Choose a reason for hiding this comment

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

Honestly, I'm fine with this. The same issue would exist when using a Remix <Form /> which does event.preventDefault() as well.

@penx penx force-pushed the firebase-avoid-rate-limiting branch from fc16fac to 77f8a4a Compare June 8, 2022 11:14
Use the Firebase Auth REST API client side to avoid rate limiting.

Previously discussed at:

- https://twitter.com/1fiws/status/1521426483037839362
- https://discord.com/channels/770287896669978684/777863722592501780/963845752986161162

The best official source I can find is the following, though specific rates for login per IP address are not mentioned:

- https://firebase.google.com/docs/auth/limits
@penx penx force-pushed the firebase-avoid-rate-limiting branch from 77f8a4a to 0211adf Compare June 8, 2022 11:16
@penx penx changed the title feat(examples/firebase-auth-firestore): avoid rate limiting feat(examples/firebase-auth-firestore): avoid auth rate limiting Jun 8, 2022
Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

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

This is much better than I was expecting.

Would still drastically simplify things if we could work out the rate-limiting issue for the server-side stuff.

Thanks so much for investing so heavily in this example.

@kentcdodds
Copy link
Member

I'm ready to merge this once you mark it as not a draft.

@penx penx marked this pull request as ready for review June 8, 2022 16:01
@MichaelDeBoey MichaelDeBoey requested a review from kentcdodds June 8, 2022 17:17
@kentcdodds kentcdodds merged commit 52985dd into remix-run:main Jun 8, 2022
@penx penx deleted the firebase-avoid-rate-limiting branch June 8, 2022 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments