Documentation
¶
Index ¶
- Constants
- Variables
- type AuditRecordRepository
- type Config
- type Consent
- type Document
- type DocumentConfig
- type GrantRequest
- type Service
- func (s Service) Documents() []Document
- func (s Service) Enabled() bool
- func (s Service) PrepareGrant(req GrantRequest) (Consent, error)
- func (s Service) RecordGranted(ctx context.Context, granted Consent)
- func (s Service) Resolve(ids []string) ([]Document, error)
- func (s Service) ResolveAll(ids []string) ([]Document, error)
Constants ¶
View Source
const SourceSignup = "signup"
Variables ¶
View Source
var ( // ErrUnknownDocuments is returned for an id this deployment does not // configure, which is how a mismatch with the client's list surfaces. ErrUnknownDocuments = errors.New("unknown consent document ids") // ErrMissingDocuments is returned when the ids do not cover every configured // document. All of them are required at signup. ErrMissingDocuments = errors.New("missing consent document ids") // ErrInvalidGrant is returned when a grant is missing something the record needs. ErrInvalidGrant = errors.New("invalid consent grant") // ErrConsentExists is returned when a user already has a signup record. ErrConsentExists = errors.New("a consent record already exists for this user") )
Functions ¶
This section is empty.
Types ¶
type AuditRecordRepository ¶
type AuditRecordRepository interface {
Create(ctx context.Context, auditRecord models.AuditRecord) (models.AuditRecord, error)
}
type Config ¶
type Config struct {
// Enabled switches the whole feature off by default.
Enabled bool `yaml:"enabled" mapstructure:"enabled" default:"false"`
Documents map[string]DocumentConfig `yaml:"documents" mapstructure:"documents"`
}
Config lists the documents a deployment asks people to accept before an account is created. It sits at app.consent, beside app.authentication.
Keyed by document id rather than a list, matching how authenticate.Config keys oidc_config: the key enforces unique ids and stays env-overridable. Every document is required at signup, so there is no per-document flag.
type Consent ¶
type Consent struct {
ID string
UserID string
UserEmail string
Documents []Document
Source string
AuthStrategy string
// IPAddress is empty when the deployment sets no client IP header.
IPAddress string
// ConsentedAt is when the user accepted, not when the row was written.
ConsentedAt time.Time
CreatedAt time.Time
}
Consent is an immutable record of one act of accepting documents
type DocumentConfig ¶
type GrantRequest ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(logger *slog.Logger, config Config, auditRecordRepository AuditRecordRepository) *Service
func (Service) PrepareGrant ¶
func (s Service) PrepareGrant(req GrantRequest) (Consent, error)
func (Service) RecordGranted ¶
RecordGranted writes the audit record after the commit
Click to show internal directories.
Click to hide internal directories.