googlecloudlogs4datatug

package
v0.60.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 34 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Personal Cloud Logging storage adapters

Registry and Operations use the existing DALgo Firestore database. A grant reserves its Google (OAuthProject, Subject) globally until FinishCleanup commits a credential-free terminal outcome. Retired grants stay available by ID for that outcome, while the user's list index retains at most 100 active or revoking grants and removes each retired ID. No log entries or query results are stored here.

Operation lease deadlines are advisory diagnostics. They never release a lease or allow a second revocation attempt: a provider call may ignore cancellation or be paused past its deadline. If a process dies before releasing a lease or recording revocation, CleanupPending keeps retrying, but the subject remains reserved and cleanup cannot finish by itself.

Cleanup sweeps advance a durable cursor before each bounded grant attempt. An orphan lease can delay its own attempt for at most one query timeout; later grants are selected on subsequent attempts or sweeps. A sweep reports failures while continuing to attempt other grants when its caller's deadline permits.

Recovery requires a separate administrative Operations instance created with NewRecoveryOperations. Its QuiescenceVerifier must authenticate the operator and verify evidence that every process capable of work for the grant generation has stopped and cannot resume, including any stalled revocation worker. Only then may ReconcileQuiesced clear orphan leases and an uncertain revocation owner; the normal Cleanup path can retry under its closed fence. Recovery first reads the operation version, verifies the evidence, and atomically rejects a changed version so a delayed verifier cannot clear a new revoker. Elapsed time or a missing heartbeat is insufficient evidence. The verifier, operator authority, and production host wiring are outside this package.

Documentation

Overview

Package googlecloudlogs4datatug provides durable host adapters for personal Cloud Logging grants. It stores no log entries, filters, or query results.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActivationLifecycle

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

ActivationLifecycle coordinates the durable activation fence with the existing personal Cloud Logs service cleanup path.

func NewActivationLifecycle

func NewActivationLifecycle(service *logs.Service, registry *Registry) (*ActivationLifecycle, error)

NewActivationLifecycle binds lifecycle controls to the same registry used by the service. The host supplies its fixed pilot UID at each invocation.

func (*ActivationLifecycle) Pause

func (l *ActivationLifecycle) Pause(ctx context.Context, uid string, expected uint64) (logs.ActivationStatus, error)

func (*ActivationLifecycle) Reconcile

func (l *ActivationLifecycle) Reconcile(ctx context.Context, uid string, expected uint64, limit int) (logs.ActivationReconciliation, error)

func (*ActivationLifecycle) Resume

func (l *ActivationLifecycle) Resume(ctx context.Context, uid string, expected uint64) (logs.ActivationStatus, error)

func (*ActivationLifecycle) Status

type KMSClient

KMSClient is implemented by Cloud KMS KeyManagementClient. A single service identity with narrow Encrypt/Decrypt permission supplies this client.

type OAuth

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

func NewOAuth

func NewOAuth(config OAuthConfig) (*OAuth, error)

func (*OAuth) AuthorizationURL

func (o *OAuth) AuthorizationURL(a personalcloudlogs4datatug.Authorization) (string, error)

AuthorizationURL accepts only the server-generated state, nonce and S256 challenge.

func (*OAuth) Exchange

Exchange performs the code exchange on the server and verifies the signed ID token before any Google subject is exposed to the service.

func (*OAuth) Refresh

func (o *OAuth) Refresh(ctx context.Context, refreshToken string) (string, time.Time, error)

Refresh uses only the delegated refresh token. Callers keep the returned access token in bounded server memory and fence the grant generation before use.

func (*OAuth) Revoke

func (o *OAuth) Revoke(ctx context.Context, refreshToken string) error

Revoke sends a bounded provider request. Google can revoke this account's permissions for the shared Sneat app, which may require consent again in other Sneat or DataTug clients; the caller owns cleanup and its fence.

type OAuthConfig

type OAuthConfig struct {
	ClientID, ClientSecret, RedirectURI string
	HTTPClient                          *http.Client
}

OAuthConfig is supplied only by the server's trusted Cloud Logs web client, configured in the shared Google Cloud project used by Sneat authentication. ClientSecret must never be returned to a browser or put in a URL.

type Operations

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

Operations stores generation leases in Firestore. Polling propagates a revocation fence across processes, while the service checks context after every provider call before exposing a result.

func NewOperations

func NewOperations(db dal.DB, revoker Revoker, now func() time.Time) (*Operations, error)

func NewRecoveryOperations

func NewRecoveryOperations(db dal.DB, revoker Revoker, now func() time.Time, verifier QuiescenceVerifier) (*Operations, error)

NewRecoveryOperations must be used only in a host operator worker whose verifier checks the operator identity and a deployment-wide stop receipt. Ordinary serving instances use NewOperations and cannot clear orphan leases.

func (*Operations) Acquire

func (o *Operations) Acquire(ctx context.Context, g logs.Grant, c *logs.Connection) (context.Context, func(), error)

func (*Operations) Cleanup

