workloadjwt

package
v0.19.1154 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package workloadjwt verifies cloud-issued workload identity JWTs.

Callers supply the issuer and audience; they are never read out of the presented token, so an unauthenticated caller cannot steer which key set is trusted.

Index

Constants

View Source
const AzureManagementAudience = "https://management.azure.com/"

Graph looks like the safer audience -- a token for a role-less identity can do nothing -- but Microsoft signs Graph access tokens with a key that is not in the tenant JWKS, so a third party cannot verify them. ARM tokens are ordinary v1 tokens and verify against the tenant keys, which is why runner auth already uses this audience.

The identity is created with no role assignments, so an ARM token minted for it is authorized for nothing either.

Variables

This section is empty.

Functions

func AzureIssuer

func AzureIssuer(tenantID string) (string, error)

AzureIssuer builds the v1 Entra issuer for a tenant. IMDS mints v1 tokens, so the issuer is sts.windows.net rather than the v2 login.microsoftonline.com form.

func AzurePhoneHomeIdentityName

func AzurePhoneHomeIdentityName(installID string) string

Rendered into the ARM template and compared against the verified xms_mirid, so both sides must stay in step.

func StringClaim

func StringClaim(claims map[string]any, name string) (string, bool)

StringClaim reads a string claim. A claim of any other type is treated as absent rather than coerced.

func UnverifiedClaims

func UnverifiedClaims(token string) (map[string]any, error)

UnverifiedClaims decodes claims without checking the signature. Only for selecting which key set to verify against; never for authorization.

Types

type AzureManagedIdentity

type AzureManagedIdentity struct {
	SubscriptionID string
	ResourceGroup  string
	Name           string
	PrincipalID    string
	TenantID       string
}

func ParseAzureManagedIdentity

func ParseAzureManagedIdentity(claims map[string]any) (*AzureManagedIdentity, error)

Only user-assigned identities are accepted. A system-assigned identity puts the compute resource in xms_mirid -- the runner's VMSS is one -- so a loose shape check would let a runner token pass as a phone-home identity.

type Request

type Request struct {
	Token    string
	Issuer   string
	Audience string
}

type Verifier

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

func NewVerifier

func NewVerifier() *Verifier

func (*Verifier) Verify

func (v *Verifier) Verify(ctx context.Context, req Request) (map[string]any, error)

Verify checks signature, issuer, audience and time claims.

A valid signature only establishes which cloud tenant minted the token, not that it is the right one, so callers must bind the returned claims to stored state.

Jump to

Keyboard shortcuts

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