feat: add service token rename command (#40)
* docs: preserve original issue 5 body * feat: add service token rename command * test: normalize rich option errors
This commit is contained in:
@@ -1128,6 +1128,37 @@ class PostgresPortfolioRepository:
|
||||
return None
|
||||
return self._row_to_auth_token(row)
|
||||
|
||||
def rename_service_token(self, name: str, new_name: str) -> AuthToken:
|
||||
self.ensure_schema()
|
||||
with self._connect().cursor() as cur:
|
||||
cur.execute(
|
||||
"""
|
||||
UPDATE auth_tokens
|
||||
SET name = %s
|
||||
WHERE name = %s
|
||||
AND token_type = 'service'
|
||||
AND revoked_at IS NULL
|
||||
RETURNING
|
||||
id,
|
||||
user_id,
|
||||
name,
|
||||
token_prefix,
|
||||
permission,
|
||||
token_type,
|
||||
expires_at,
|
||||
last_used_at,
|
||||
revoked_at,
|
||||
created_at,
|
||||
runtime_id,
|
||||
daemon_id
|
||||
""",
|
||||
(new_name, name),
|
||||
)
|
||||
row = cur.fetchone()
|
||||
if row is None:
|
||||
raise ValueError(f"서비스 토큰을 찾을 수 없습니다: {name}")
|
||||
return self._row_to_auth_token(row)
|
||||
|
||||
def get_token_principal(self, token_hash: str) -> TokenPrincipal | None:
|
||||
self.ensure_schema()
|
||||
with self._connect().cursor() as cur:
|
||||
|
||||
Reference in New Issue
Block a user