🔀 Merge branch 'fix-22' into 'main'

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

Closes #22

See merge request framasoft/framaspace/argos!37
This commit is contained in:
Luc Didry 2024-03-27 15:19:52 +00:00
commit c79054b48b
2 changed files with 37 additions and 5 deletions

View file

@ -1,6 +1,7 @@
import asyncio import asyncio
import os import os
from functools import wraps from functools import wraps
from uuid import uuid4
import click import click
import uvicorn import uvicorn
@ -167,5 +168,15 @@ async def migrate():
command.upgrade(alembic_cfg, "head") 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__": if __name__ == "__main__":
cli() cli()

View file

@ -33,7 +33,7 @@ Commands:
<!--[[[end]]] <!--[[[end]]]
--> -->
## Agent commands ## Agent command
<!-- <!--
.. [[[cog .. [[[cog
help(["agent", "--help"]) help(["agent", "--help"])
@ -78,6 +78,7 @@ Options:
Commands: Commands:
cleandb Clean the database (to run routinely) cleandb Clean the database (to run routinely)
generate-token Generate a token, which can be used as an agents...
migrate Run database migrations migrate Run database migrations
reload-config Read tasks config and add/delete tasks in database if... reload-config Read tasks config and add/delete tasks in database if...
start Starts the server start Starts the server
@ -172,3 +173,23 @@ Options:
<!--[[[end]]] <!--[[[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]]]
-->