From 168788eb89dff5403c895e5cee1a86f36dd9255c Mon Sep 17 00:00:00 2001 From: Luc Didry Date: Mon, 25 Mar 2024 14:57:23 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E2=80=94=20Add=20a=20command=20to?= =?UTF-8?q?=20generate=20an=20auth=20token=20(fix=20#22)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- argos/commands.py | 11 +++++++++++ docs/cli.md | 31 ++++++++++++++++++++++++++----- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/argos/commands.py b/argos/commands.py index ec694e5..dda39dc 100644 --- a/argos/commands.py +++ b/argos/commands.py @@ -1,6 +1,7 @@ import asyncio import os from functools import wraps +from uuid import uuid4 import click import uvicorn @@ -167,5 +168,15 @@ async def migrate(): command.upgrade(alembic_cfg, "head") +@server.command() +@coroutine +async def generate_token(): + """Generate a token, which can be used as an agent’s authentication token. + + It’s actually an UUID + """ + click.echo(uuid4()) + + if __name__ == "__main__": cli() diff --git a/docs/cli.md b/docs/cli.md index 711f834..5969771 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -26,14 +26,14 @@ Options: --help Show this message and exit. Commands: - agent Get and run tasks to the provided server. + agent Get and run tasks to the provided server. server ``` -## Agent commands +## Agent command +### Server generate-token command + + + +```man +Usage: argos server generate-token [OPTIONS] + + Generate a token, which can be used as an agent’s authentication token. + + It’s actually an UUID + +Options: + --help Show this message and exit. +``` + +