feat(mcp): admin token CRUD HTTP handler (POST/GET/DELETE) + TokenService.List/GetByID

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-08 11:04:37 +08:00
parent 2d6521e610
commit d0efe2bdd4
3 changed files with 207 additions and 0 deletions
+10
View File
@@ -23,6 +23,8 @@ type TokenService interface {
Authenticate(ctx context.Context, plaintext string) (*Token, error)
Revoke(ctx context.Context, id, byUserID uuid.UUID) error
RevokeBySession(ctx context.Context, sessionID uuid.UUID) error
List(ctx context.Context, callerUserID *uuid.UUID, activeOnly bool) ([]*Token, error)
GetByID(ctx context.Context, id uuid.UUID) (*Token, error)
}
// IssueAdminInput 是 admin 签发时的入参。UserID 缺省 = 当前 admin 自己(由调用方填)。
@@ -278,3 +280,11 @@ func (s *tokenService) RevokeBySession(ctx context.Context, sessionID uuid.UUID)
}
return nil
}
func (s *tokenService) List(ctx context.Context, callerUserID *uuid.UUID, activeOnly bool) ([]*Token, error) {
return s.repo.List(ctx, callerUserID, activeOnly)
}
func (s *tokenService) GetByID(ctx context.Context, id uuid.UUID) (*Token, error) {
return s.repo.GetByID(ctx, id)
}