dataaccessclient

package
v1.42.3 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package dataaccessclient holds client-side plumbing shared by the iam-data-access smoke test and its bootstrap-ancestor-grant tool. It has no build tag on purpose: the smoke test package is //go:build smoke and the bootstrap tool is untagged, and neither could import the other directly.

Index

Constants

View Source
const AncestorID = "019f7f64-768f-7e71-ac3d-ca6d41ad16de"

AncestorID is the fixed object id the smoke-test service account holds a standing relationships-admin grant on. See docs/smoke-tests.md.

View Source
const ArtifactAdminRoleID = "019ed9d4-7d50-7249-9baa-52594d2d645b"

ArtifactAdminRoleID is the "Artifact Admin" role, the only role accepted for a grant on a non-organization object. See docs/smoke-tests.md.

View Source
const GatewayHeaderName = "x-gitlab-svc"

GatewayHeaderName is the header the GATE sandbox's L1 gateway routes on. Fixed; only the value varies per target service.

View Source
const ServiceTokenHeader = "gitlab-iam-data-access-token"

ServiceTokenHeader is the metadata header carrying the iam-data-access service token.

Variables

This section is empty.

Functions

func AssignmentInput

AssignmentInput builds a relationship granting subject the Artifact Admin role on object — the only role WriteRelationships accepts for a non-organization object.

func AuthContext

func AuthContext(ctx context.Context, serviceToken, jwt, gatewayHeaderValue string) context.Context

AuthContext returns ctx carrying the service token and end-user JWT a data-access caller needs, plus the gateway routing header.

func Dial

func Dial(addr string, insecureConn bool) (*grpc.ClientConn, error)

Dial opens a gRPC client connection to addr. TLS is used by default; pass insecure=true only for local testing against a plaintext dev instance.

func GatewayContext added in v1.39.2

func GatewayContext(ctx context.Context, gatewayHeaderValue string) context.Context

GatewayContext returns ctx carrying only the gateway routing header. Needed even for RPCs that take no credentials: the sandbox's L1 gateway routes on this header alone, and without it the call lands on GitLab Rails, which answers with an HTML error page rather than gRPC. An empty gatewayHeaderValue adds nothing, for a target reached directly (Runway).

func MintJWT

func MintJWT(ctx context.Context, railsBaseURL, pat string) (string, error)

MintJWT calls Rails' /token_exchange endpoint and returns the signed JWT. pat must belong to a dedicated GitLab Service Account, not a CI job token or a human user's token — see docs/smoke-tests.md for why.

func Subject

func Subject(id Identity) *relationshipspb.Subject

Subject builds the subject.identity message for id. Origin is always ORIGIN_ORGANIZATION: token exchange only mints organization-scoped identities.

Types

type Identity

type Identity struct {
	OriginID         string
	LocalID          string
	OrganizationRole string
}

Identity is the subset of the nested `gitlab` claim these clients need to build a matching subject.identity. Origin isn't included: callers always use ORIGIN_ORGANIZATION, since token exchange only mints organization-scoped user identities.

func DecodeIdentity

func DecodeIdentity(jwt string) (Identity, error)

DecodeIdentity reads the `gitlab` claim out of a JWT's payload segment. It does not verify the signature: the token came straight from Rails over TLS using our own PAT, so there's no untrusted party to verify against.

Jump to

Keyboard shortcuts

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