dnsverify

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package dnsverify provides DNS-based domain ownership verification.

This package allows applications to verify that a domain owner has control over a domain by checking for the presence of a specific project ID in a TXT DNS record. This is commonly used for email authentication, domain claims, and similar verification workflows.

Basic Usage

The primary function is VerifyDomainOwnership, which performs the verification:

import (
	"context"
	"github.com/dmitrymomot/forge/pkg/dnsverify"
)

func main() {
	ctx := context.Background()
	err := dnsverify.VerifyDomainOwnership(ctx, "example.com", "my-project-id-123")
	if err != nil {
		// Handle verification failure
	}
}

Error Handling

The package provides several specific error types for different verification failures:

  • ErrInvalidInput: domain or projectID is empty
  • ErrTXTRecordNotFound: no TXT records found for the domain
  • ErrDNSLookupFailed: DNS lookup encountered a network error
  • ErrDomainNotVerified: TXT records exist but do not contain the projectID

Implementation Details

The verification process:

1. Validates that both domain and projectID are provided 2. Normalizes the domain (lowercases, trims whitespace) 3. Performs a DNS TXT record lookup for the domain 4. Checks if any TXT record contains the projectID string

Domain owners should add a TXT record to their DNS configuration containing the project ID. For example:

example.com TXT "my-project-id-123"

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDNSLookupFailed   = errors.New("dns lookup failed")
	ErrDomainNotVerified = errors.New("domain not verified")
	ErrTXTRecordNotFound = errors.New("txt record not found")
	ErrInvalidInput      = errors.New("invalid domain or project id")
)

Functions

func VerifyDomainOwnership

func VerifyDomainOwnership(ctx context.Context, domain, projectID string) error

VerifyDomainOwnership checks if the domain has a TXT record containing the projectID. Returns nil if verification succeeds, otherwise returns a specific error.

Types

This section is empty.

Jump to

Keyboard shortcuts

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