[Feature Request] Role based authorization
- Linguagem predominante
- TypeScript
- Estrelas
- 2
- Forks
- 0
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
# Overview
There are various pages and functionality that are specific to certain roles, such as an admin. Additionally, this provides the groundwork for future functionality such as customizing a user's. Access to these resources need to be restricted and authorized based on the user's role.
Authorization will be handled with a roles based system where a collection, namely the authorization collection, will hold documents containing the associated UserId from the User's collection as well as the roles array.
# Tasks
- [ ] Add authorization collection to db
- [ ] Write function get a user's roles from db. This might include adding an index into FaunaDB, writing a custom FQL function to get roles based on UserId
- [ ] Create auth wrapper component that authenticates users based on role
- [ ] Restrict access to admin routes to users with admin role
# Supplemental Information
* The design decision to segregate roles into the authorization collection, instead of the user collection, is done in part to avoid modifying the default NextAuth schema. This avoids the need to write a custom database adapter.
* https://next-auth.js.org/adapters/models
Guia de contribuição
Nenhum guia de contribuição indexado para este repositório
Direção de pesquisa
No files or tests are named in the issue. Start by locating the existing NextAuth setup and any current route-guard/auth middleware, then inspect how admin routes are defined and where user session data is attached. Next, find where FaunaDB queries are currently made so the authorization-collection role lookup can be added for a role-based wrapper, and finish by confirming admin pages are inaccessible to non-admin users while remaining accessible to admins.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- next.js, typescript
- Domínio
- security
- Tipo de issue
- Funcionalidade
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 32/100