mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 14:52:15 +00:00
Add permissions to API keys
This commit is contained in:
@@ -2,14 +2,28 @@ import uuid
|
||||
from django.db import models
|
||||
|
||||
|
||||
class AuthAPIKeyPermission(models.Model):
|
||||
""" Auth API Key permissions """
|
||||
key = models.CharField("Permission Key", max_length=32)
|
||||
name = models.CharField("Permission Name", max_length=200)
|
||||
|
||||
def __unicode__(self):
|
||||
return self.name
|
||||
|
||||
class Meta:
|
||||
verbose_name = 'API Key Permission'
|
||||
verbose_name_plural = 'API Key Permissions'
|
||||
|
||||
|
||||
class AuthAPIKey(models.Model):
|
||||
""" Auth API Key storage model """
|
||||
|
||||
name = models.CharField("Service Name", max_length=200)
|
||||
url = models.CharField("Service URL", max_length=200, blank=True, help_text="URL that the service is available at")
|
||||
url = models.CharField("Service URL", max_length=200, blank=True, help_text="URL that the service is available at.")
|
||||
active = models.BooleanField(default=True)
|
||||
key = models.CharField("API Key", max_length=200, blank=True, help_text="API key for the service to use")
|
||||
callback = models.CharField("Callback URL", max_length=200, blank=True, help_text="URL for the callback service to connect to")
|
||||
key = models.CharField("API Key", max_length=200, blank=True, help_text="API key for the service to use.")
|
||||
callback = models.CharField("Callback URL", max_length=200, blank=True, help_text="URL for the callback service to connect to.")
|
||||
permissions = models.ManyToManyField(AuthAPIKeyPermission, related_name='keys', help_text="API calls this API key is allowed to access.")
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
if not self.key or self.key == '':
|
||||
|
||||
Reference in New Issue
Block a user