IssueServiceAuthToken issues a new auth token for a service account.
(ctx context.Context, req *adminv1.IssueServiceAuthTokenRequest)
| 479 | |
| 480 | // IssueServiceAuthToken issues a new auth token for a service account. |
| 481 | func (s *Server) IssueServiceAuthToken(ctx context.Context, req *adminv1.IssueServiceAuthTokenRequest) (*adminv1.IssueServiceAuthTokenResponse, error) { |
| 482 | observability.AddRequestAttributes(ctx, |
| 483 | attribute.String("args.service_name", req.ServiceName), |
| 484 | attribute.String("args.organization_name", req.Org), |
| 485 | ) |
| 486 | |
| 487 | org, err := s.admin.DB.FindOrganizationByName(ctx, req.Org) |
| 488 | if err != nil { |
| 489 | return nil, err |
| 490 | } |
| 491 | |
| 492 | service, err := s.admin.DB.FindServiceByName(ctx, org.ID, req.ServiceName) |
| 493 | if err != nil { |
| 494 | return nil, err |
| 495 | } |
| 496 | |
| 497 | claims := auth.GetClaims(ctx) |
| 498 | if !claims.OrganizationPermissions(ctx, org.ID).ManageOrg { |
| 499 | return nil, status.Error(codes.PermissionDenied, "not allowed to update org") |
| 500 | } |
| 501 | |
| 502 | token, err := s.admin.IssueServiceAuthToken(ctx, service.ID, nil) |
| 503 | if err != nil { |
| 504 | return nil, err |
| 505 | } |
| 506 | |
| 507 | return &adminv1.IssueServiceAuthTokenResponse{ |
| 508 | Token: token.Token().String(), |
| 509 | }, nil |
| 510 | } |
| 511 | |
| 512 | // RevokServiceAuthToken revokes an auth token for a service account. |
| 513 | func (s *Server) RevokeServiceAuthToken(ctx context.Context, req *adminv1.RevokeServiceAuthTokenRequest) (*adminv1.RevokeServiceAuthTokenResponse, error) { |
nothing calls this directly
no test coverage detected