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

Method IssueServiceAuthToken

admin/server/service.go:481–510  ·  view source on GitHub ↗

IssueServiceAuthToken issues a new auth token for a service account.

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

Source from the content-addressed store, hash-verified

479
480// IssueServiceAuthToken issues a new auth token for a service account.
481func (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.
513func (s *Server) RevokeServiceAuthToken(ctx context.Context, req *adminv1.RevokeServiceAuthTokenRequest) (*adminv1.RevokeServiceAuthTokenResponse, error) {

Callers

nothing calls this directly

Calls 9

AddRequestAttributesFunction · 0.92
GetClaimsFunction · 0.92
StringMethod · 0.65
FindServiceByNameMethod · 0.65
IssueServiceAuthTokenMethod · 0.65
TokenMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected