mirror of
https://framagit.org/framasoft/framaspace/argos.git
synced 2025-04-28 18:02:41 +02:00
✨ — Add a command to generate an auth token (fix #22)
This commit is contained in:
parent
e264f8a068
commit
168788eb89
2 changed files with 37 additions and 5 deletions
|
@ -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 agent’s authentication token.
|
||||||
|
|
||||||
|
It’s actually an UUID
|
||||||
|
"""
|
||||||
|
click.echo(uuid4())
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
cli()
|
cli()
|
||||||
|
|
23
docs/cli.md
23
docs/cli.md
|
@ -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 agent’s...
|
||||||
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 agent’s authentication token.
|
||||||
|
|
||||||
|
It’s actually an UUID
|
||||||
|
|
||||||
|
Options:
|
||||||
|
--help Show this message and exit.
|
||||||
|
```
|
||||||
|
|
||||||
|
<!--[[[end]]]
|
||||||
|
-->
|
||||||
|
|
Loading…
Reference in a new issue