func (o *Operations) Cleanup(ctx context.Context, g logs.Grant) (bool, error)

func (*Operations) ReconcileQuiesced

func (o *Operations) ReconcileQuiesced(ctx context.Context, g logs.Grant, evidence []byte) error

ReconcileQuiesced is an explicit last-resort recovery for a process that died before releasing a lease or recording revocation. A separately configured recovery worker must verify authenticated, auditable evidence of quiescence; time expiry never unlocks it. The proof must cover the entire worker deployment capable of this grant generation, not merely the instance calling this method. No browser path should expose this operation.

type QuiescenceVerifier

type QuiescenceVerifier interface {
	VerifyQuiesced(context.Context, logs.Grant, []byte) error
}

QuiescenceVerifier is configured only on an administrative Operations instance. It authenticates operator evidence and authoritatively establishes that every process able to run provider work for this generation has stopped, including a stalled revocation attempt, and cannot resume. Clock deadlines and heartbeats are insufficient. The closed Firestore fence rejects new work.

type QuiescenceVerifierFunc

type QuiescenceVerifierFunc func(context.Context, logs.Grant, []byte) error

func (QuiescenceVerifierFunc) VerifyQuiesced

func (f QuiescenceVerifierFunc) VerifyQuiesced(ctx context.Context, g logs.Grant, evidence []byte) error

type Reader

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

Reader performs request-scoped delegated reads. The domain Service must acquire a generation lease before calling it and reauthorize before publishing results. It retains neither credentials nor results across requests.

func NewReader

func NewReader(vault *Vault, oauth *OAuth) (*Reader, error)

func (*Reader) Probe

func (r *Reader) Probe(ctx context.Context, grant personal.Grant, connection personal.Connection) error

Probe executes entries.list even when the view is empty. No schema-only discovery, local metadata or successful token refresh can prove view IAM.

func (*Reader) Query

func (r *Reader) Query(ctx context.Context, grant personal.Grant, connection personal.Connection, query personal.Query) (personal.Result, error)

type Registry

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

Registry uses DALgo's Firestore DB; transactions must be backed by Firestore, never an eventually consistent in-memory substitute in production.

func NewRegistry

func NewRegistry(db dal.DB, stateKey []byte) (*Registry, error)

func (*Registry) ActivateCompletion

func (r *Registry) ActivateCompletion(ctx context.Context, uid, receipt, finish, project string, now time.Time) (logs.Grant, error)

func (*Registry) BeginDisconnect

func (r *Registry) BeginDisconnect(ctx context.Context, uid, id string, now time.Time) (logs.Grant, error)

func (*Registry) ConsumePending

func (r *Registry) ConsumePending(ctx context.Context, hash string, now time.Time) (logs.Pending, error)

func (*Registry) CreateConnection

func (r *Registry) CreateConnection(ctx context.Context, c logs.Connection) error

func (*Registry) FinishCleanup

func (r *Registry) FinishCleanup(ctx context.Context, id, generation string, confirmed bool) error

func (*Registry) GetConnection

func (r *Registry) GetConnection(ctx context.Context, uid, id string) (logs.Connection, error)

func (*Registry) GetGrant

func (r *Registry) GetGrant(ctx context.Context, uid, id string) (logs.Grant, error)

func (*Registry) List

func (r *Registry) List(ctx context.Context, uid string) (logs.Listing, error)

func (*Registry) PendingCleanup

func (r *Registry) PendingCleanup(ctx context.Context, limit int) ([]logs.Grant, error)

func (*Registry) PurgeExpired

func (r *Registry) PurgeExpired(ctx context.Context, now time.Time, limit int) error

func (*Registry) RemoveConnection

func (r *Registry) RemoveConnection(ctx context.Context, uid, id string) error

func (*Registry) SaveCompletion

func (r *Registry) SaveCompletion(ctx context.Context, c logs.Completion) error

func (*Registry) SavePending

func (r *Registry) SavePending(ctx context.Context, p logs.Pending) error

type RevokeFunc

type RevokeFunc func(context.Context, logs.Grant) (bool, error)

func (RevokeFunc) Revoke

func (f RevokeFunc) Revoke(ctx context.Context, g logs.Grant) (bool, error)

type Revoker

type Revoker interface {
	Revoke(context.Context, logs.Grant) (bool, error)
}

Revoker receives an already sealed grant. It must use the delegated token after opening it through the host vault; this adapter never logs its value. A false, nil result means Google did not confirm revocation.

type Vault

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

func NewVault

func NewVault(keyName string, kms KMSClient) (*Vault, error)

func (*Vault) Open

Open decrypts only with the same grant identity and key. A corrupt envelope, changed AAD, disabled key version or KMS failure never yields a token.

func (*Vault) Seal

func (v *Vault) Seal(ctx context.Context, grant personalcloudlogs4datatug.Grant, refreshToken string) ([]byte, error)

Seal binds the refresh token to every stable grant identity field. Key rotation uses the KMS CryptoKey primary for new encryptions.

Jump to

Keyboard shortcuts

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