MCPcopy Create free account
hub / github.com/rilldata/rill / RevokeServiceAuthToken

Method RevokeServiceAuthToken

admin/server/service.go:513–544  ·  view source on GitHub ↗

RevokServiceAuthToken revokes an auth token for a service account.

(ctx context.Context, req *adminv1.RevokeServiceAuthTokenRequest)

Source from the content-addressed store, hash-verified

511
512// RevokServiceAuthToken revokes an auth token for a service account.
513func (s *Server) RevokeServiceAuthToken(ctx context.Context, req *adminv1.RevokeServiceAuthTokenRequest) (*adminv1.RevokeServiceAuthTokenResponse, error) {
514 observability.AddRequestAttributes(ctx,
515 attribute.String("args.token_id", req.TokenId),
516 )
517
518 token, err := s.admin.DB.FindServiceAuthToken(ctx, req.TokenId)
519 if err != nil {
520 return nil, err
521 }
522
523 service, err := s.admin.DB.FindService(ctx, token.ServiceID)
524 if err != nil {
525 return nil, err
526 }
527
528 org, err := s.admin.DB.FindOrganization(ctx, service.OrgID)
529 if err != nil {
530 return nil, err
531 }
532
533 claims := auth.GetClaims(ctx)
534 if !claims.OrganizationPermissions(ctx, org.ID).ManageOrg {
535 return nil, status.Error(codes.PermissionDenied, "not allowed to revoke auth token")
536 }
537
538 err = s.admin.DB.DeleteServiceAuthToken(ctx, token.ID)
539 if err != nil {
540 return nil, err
541 }
542
543 return &adminv1.RevokeServiceAuthTokenResponse{}, nil
544}
545
546func serviceToPB(service *database.Service, orgName string) *adminv1.Service {
547 attr, err := structpb.NewStruct(service.Attributes)

Callers

nothing calls this directly

Calls 9

AddRequestAttributesFunction · 0.92
GetClaimsFunction · 0.92
StringMethod · 0.65
FindServiceAuthTokenMethod · 0.65
FindServiceMethod · 0.65
FindOrganizationMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected