작업 내용 저장

This commit is contained in:
2026-04-23 10:16:09 +00:00
parent d383c7086f
commit bc56c5c101
7 changed files with 307 additions and 1 deletions
+32 -1
View File
@@ -2,10 +2,13 @@
from __future__ import annotations
from typing import Optional
import typer
from app.cli.core.output import mask_token_text, render_service_token_result
from app.schemas.auth import ServiceTokenIssueCliResponse, ServiceTokenRevokeCliResponse
from app.cli.core.utils import render_output
from app.schemas.auth import AuthTokenResponse, ServiceTokenIssueCliResponse, ServiceTokenRevokeCliResponse
from app.services.auth_service import AuthService
token_app = typer.Typer(help="Service token lifecycle commands.")
@@ -23,6 +26,34 @@ def _with_service(ctx: typer.Context, callback):
repository.close()
@token_app.command("list")
def list_service_tokens(
ctx: typer.Context,
user: Optional[str] = typer.Option(None, "--user", help="Filter by username."),
show_revoked: bool = typer.Option(False, "--show-revoked", help="Include revoked tokens."),
) -> None:
def _list(service: AuthService, app_context):
tokens = service.list_service_tokens(user, include_revoked=show_revoked)
return [
AuthTokenResponse(
id=t.id,
user_id=t.user_id,
name=t.name,
token_prefix=t.token_prefix,
permission=t.permission,
token_type=t.token_type,
expires_at=t.expires_at,
last_used_at=t.last_used_at,
revoked_at=t.revoked_at,
created_at=t.created_at,
)
for t in tokens
]
result = _with_service(ctx, _list)
render_output(ctx.obj.console, ctx.obj.output_format, result, empty_message="No service tokens found.")
@token_app.command("issue")
def issue_service_token(
ctx: typer.Context,