mirror of
https://github.com/thatmattlove/hyperglass.git
synced 2026-01-17 08:48:05 +00:00
swapping API key hash validating so that plain text key is stored on the secure device
This commit is contained in:
parent
23f8c0bdd7
commit
892b9ebcfc
2 changed files with 23 additions and 0 deletions
22
manage.py
22
manage.py
|
|
@ -2,7 +2,11 @@
|
|||
import os
|
||||
import sys
|
||||
import click
|
||||
import random
|
||||
import string
|
||||
from logzero import logger
|
||||
from passlib.hash import pbkdf2_sha256
|
||||
|
||||
from hyperglass import render as render
|
||||
from hyperglass import hyperglass
|
||||
|
||||
|
|
@ -22,6 +26,24 @@ def clearcache():
|
|||
logger.error("Failed to clear cache.")
|
||||
|
||||
|
||||
@main.command()
|
||||
def generatekey(string_length=16):
|
||||
ld = string.ascii_letters + string.digits
|
||||
api_key = "".join(random.choice(ld) for i in range(string_length))
|
||||
key_hash = pbkdf2_sha256.hash(api_key)
|
||||
click.echo(
|
||||
"""
|
||||
Your API Key is: {api_key}
|
||||
Place your API Key in the `configuration.py` of your API module. For example, in: `hyperglass-frr/configuration.py`
|
||||
|
||||
Your Key Hash is: {key_hash}
|
||||
Use this hash as the password for the device using the API module. For example, in: `hyperglass/hyperglass/configuration/devices.toml`
|
||||
""".format(
|
||||
api_key=api_key, key_hash=key_hash
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@main.command()
|
||||
def testserver():
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -9,3 +9,4 @@ markdown2
|
|||
libsass
|
||||
logzero
|
||||
click
|
||||
passlib
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue