Documentation
¶
Overview ¶
Package ports defines the shared interfaces (contracts) between Dilion domains and embedder-injectable components. Do not add domain logic here.
Index ¶
- Constants
- func ContextWithInstance(ctx context.Context, instanceID string) context.Context
- func InstanceFromContext(ctx context.Context) string
- type Actor
- type AuditEvent
- type AuditSink
- type Authorizer
- type Claims
- type Clock
- type Connector
- type ConnectorReceipt
- type ConnectorTask
- type HookFunc
- type HookPoint
- type InstanceResolver
- type KMS
- type KeyScope
- type Mailer
- type SMSSender
- type SystemClock
- type TokenSigner
- type TokenVerifier
Constants ¶
const DefaultInstanceID = "default"
DefaultInstanceID is the sole instance of the built-in daemon and examples. Multi-instance is an embedder customization, not a default-daemon feature.
Variables ¶
This section is empty.
Functions ¶
func ContextWithInstance ¶
ContextWithInstance selects the instance for downstream Dilion calls.
func InstanceFromContext ¶
InstanceFromContext returns the selected instance, or DefaultInstanceID.
Types ¶
type AuditEvent ¶
type AuditEvent struct {
ProjectID string
ActorID string
ActorType string // admin | api_key | service_role | user | system
Action string // e.g. USER_LIST_READ, PII_FULL_READ, ROLE_GRANTED
Resource string
AccessLevel string // masked | full | n/a
RequestID string
ResultCount int
SubjectIDs []string // written to dilion_audit.subjects (manifest)
Reason string // operator-supplied justification (PII reveal 등); optional
IP string
UserAgent string
OccurredAt time.Time
}
type Authorizer ¶
type Authorizer interface {
Can(ctx context.Context, actor Actor, permission string, resource string) (bool, error)
}
Authorizer decides only; audit logging and masked-by-default behavior are enforced by callers regardless of the implementation.
type Connector ¶
type Connector interface {
Execute(ctx context.Context, t ConnectorTask) (ConnectorReceipt, error)
}
type ConnectorReceipt ¶
type ConnectorTask ¶
type HookFunc ¶
HookFunc receives a mutable payload. Validating hooks reject by returning an error; mutating hooks return a replacement payload (nil = unchanged).
type HookPoint ¶
type HookPoint string
const ( BeforeSignup HookPoint = "before_signup" // validating (may reject) AfterSignup HookPoint = "after_signup" // observing TokenClaims HookPoint = "token_claims" // mutating (adds Claims.Extra) BeforeUserDelete HookPoint = "before_user_delete" // validating AfterUserDelete HookPoint = "after_user_delete" // observing BeforeErasureStep HookPoint = "before_erasure_step" // validating AfterErasure HookPoint = "after_erasure" // observing ConsentChanged HookPoint = "consent_changed" // observing ConsentReconfirm HookPoint = "consent_reconfirm" // observing (확인 고지 이벤트) PIIReveal HookPoint = "pii_reveal" // validating )
type InstanceResolver ¶
type InstanceResolver interface {
Pool(ctx context.Context, instanceID string) (*pgxpool.Pool, error)
KMS(ctx context.Context, instanceID string) (KMS, error)
// PolicyYAML returns the instance's compliance policy document
// (project.md §2.8). nil = built-in defaults only.
PolicyYAML(ctx context.Context, instanceID string) ([]byte, error)
// PIIFields returns the instance's fixed PII field definitions (YAML:
// pii-fields: {<key>: {hint: NAME|EMAIL|PHONE|ADDRESS|GENERIC}}).
// Writes of undefined keys are rejected and the stored hint always comes
// from the definition. nil = free-form fields (single-instance default).
PIIFields(ctx context.Context, instanceID string) ([]byte, error)
// List enumerates known instance ids (background worker scheduling).
List(ctx context.Context) ([]string, error)
}
InstanceResolver provides per-instance resources dynamically. Each instance is a fully isolated database (auth.* + dilion_*), larger in scope than a tenant/project. The built-in daemon uses a single static instance; embedders inject their own resolver via dilion.WithInstanceResolver and select the instance per request with ContextWithInstance. There is NO built-in HTTP routing or token↔instance binding — how an instance is chosen for a request, and how credentials are bound to instances, is the embedder's responsibility.
Results for the same instanceID should be stable; Dilion may cache per-instance resources (engines, workers) keyed by instanceID.
type KMS ¶
type KMS interface {
Encrypt(ctx context.Context, subjectID string, scope KeyScope, plaintext []byte) ([]byte, error)
Decrypt(ctx context.Context, subjectID string, scope KeyScope, ciphertext []byte) ([]byte, error)
// DestroyDEK irreversibly destroys the subject-scoped DEK (crypto-shred).
// Decrypt must fail afterwards. Idempotent.
DestroyDEK(ctx context.Context, subjectID string, scope KeyScope) error
}
type SystemClock ¶
type SystemClock struct{}
func (SystemClock) Now ¶
func (SystemClock) Now() time.Time