graphql-python / graphql-python/graphene-django
Permission System
- Lingua principale
- Python
- Stelle
- 4.4k
- Fork
- 760
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
I would like to add a permission system but want to some feedback on the API before I implement.
You would have two options and I'm proposing to add both:
## Option 1: Custom queryset method
This option would let you overwrite how a queryset is filtered.
```python
class UserNode(DjangoObjectType):
class Meta:
model = User
interfaces = (relay.Node,)
only_fields = ('email', 'first_name', 'last_name')
@classmethod
def get_queryset (cls, queryset, args, request, info):
return queryset.filter(owner=request.user)
```
## Option 2: Permissions List
This option would setup a Meta API to use to define permissions
```python
def auth_required(queryset, args, request, info):
if request.user.is_authenticated():
return queryset
return queryset.none()
class UserNode(DjangoObjectType):
class Meta:
model = User
interfaces = (relay.Node,)
only_fields = ('email', 'first_name', 'last_name')
permissions = [auth_required]
```
If these look like good APIs then I'll implement.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Esamina le due API proposte per DjangoObjectType: un metodo get_queryset personalizzato e un elenco di permessi in Meta. L’issue non indica file né test, quindi esamina la gestione esistente di DjangoObjectType e Meta prima di valutare la fattibilità. Il completamento richiede che l’API venga concordata prima di iniziare l’implementazione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- django, graphql, python
- Ambito
- authorization, backend-api-design
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100