Skip to content

Commit 0ba2c93

Browse files
committed
Added a showapikeys management command, to be able to easily see the api keys.
- Legacy-Id: 17935
1 parent 542c165 commit 0ba2c93

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright The IETF Trust 2018-2020, All Rights Reserved
2+
# -*- coding: utf-8 -*-
3+
4+
from django.core.management.base import BaseCommand
5+
6+
import debug # pyflakes:ignore
7+
8+
from ietf.person.models import PersonalApiKey
9+
10+
class Command(BaseCommand):
11+
12+
help = 'Show existing personal API keys'
13+
14+
def add_arguments(self, parser):
15+
pass
16+
17+
def handle(self, *args, **options):
18+
format = "%-36s %-24s %-64s %-16s"
19+
self.stdout.write(format % ('Endpoint', 'Login', 'Key', 'Used'))
20+
for key in PersonalApiKey.objects.filter():
21+
self.stdout.write(format % (key.endpoint, key.person.user.username, key.hash(), key.latest.strftime('%Y-%m-%d %H:%M') if key.latest else ''))

0 commit comments

Comments
 (0)