feat(auth): Add python script to create new api keys
This commit is contained in:
20
cmd/api-key.py
Normal file
20
cmd/api-key.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import secrets
|
||||
import uuid
|
||||
import base64
|
||||
|
||||
from argon2 import PasswordHasher
|
||||
|
||||
new_secret = secrets.token_hex(32)
|
||||
print(new_secret)
|
||||
|
||||
ph = PasswordHasher()
|
||||
hashed_secret = ph.hash(new_secret)
|
||||
|
||||
new_id = uuid.uuid4()
|
||||
|
||||
plain_secret = f"{new_id}:{new_secret}"
|
||||
base64_secret = base64.b64encode(plain_secret.encode()).decode()
|
||||
print(f"Secret: {base64_secret}")
|
||||
print(f"ID: {new_id}")
|
||||
print(f"Hashed Secret: {hashed_secret}")
|
||||
print(f"X-Api-Key: {base64_secret}")
|
||||
Reference in New Issue
Block a user