gitcredentials

package
v0.4.0 Latest Latest
Warning

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

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

Documentation

Overview

Package gitcredentials owns the per-user git PAT credential surface (list / create / delete). The token plaintext is encrypted at rest under "git_credential/{id}/token" via secrets.Store and is never returned by any method on this Service — DTOs deliberately omit it, so a caller can't accidentally serialize the secret. Per-row runtime lookups that need the encrypted ref (agent build pipeline) hit dbq.GetGitCredential directly with their own ownership check; this service is for the operator's own CRUD against their credential list.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateRequest

type CreateRequest struct {
	Name  string
	Token string
	Type  string
}

CreateRequest is the input for Create. Type "" defaults to "pat".

type Credential

type Credential struct {
	ID              uuid.UUID
	UserID          uuid.UUID
	Type            string
	Name            string
	GithubInstallID string
	CreatedAt       pgtype.Timestamptz
	LastUsedAt      pgtype.Timestamptz
}

Credential is the wire shape the handler / sysagent tool sees. No token field exists — by design, so accidental serialization can't leak the secret.

type Service

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

Service is the per-user git PAT layer. All methods gate on the principal being an authenticated user; there is no agent axis.

func New

func New(d *db.DB, enc secrets.Store, logger *zap.Logger) *Service

func (*Service) Create

func (s *Service) Create(ctx context.Context, p authz.Principal, req CreateRequest) (Credential, error)

Create encrypts the token under a generated id and persists the row. Returns ErrInvalidInput (Detail-wrapped) on missing name/token or unsupported type, ErrConflict on a duplicate name for this user.

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, p authz.Principal, id uuid.UUID) error

Delete removes the caller's credential by id. Owner-scoped at the query level via DELETE WHERE id = $1 AND user_id = $2, so a mismatched owner yields no-op (we still report success — same idempotence the raw handler had).

func (*Service) List

func (s *Service) List(ctx context.Context, p authz.Principal) ([]Credential, error)

List returns the caller's own credentials, omitting token_ref bytes. Ordered by name for stable rendering.

Jump to

Keyboard shortcuts

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