Documentation
¶
Overview ¶
Package domainverify implements DNS-TXT domain-ownership verification and the verified-domain gate for SSO JIT auto-provisioning (SSO P1).
An IdP proves WHO a user is; a DNS-proven domain proves a tenant may CLAIM that domain's users. A tenant admin adds a domain, publishes the returned TXT record, and the service confirms it — only then may that domain's users be auto-joined. All state transitions are fail-closed: a domain is verified ONLY when the exact token is observed, and a verified domain whose record later disappears is downgraded to failed.
Index ¶
- type NetResolver
- type Resolver
- type Service
- func (s *Service) AddDomain(ctx context.Context, tenantID shared.ID, rawDomain string) (*verifieddomain.VerifiedDomain, TXTRecord, error)
- func (s *Service) Delete(ctx context.Context, tenantID, id shared.ID) error
- func (s *Service) IsVerifiedDomain(ctx context.Context, tenantID, emailDomain string) (bool, error)
- func (s *Service) List(ctx context.Context, tenantID shared.ID) ([]*verifieddomain.VerifiedDomain, error)
- func (s *Service) ReverifyDue(ctx context.Context, staleness time.Duration, batch int) (int, error)
- func (s *Service) VerifyByID(ctx context.Context, tenantID, id shared.ID) (*verifieddomain.VerifiedDomain, error)
- type TXTRecord
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NetResolver ¶
type NetResolver struct {
// contains filtered or unexported fields
}
NetResolver is the production Resolver backed by the system DNS resolver.
func NewNetResolver ¶
func NewNetResolver() *NetResolver
NewNetResolver returns a Resolver using Go's default net.Resolver.
type Resolver ¶
Resolver looks up DNS TXT records. The real implementation wraps net.Resolver; tests inject a mock so verification is deterministic.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service manages verified domains and answers the JIT gate query.
func NewService ¶
func NewService(repo verifieddomain.Repository, resolver Resolver, log *logger.Logger) *Service
NewService creates a Service. When resolver is nil a NetResolver is used.
func (*Service) AddDomain ¶
func (s *Service) AddDomain(ctx context.Context, tenantID shared.ID, rawDomain string) (*verifieddomain.VerifiedDomain, TXTRecord, error)
AddDomain normalizes and validates a domain, rejects shared/public domains, generates a token, and stores a pending row. Returns the row and the TXT record the tenant must publish.
func (*Service) IsVerifiedDomain ¶
IsVerifiedDomain reports whether emailDomain is a verified domain for the tenant. Tenant-scoped and fail-closed: normalization failure, a missing row, or a non-verified status all return false. A lookup error is surfaced so the caller can also fail closed.
func (*Service) List ¶
func (s *Service) List(ctx context.Context, tenantID shared.ID) ([]*verifieddomain.VerifiedDomain, error)
List returns all verified-domain rows for a tenant.
func (*Service) ReverifyDue ¶
ReverifyDue re-checks verified domains that have not been checked since `staleness` ago. A domain whose TXT record vanished is downgraded to failed (fail-closed) so a lapsed/hijacked domain loses JIT authority. Returns the number of rows whose status changed.
func (*Service) VerifyByID ¶
func (s *Service) VerifyByID(ctx context.Context, tenantID, id shared.ID) (*verifieddomain.VerifiedDomain, error)
VerifyByID runs verification for a stored row (admin "verify now"). It loads the row (tenant-scoped), performs the DNS check, persists the outcome, and returns the updated row.
type TXTRecord ¶
type TXTRecord struct {
Host string `json:"host"`
Type string `json:"type"`
Value string `json:"value"`
}
TXTRecord describes the DNS record a tenant must publish to prove ownership.
func Instructions ¶
Instructions returns the TXT record to publish for domain+token. It does not touch persistence, so handlers can render instructions for a stored row.