— Add a command to generate an auth token (fix #22)

This commit is contained in:
Luc Didry 2024-03-25 14:57:23 +01:00
parent e264f8a068
commit 168788eb89
No known key found for this signature in database
GPG key ID: EA868E12D0257E3C
2 changed files with 37 additions and 5 deletions

View file

@ -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 agents authentication token.
Its actually an UUID
"""
click.echo(uuid4())
if __name__ == "__main__":
cli()

View file

@ -33,7 +33,7 @@ Commands:
<!--[[[end]]]
-->
## Agent commands
## Agent command
<!--
.. [[[cog
help(["agent", "--help"])
@ -78,6 +78,7 @@ Options:
Commands:
cleandb Clean the database (to run routinely)
generate-token Generate a token, which can be used as an agents...
migrate Run database migrations
reload-config Read tasks config and add/delete tasks in database if...
start Starts the server
@ -172,3 +173,23 @@ Options:
<!--[[[end]]]
-->
### Server generate-token command
<!--
.. [[[cog
help(["server", "generate-token", "--help"])
.. ]]] -->
```man
Usage: argos server generate-token [OPTIONS]
Generate a token, which can be used as an agents authentication token.
Its actually an UUID
Options:
--help Show this message and exit.
```
<!--[[[end]]]
-->