domainverify

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: GPL-3.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

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.

func (*NetResolver) LookupTXT

func (n *NetResolver) LookupTXT(ctx context.Context, name string) ([]string, error)

LookupTXT resolves TXT records for name.

type Resolver

type Resolver interface {
	LookupTXT(ctx context.Context, name string) ([]string, error)
}

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) Delete

func (s *Service) Delete(ctx context.Context, tenantID, id shared.ID) error

Delete removes a tenant's verified-domain row by id.

func (*Service) IsVerifiedDomain

func (s *Service) IsVerifiedDomain(ctx context.Context, tenantID, emailDomain string) (bool, error)

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

func (s *Service) ReverifyDue(ctx context.Context, staleness time.Duration, batch int) (int, error)

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

func Instructions(domain, token string) TXTRecord

Instructions returns the TXT record to publish for domain+token. It does not touch persistence, so handlers can render instructions for a stored row.

Jump to

Keyboard shortcuts

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