serviceaccounts

package
v1.18.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

README

pkg/handler/serviceaccounts

This package manages organization-local non-human identities.

Intent

Structurally, this package is the service-account analogue of pkg/handler/users, but with one important extra responsibility: issued credential lifecycle.

It manages service accounts that:

  • exist only within an organization scope
  • inherit authority indirectly through groups and roles
  • receive issued access tokens from identity

What Is Specific Here

Organization-Local Actor Model

Unlike users, service accounts do not have a separate global identity layer plus an organization-membership layer.

They are already organization-local actors, so this package operates directly on the organization-scoped service account resource.

Group-Based Authority Inheritance

Like users, service accounts do not receive roles directly here.

The package reconciles groupIDs into group membership, and those groups then define the effective authority of the service account through their RoleIDs.

So this client participates in the same local delegation model as users, but without the global identity split.

Token Issuance And Rotation

This is the main behavioural difference from the users client.

Creating a service account also issues an access token. Updating metadata preserves the existing token. Rotation is an explicit lifecycle operation that:

  • issues a replacement token
  • stores the new token and expiry on the resource
  • invalidates the old token

Delete also invalidates the current token after unlinking group membership.

That makes this package both an identity-binding client and a credential-lifecycle client.

Invariants

  • service accounts are organization-bound actors
  • service-account authority is still mediated through groups and roles
  • create returns freshly issued credentials
  • ordinary update preserves the current token
  • rotate replaces the token and invalidates the old one
  • delete removes group membership and invalidates the token

Caveats

  • Like pkg/handler/users, this package performs best-effort multi-object consistency across service accounts and groups on top of Kubernetes storage rather than an ACID backing store.
  • The current access token is stored on the service-account resource and returned on create/rotate, so token-handling mistakes have more impact here than in most handler clients.
  • The package is intentionally similar to the users client; the main value in documenting it is the lack of a global identity layer and the explicit token rotation lifecycle.
  • pkg/handler/users, which shows the structurally similar human-identity path with a global identity layer
  • pkg/handler/groups, which binds service accounts to roles
  • pkg/oauth2, which defines the issued token model and invalidation behaviour consumed here

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is responsible for service account management.

func New

func New(client client.Client, namespace string, issuer common.IssuerValue, oauth2 *oauth2.Authenticator, options *Options) *Client

New creates a new service account client.

func (*Client) Create

Create makes a new service account and issues an access token.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, organizationID ids.OrganizationID, serviceAccountID string) error

Delete removes the service account and revokes the access token.

func (*Client) Get

func (c *Client) Get(ctx context.Context, organizationID ids.OrganizationID, serviceAccountID string) (*openapi.ServiceAccountRead, error)

Get retrieves information about a service account.

func (*Client) List

func (c *Client) List(ctx context.Context, organizationID ids.OrganizationID) (openapi.ServiceAccounts, error)

List retrieves information about all service accounts in the organization.

func (*Client) Rotate

func (c *Client) Rotate(ctx context.Context, organizationID ids.OrganizationID, serviceAccountID string) (*openapi.ServiceAccountCreate, error)

Rotate is a special version of Update where everything about the resource is preserved with the exception of the access token.

func (*Client) Update

func (c *Client) Update(ctx context.Context, organizationID ids.OrganizationID, serviceAccountID string, request *openapi.ServiceAccountWrite) (*openapi.ServiceAccountRead, error)

Update modifies any metadata for the service account if it exists. If a matching account doesn't exist it raises an error.

type Options

type Options struct {
	// contains filtered or unexported fields
}

func (*Options) AddFlags

func (o *Options) AddFlags(f *pflag.FlagSet)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL