[Server update]: Create a custom server and auth/cookie middleware
Contact Details
No response
Is your feature request related to a problem? Please describe?
We are currently using the default server from remix which works but its not customizable. If we want to add our own middleware we need to consider making a custom server. When we do a custom server we will be able to:
- create auth middleware
- create cookie setting middleware
This way we dont have to worry about committing the session or protecting each route. We can just manage it via the middleware.
Describe the solution you'd like
After discussing it with some community members I was recommended to use Hono due to it being super easy to test and build middleware for. https://github.com/sergiodxa/remix-hono
Once we have the server working we can create the middleware to add. I already have examples that I can share once we get there.
Describe alternatives you've considered
No response
Additional context
No response
On it
@rajdip-b okey we have the server working, we need to make the protect middleware part now, which was the main reason we did this. Here is a list of what we still need to do in my mind.
- Enable protect middleware. This basically works already, just needs to be added. We also need to add the array of
publicRoutes - remove
requireAuthSessionfrom withinrequirePermision - We will now be getting the session data like this:
export async function loader({ context }: LoaderFunctionArgs) {
const { username, userId } = context.getSession();
...
so we need to adjust requirePermission. We have to decide weather we pass directly the userId or we just pass the whole context or just the userId. I think it might be better to just pass the userId.
4. CHange the returns of requirePermission. Should not return the authSession anymore as we dont need it. I also dont think it should return userId as we will be getting that from the context as in the example above
5. We need to go to every loader/action, change the props to include context and adjust how we get the userId and how we call requirePermision
Progress:
Routes:
- [x] ./api+/user.prefs.upload-user-photo.ts
- [x] ./api+/$organizationId.qr-codes[.zip].ts
- [x] ./api+/public-stats.ts
- [x] ./api+/utils.parse-markdown.ts
- [x] ./api+/user.prefs.dismiss-support-banner.ts
- [x] ./api+/user.prefs.minimized-sidebar.ts
- [x] ./api+/image.$imageId.ts
- [x] ./api+/user.change-current-organization.ts
- [x] ./api+/sse.notification.ts
- [x] ./api+/asset.refresh-main-image.ts
- [x] ./api+/oss-friends.ts
- [x] ./api+/user.prefs.skip-onboarding-checklist.ts
- [x] ./api+/admin.export-org-assets.$organizationId.$fileName[.csv].tsx
- [x] ./api+/admin.import-org-assets.$organizationId.tsx
- [x] ./api+/stripe-webhook.ts
- [x] ./api+/client-notification.ts
- [x] ./_welcome+/onboarding.tsx
- [x] ./_welcome+/_layout.tsx
- [x] ./_welcome+/welcome.tsx
- [x] ./_layout+/$.tsx
- [x] ./_layout+/settings.tsx
- [x] ./_layout+/assets._index.tsx
- [x] ./_layout+/assets.$assetId.qr.tsx
- [x] ./_layout+/assets.$assetId.give-custody.tsx
- [x] ./_layout+/assets.$assetId.update-location.tsx
- [x] ./_layout+/assets.export.$fileName[.csv].tsx
- [x] ./_layout+/assets.new.tsx
- [x] ./_layout+/assets.$assetId.note.tsx
- [x] ./_layout+/assets.import.tsx
- [x] ./layout+/assets.$assetId.edit.tsx
- [x] ./_layout+/assets.$assetId.duplicate.tsx
- [x] ./_layout+/assets.$assetId.tsx
- [x] ./_layout+/assets.$assetId.release-custody.tsx
- [x] ./_layout+/assets.tsx
- [x] ./_layout+/locations.new.tsx
- [x] ./_layout+/locations.$locationId.add-assets.tsx
- [x] ./_layout+/locations.tsx
- [x] ./layout+/locations.$locationId.edit.tsx
- [x] ./_layout+/locations.$locationId.tsx
- [x] ./_layout+/locations._index.tsx
- [x] ./_layout+/admin-dashboard+/$userId.tsx
- [x] ./_layout+/admin-dashboard+/org.$organizationId.tsx
- [x] ./_layout+/admin-dashboard+/users.tsx
- [x] ./_layout+/admin-dashboard+/_layout.tsx
- [x] ./_layout+/admin-dashboard+/announcements.tsx
- [x] ./_layout+/admin-dashboard+/announcements.new.tsx
- [x] ./_layout+/dashboard.tsx
- [x] ./_layout+/bookings.new.tsx
- [x] ./_layout+/bookings.tsx
- [x] ./_layout+/bookings.$bookingId.tsx
- [x] ./_layout+/bookings.$bookingId.add-assets.tsx
- [x] ./_layout+/categories.new.tsx
- [x] ./_layout+/categories.tsx
- [x] ./layout+/categories.$categoryId.edit.tsx
- [x] ./_layout+/tags.tsx
- [x] ./layout+/tags.$tagId.edit.tsx
- [x] ./_layout+/tags.new.tsx
- [x] ./_layout+/settings.subscription.customer-portal.tsx
- [x] ./_layout+/settings.subscription.tsx
- [x] ./_layout+/settings.team.tsx
- [x] ./_layout+/settings.workspace.tsx
- [x] ./_layout+/settings.workspace.index.tsx
- [x] ./_layout+/settings.workspace.$workspaceId.edit.tsx
- [x] ./_layout+/settings.workspace.new.tsx
- [x] ./_layout+/settings.account.tsx
- [x] ./layout+/settings.custom-fields.$fieldId.edit.tsx
- [x] ./_layout+/settings.general.tsx
- [x] ./_layout+/settings.team.invite-user.tsx
- [x] ./_layout+/settings.custom-fields.index.tsx
- [x] ./_layout+/settings.custom-fields.tsx
- [x] ./_layout+/settings.index.tsx
- [x] ./_layout+/settings.custom-fields.new.tsx
- [x] ./_layout+/settings.team.add-member.tsx
- [x] ./_layout+/_layout.tsx
- [x] ./_auth+/login.tsx
- [x] ./_auth+/join.tsx
- [x] ./_auth+/oauth.callback.tsx
- [x] ./_auth+/_auth.tsx
- [x] ./_auth+/logout.tsx
- [x] ./_auth+/send-magic-link.tsx
- [x] ./_auth+/accept-invite.$inviteId.tsx
- [x] ./_auth+/resend-email-confirmation.tsx
- [x] ./_auth+/reset-password.tsx
- [x] ./_auth+/forgot-password.tsx
- [x] ./_auth+/verify-email.tsx
- [x] ./healthcheck.tsx
- [x] ./qr+/$qrId_.not-logged-in.tsx
- [x] ./qr+/$qrId.tsx
- [x] ./qr+/route.tsx
- [x] ./qr+/$qrId_.contact-owner.tsx
- [x] ./qr+/$qrId_.link.tsx
- [x] ./_index.tsx
This has been completed and released already long time ago.