Documentation
¶
Overview ¶
Package iam implements provider-neutral, fail-closed authorization decisions for CloudRING organizations, tenants, projects, support grants, API-token references, break-glass controls, and audit sinks.
A subject or API-token reference never authenticates itself. Policy denies unless its configured AuthenticationVerifier returns matching trusted authentication, MFA, session, credential-class, and bounded proof-freshness evidence. OIDCAuthenticationVerifier is the reference adapter that takes the subject from a signed OIDC token rather than from the authorization request.
A Policy is configured by populating its exported maps before it starts serving requests. Once serving begins, callers must treat that configuration as immutable. Authorize and AuditEvents may then be called concurrently when the configured Clock, AuthenticationVerifier, and AuditSink are themselves safe for concurrent use. MemoryAuditSink is bounded, non-durable, and must be explicitly allowed for synthetic or test-only policy. Production decisions require a ready DurableAuditSink. Authorize samples its clock once and uses that instant for authentication, evaluation, and audit.
Index ¶
- Variables
- func AppendDurableSecurityEvent(ctx context.Context, sink SecurityAuditSink, event SecurityEvent) error
- type APIToken
- type Action
- type AuditEvent
- type AuditEventReader
- type AuditReadiness
- type AuditResult
- type AuditSink
- type AuthenticationFunc
- type AuthenticationProof
- type AuthenticationResult
- type AuthenticationVerifier
- type AuthorizationRequest
- type Clock
- type CredentialClass
- type Decision
- type DeniedState
- type DurableAuditSink
- type FailingAuditSink
- type FixedClock
- type IdentityContract
- type LifecycleClaims
- type MFAAssurance
- type MFAMethodClass
- type Membership
- type MemoryAuditSink
- func (sink *MemoryAuditSink) Append(event AuditEvent) error
- func (sink *MemoryAuditSink) AppendSecurityEvent(_ context.Context, event SecurityEvent) error
- func (*MemoryAuditSink) Durable() bool
- func (sink *MemoryAuditSink) Events() []AuditEvent
- func (*MemoryAuditSink) Ready(context.Context) error
- func (sink *MemoryAuditSink) SecurityEvents() []SecurityEvent
- type NamespaceScope
- type OIDCAuthenticationVerifier
- type OIDCProof
- type OIDCProofFunc
- type OIDCProofSource
- type Organization
- type Policy
- type PolicyConfig
- type PolicyState
- type PolicyStateLoader
- type Principal
- type PrincipalRef
- type Project
- type Quotas
- type RequestContext
- type Role
- type RoleCoverage
- type Scenario
- type SecurityAuditSink
- type SecurityEvent
- type SessionAssurance
- type SessionState
- type SourceSafetyClaims
- type Status
- type SupportGrant
- type TargetRef
- type Tenant
- type TenantState
- type VerifyBlocker
- type VerifyCase
- type VerifyCoverage
- type VerifyOptions
- type VerifyReport
Constants ¶
This section is empty.
Variables ¶
var ( ErrUnknownPrincipal = errors.New("iam: unknown principal") ErrUnknownAction = errors.New("iam: unknown action") ErrUnknownTenant = errors.New("iam: unknown tenant") ErrUnknownProject = errors.New("iam: unknown project") ErrCrossTenant = errors.New("iam: cross-tenant access denied") ErrObjectScope = errors.New("iam: object scope denied") ErrTenantSuspended = errors.New("iam: tenant suspended") ErrTenantDeleting = errors.New("iam: tenant deleting") ErrTenantState = errors.New("iam: invalid tenant lifecycle state") ErrLastOwner = errors.New("iam: last owner removal denied") ErrReasonRequired = errors.New("iam: explicit reason required") ErrTicketRequired = errors.New("iam: support ticket reference required") ErrAuditRequired = errors.New("iam: durable audit required") ErrTokenExpired = errors.New("iam: api token expired") ErrTokenRevoked = errors.New("iam: api token revoked") ErrTokenScope = errors.New("iam: api token scope denied") ErrSupportGrant = errors.New("iam: support grant denied") ErrRoleDenied = errors.New("iam: role denied") ErrAuthentication = errors.New("iam: trusted authentication evidence required") ErrMFARequired = errors.New("iam: multi-factor assurance required") ErrSessionAssurance = errors.New("iam: fresh session assurance required") ErrBreakGlass = errors.New("iam: break-glass context required") ErrTargetPrincipal = errors.New("iam: target principal is not an owner of the project") )
Functions ¶
func AppendDurableSecurityEvent ¶
func AppendDurableSecurityEvent(ctx context.Context, sink SecurityAuditSink, event SecurityEvent) error
Types ¶
type AuditEvent ¶
type AuditEvent struct {
Actor string
RepresentedSubject string
Action Action
Target TargetRef
Reason string
TicketRef string
CorrelationID string
Result AuditResult
PolicyRule string
Timestamp time.Time
Error string
BreakGlass bool
SupportGrantRef string
APITokenRef string
TargetPrincipal string
TargetLifecycle TenantState
TargetNamespace string
TargetResource string
TargetResourceName string
TargetOrganization string
TargetTenant string
TargetProject string
CredentialClass CredentialClass
MFA MFAAssurance
Session SessionAssurance
Proof AuthenticationProof
}
type AuditEventReader ¶
type AuditEventReader interface {
Events() []AuditEvent
}
type AuditReadiness ¶
type AuditResult ¶
type AuditResult string
const ( AuditResultAllow AuditResult = "allow" AuditResultDeny AuditResult = "deny" )
type AuditSink ¶
type AuditSink interface {
Append(AuditEvent) error
}
type AuthenticationFunc ¶
type AuthenticationFunc func(context.Context, AuthorizationRequest, time.Time) (AuthenticationResult, error)
func (AuthenticationFunc) Authenticate ¶
func (verify AuthenticationFunc) Authenticate(ctx context.Context, request AuthorizationRequest, at time.Time) (AuthenticationResult, error)
type AuthenticationProof ¶
type AuthenticationResult ¶
type AuthenticationResult struct {
SubjectID string
APITokenRef string
CredentialClass CredentialClass
MFA MFAAssurance
Session SessionAssurance
Proof AuthenticationProof
}
AuthenticationResult is returned only by the trusted verifier configured on Policy. It is deliberately not part of AuthorizationRequest, so callers cannot turn a subject or API-token reference into authentication evidence.
type AuthenticationVerifier ¶
type AuthenticationVerifier interface {
Authenticate(context.Context, AuthorizationRequest, time.Time) (AuthenticationResult, error)
}
type AuthorizationRequest ¶
type AuthorizationRequest struct {
Subject PrincipalRef
Action Action
Target TargetRef
Context RequestContext
SupportGrantRef string
BreakGlass bool
}
type CredentialClass ¶
type CredentialClass string
const ( CredentialClassInteractiveSession CredentialClass = "interactive_session" CredentialClassShortLivedAPIToken CredentialClass = "short_lived_api_token" CredentialClassSupportGrant CredentialClass = "support_grant" CredentialClassBreakGlass CredentialClass = "break_glass" )
type Decision ¶
type Decision struct {
Allowed bool
Err error
PolicyRule string
CredentialClass CredentialClass
MFA MFAAssurance
Session SessionAssurance
Proof AuthenticationProof
}
type DeniedState ¶
type DeniedState struct {
Code string `json:"code"`
Owner string `json:"owner"`
Impact string `json:"impact"`
NextAction string `json:"nextAction"`
}
func AuthUnavailableDeniedState ¶
func AuthUnavailableDeniedState() DeniedState
func ManagementDeniedState ¶
func ManagementDeniedState() DeniedState
func SessionRequiredDeniedState ¶
func SessionRequiredDeniedState() DeniedState
func TokenRejectedDeniedState ¶
func TokenRejectedDeniedState() DeniedState
type DurableAuditSink ¶
type DurableAuditSink interface {
AuditSink
AuditReadiness
Durable() bool
}
DurableAuditSink promises that a successful Append is durably committed and that Ready checks the usable persistence dependency. Durable returning false is accepted only when PolicyConfig.AllowEphemeralAudit is explicitly set for a synthetic or test-only policy.
type FailingAuditSink ¶
type FailingAuditSink struct{}
func (FailingAuditSink) Append ¶
func (FailingAuditSink) Append(AuditEvent) error
func (FailingAuditSink) Durable ¶
func (FailingAuditSink) Durable() bool
func (FailingAuditSink) Events ¶
func (FailingAuditSink) Events() []AuditEvent
type FixedClock ¶
func (FixedClock) Now ¶
func (clock FixedClock) Now() time.Time
type IdentityContract ¶
type LifecycleClaims ¶
type MFAAssurance ¶
type MFAAssurance struct {
Required bool
Satisfied bool
MethodClass MFAMethodClass
}
type MFAMethodClass ¶
type MFAMethodClass string
const ( MFAMethodNone MFAMethodClass = "none" MFAMethodTOTP MFAMethodClass = "totp" MFAMethodWebAuthn MFAMethodClass = "webauthn" MFAMethodHardwareKey MFAMethodClass = "hardware_key" MFAMethodExternalIDP MFAMethodClass = "external_idp" )
type Membership ¶
type MemoryAuditSink ¶
type MemoryAuditSink struct {
// contains filtered or unexported fields
}
func NewBoundedMemoryAuditSink ¶
func NewBoundedMemoryAuditSink(maxEvents int) *MemoryAuditSink
func NewMemoryAuditSink ¶
func NewMemoryAuditSink() *MemoryAuditSink
func (*MemoryAuditSink) Append ¶
func (sink *MemoryAuditSink) Append(event AuditEvent) error
func (*MemoryAuditSink) AppendSecurityEvent ¶
func (sink *MemoryAuditSink) AppendSecurityEvent(_ context.Context, event SecurityEvent) error
func (*MemoryAuditSink) Durable ¶
func (*MemoryAuditSink) Durable() bool
func (*MemoryAuditSink) Events ¶
func (sink *MemoryAuditSink) Events() []AuditEvent
func (*MemoryAuditSink) SecurityEvents ¶
func (sink *MemoryAuditSink) SecurityEvents() []SecurityEvent
type NamespaceScope ¶
type OIDCAuthenticationVerifier ¶
type OIDCAuthenticationVerifier struct {
// contains filtered or unexported fields
}
OIDCAuthenticationVerifier is the reference adapter from a verified OIDC ID token to Policy authentication evidence. The subject always comes from the signed token; Policy separately requires it to match the requested subject and the configured role/scope directory.
func NewOIDCAuthenticationVerifier ¶
func NewOIDCAuthenticationVerifier(runtime *identity.Runtime, source OIDCProofSource) (*OIDCAuthenticationVerifier, error)
func (*OIDCAuthenticationVerifier) Authenticate ¶
func (verifier *OIDCAuthenticationVerifier) Authenticate(ctx context.Context, _ AuthorizationRequest, at time.Time) (AuthenticationResult, error)
type OIDCProof ¶
type OIDCProof struct {
IDToken string
Nonce string
MFA MFAAssurance
Session SessionAssurance
}
type OIDCProofFunc ¶
type OIDCProofSource ¶
OIDCProofSource reads browser/session proof from trusted transport context. It must not derive a subject from AuthorizationRequest.
type Organization ¶
type Policy ¶
type Policy struct {
Organizations map[string]Organization
Tenants map[string]Tenant
Projects map[string]Project
Principals map[string]Principal
APITokens map[string]APIToken
SupportGrants map[string]SupportGrant
AuditSink AuditSink
// contains filtered or unexported fields
}
func NewPolicy ¶
func NewPolicy(config PolicyConfig) *Policy
func NewPolicyFromState ¶
func NewPolicyFromState(ctx context.Context, config PolicyConfig, loader PolicyStateLoader) (*Policy, error)
NewPolicyFromState is the production-oriented construction path. It requires a ready durable audit dependency, a trusted verifier with bounded proof policy, and a structurally consistent role/scope directory.
func (*Policy) AuditEvents ¶
func (policy *Policy) AuditEvents() []AuditEvent
func (*Policy) Authorize ¶
func (policy *Policy) Authorize(request AuthorizationRequest) Decision
func (*Policy) AuthorizeContext ¶
func (policy *Policy) AuthorizeContext(ctx context.Context, request AuthorizationRequest) Decision
AuthorizeContext lets a trusted AuthenticationVerifier consume transport-specific proof from ctx without placing bearer material in the authorization request or audit record.
type PolicyConfig ¶
type PolicyState ¶
type PolicyStateLoader ¶
type Principal ¶
type Principal struct {
ID string
Groups []string
Memberships []Membership
Support bool
}
type PrincipalRef ¶
type Project ¶
type Project struct {
ID string
TenantID string
OrgID string
Namespace string
Scopes []NamespaceScope
}
type RequestContext ¶
type RoleCoverage ¶
type SecurityAuditSink ¶
type SecurityAuditSink interface {
AuditReadiness
Durable() bool
AppendSecurityEvent(context.Context, SecurityEvent) error
}
SecurityAuditSink lets authentication, login, logout, registration, and bootstrap boundaries use the same durable dependency as authorization.
type SecurityEvent ¶
type SessionAssurance ¶
type SessionAssurance struct {
State SessionState
// MaxAgeSeconds is the verifier-declared maximum age of Proof.VerifiedAt
// for this session. Policy also applies its own stricter maximum.
MaxAgeSeconds int64
ReauthenticationRequired bool
}
type SessionState ¶
type SessionState string
const ( SessionStateFresh SessionState = "fresh" SessionStateStale SessionState = "stale" SessionStateAbsent SessionState = "absent" SessionStateRevoked SessionState = "revoked" )
type SourceSafetyClaims ¶
type SupportGrant ¶
type TenantState ¶
type TenantState string
const ( TenantStateActive TenantState = "active" TenantStateSuspended TenantState = "suspended" TenantStateDeleting TenantState = "deleting" TenantStateRecovering TenantState = "recovering" TenantStateExporting TenantState = "exporting" )
type VerifyBlocker ¶
type VerifyBlocker struct {
ID string `json:"id"`
Message string `json:"message"`
Expected string `json:"expected"`
Observed string `json:"observed"`
PolicyRule string `json:"policyRule"`
Audited bool `json:"audited"`
ReadinessClaimed bool `json:"readinessClaimed"`
Executable bool `json:"executable"`
Err error `json:"-"`
}
type VerifyCase ¶
type VerifyCase struct {
ID string `json:"id"`
Expected string `json:"expected"`
Observed string `json:"observed"`
PolicyRule string `json:"policyRule"`
Error string `json:"error,omitempty"`
Audited bool `json:"audited"`
ReadinessClaimed bool `json:"readinessClaimed"`
Executable bool `json:"executable"`
}
type VerifyCoverage ¶
type VerifyCoverage struct {
Organization bool `json:"organization"`
ActiveTenant bool `json:"activeTenant"`
ActiveProject bool `json:"activeProject"`
Roles RoleCoverage `json:"roles"`
Quotas bool `json:"quotas"`
APITokenReadScope bool `json:"apiTokenReadScope"`
SupportGrantWithTicketReason bool `json:"supportGrantWithTicketReason"`
BreakGlassWithTicketReason bool `json:"breakGlassWithTicketReason"`
AuditAppend bool `json:"auditAppend"`
Lifecycle LifecycleClaims `json:"lifecycle"`
IdentityContract IdentityContract `json:"identityContract"`
PlaintextSecretsAbsent bool `json:"plaintextSecretsAbsent"`
}
type VerifyOptions ¶
type VerifyReport ¶
type VerifyReport struct {
SchemaVersion string `json:"schemaVersion"`
GeneratedAt string `json:"generatedAt"`
Scenario Scenario `json:"scenario"`
Status Status `json:"status"`
ReadinessClaimed bool `json:"readinessClaimed"`
Target string `json:"target"`
SyntheticOnly bool `json:"syntheticOnly"`
Requirements []string `json:"requirements"`
Coverage VerifyCoverage `json:"coverage"`
Cases []VerifyCase `json:"cases"`
Blockers []VerifyBlocker `json:"blockers,omitempty"`
AuditEventCount int `json:"auditEventCount"`
SourceSafety SourceSafetyClaims `json:"sourceSafety"`
NonClaims []string `json:"nonClaims"`
ControlObservations []string `json:"controlObservations"`
}
func VerifyContract ¶
func VerifyContract(opts VerifyOptions) (VerifyReport, int, error)