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

feat: Secure Endpoints using Middleware, validate bearer token #89

Open
NwinNwin opened this issue Feb 11, 2025 · 0 comments
Open

feat: Secure Endpoints using Middleware, validate bearer token #89

NwinNwin opened this issue Feb 11, 2025 · 0 comments
Assignees

Comments

@NwinNwin
Copy link
Member

To do

  • Investigate how to implement middleware with firebase-admin correctly with SST
  • Secure all API routes
  • Help us secure these endpoints pls!!!

Description

We attempted to add middleware to secure our backend routes while setting up SST. Specifically, we tried implementing a middleware function like:

itemsRouter.post("/", middleware.decodeToken, async (req, res) => {
  // Route handler logic
});

This middleware is meant to decode the token and authenticate requests. However, we ran into some issues, and it wasn’t working as expected.

Expected Behavior

  • The middleware should correctly extract and validate the token from the request.
  • Requests should be blocked if authentication fails.

Actual Behavior

  • Got some error in SST when setting it up
  • Doesn't allow backend to run

Steps to Reproduce

  1. Added middleware.decodeToken to itemsRouter.post("/").
  2. Set up SST with the backend.
  3. Encountered issues where the middleware was not working as expected.

Relevant Information

The frontend is sending the Bearer token in requests like this:
[Frontend code sending Bearer token](

{
headers: {
Authorization: `Bearer ${token}`,
},
}
)

We need to ensure that our middleware properly handles and validates this token.

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

No branches or pull requests

2 participants