Skip to content

Commit

Permalink
API Key Creation & Management
Browse files Browse the repository at this point in the history
Added functionality for superusers and users to create and manage API keys, with Knox integration for secure key hashing.
  • Loading branch information
NEZRI Ygal authored and NEZRI Ygal committed Jul 22, 2024
1 parent 6f8c71c commit 7261942
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Watcher/Watcher/accounts/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,4 +296,15 @@ def delete_authtoken_when_apikey_deleted(sender, instance, **kwargs):
if instance.auth_token:
instance.auth_token.delete()
except AuthToken.DoesNotExist:
pass
pass


class AuthTokenAdmin(admin.ModelAdmin):
list_display = ('user', 'digest', 'created', 'expiry')
readonly_fields = ('user', 'digest', 'created', 'expiry')

def has_add_permission(self, request):
return False

admin.site.unregister(AuthToken)
admin.site.register(AuthToken, AuthTokenAdmin)

0 comments on commit 7261942

Please sign in to comment.