Added a showapikeys management command, to be able to easily see the api keys.
- Legacy-Id: 17935
This commit is contained in:
parent
542c165907
commit
0ba2c93d7f
21
ietf/api/management/commands/showapikeys.py
Normal file
21
ietf/api/management/commands/showapikeys.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
# Copyright The IETF Trust 2018-2020, All Rights Reserved
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
import debug # pyflakes:ignore
|
||||
|
||||
from ietf.person.models import PersonalApiKey
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
||||
help = 'Show existing personal API keys'
|
||||
|
||||
def add_arguments(self, parser):
|
||||
pass
|
||||
|
||||
def handle(self, *args, **options):
|
||||
format = "%-36s %-24s %-64s %-16s"
|
||||
self.stdout.write(format % ('Endpoint', 'Login', 'Key', 'Used'))
|
||||
for key in PersonalApiKey.objects.filter():
|
||||
self.stdout.write(format % (key.endpoint, key.person.user.username, key.hash(), key.latest.strftime('%Y-%m-%d %H:%M') if key.latest else ''))
|
Loading…
Reference in a new issue