1
0
mirror of https://github.com/checktheroads/hyperglass synced 2024-05-11 05:55:08 +00:00

swapping API key hash validating so that plain text key is stored on the secure device

This commit is contained in:
checktheroads
2019-05-23 19:26:09 -07:00
parent 23f8c0bdd7
commit 892b9ebcfc
2 changed files with 23 additions and 0 deletions

View File

@@ -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:

View File

@@ -9,3 +9,4 @@ markdown2
libsass
logzero
click
passlib