Help us shape the future of Go! Take the 2026 Go Developer Survey

contract

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package contract is the consent plugin's forge-dashboard contract surface. The plugin's Store is the source of truth; this package wraps it as four intents: list, userConsents, grant, revoke.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(
	d *dispatcher.Dispatcher,
	reg contract.Registry,
	wreg contract.WardenRegistry,
	deps Deps,
) error

Types

type ConsentItem

type ConsentItem = ConsentRecord

ConsentItem is what list+detail handlers project Consent records into. Defined as its own type so future fields (PolicyTitle, etc.) can be added without forcing every store call site to materialise them.

type ConsentList

type ConsentList struct {
	Items      []ConsentItem `json:"items"`
	NextCursor string        `json:"nextCursor,omitempty"`
}

ConsentList is the wire shape for list responses.

type ConsentQuery

type ConsentQuery struct {
	UserID  id.UserID
	AppID   id.AppID
	Purpose string
	Cursor  string
	Limit   int
}

type ConsentRecord

type ConsentRecord struct {
	ID        string `json:"id"`
	UserID    string `json:"userId"`
	AppID     string `json:"appId,omitempty"`
	Purpose   string `json:"purpose"`
	Granted   bool   `json:"granted"`
	Version   string `json:"version,omitempty"`
	IPAddress string `json:"ipAddress,omitempty"`
	GrantedAt string `json:"grantedAt,omitempty"`
	RevokedAt string `json:"revokedAt,omitempty"`
	CreatedAt string `json:"createdAt"`
	UpdatedAt string `json:"updatedAt,omitempty"`
}

ConsentRecord is the wire shape consumers see. Field names mirror the resource.list columns in the manifest — renames are wire breaks.

type ConsentRow

type ConsentRow struct {
	ID        id.ConsentID
	UserID    id.UserID
	AppID     id.AppID
	Purpose   string
	Granted   bool
	Version   string
	IPAddress string
	GrantedAt time.Time
	RevokedAt *time.Time
	CreatedAt time.Time
	UpdatedAt time.Time
}

ConsentRow + ConsentQuery mirror the consent package's exported types. The parent plugin's contract.go adapts its own concrete types into these via a small shim so we don't import the parent package here.

type ConsentStore

type ConsentStore interface {
	GrantConsent(ctx context.Context, c *ConsentRow) error
	RevokeConsent(ctx context.Context, userID id.UserID, appID id.AppID, purpose string) error
	ListConsents(ctx context.Context, q *ConsentQuery) ([]*ConsentRow, string, error)
}

ConsentStore is the surface this package needs from the consent plugin. Mirroring consent.Store's relevant subset as a local interface keeps this package decoupled from the parent plugin (cycle avoidance).

type Deps

type Deps struct {
	Engine *authsome.Engine
	Store  ConsentStore
}

type GrantConsentInput

type GrantConsentInput struct {
	UserID    string `json:"userId"`
	Purpose   string `json:"purpose"`
	Version   string `json:"version,omitempty"`
	IPAddress string `json:"ipAddress,omitempty"`
}

GrantConsentInput is the wire shape for consent.grant.

type ListConsentsInput

type ListConsentsInput struct {
	UserID  string `json:"userId,omitempty"`
	Purpose string `json:"purpose,omitempty"`
	Cursor  string `json:"cursor,omitempty"`
	Limit   int    `json:"limit,omitempty"`
}

ListConsentsInput is the input for consent.list / consent.userConsents. All fields are optional; an empty input lists the principal-app's records.

type RevokeConsentInput

type RevokeConsentInput struct {
	UserID  string `json:"userId"`
	Purpose string `json:"purpose"`
}

RevokeConsentInput is the wire shape for consent.revoke.

Jump to

Keyboard shortcuts

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