rpid

package
v0.6.8 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package rpid derives and validates the WebAuthn relying-party ID for the host subflux is reached on: the registrable domain (eTLD+1) from the public suffix list, never a label strip, so a host whose provider is itself a public suffix (foo.duckdns.org, nas.synology.me) collapses to the exact host instead of to an illegal bare suffix.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Derive

func Derive(host string) (string, error)

Derive returns the relying-party ID for host: the registrable domain of a DNS name, or "localhost" verbatim. The error is a *Error.

func Normalize

func Normalize(raw string) string

Normalize returns the canonical spelling of an operator-typed value: trimmed, ASCII-lowercased, without a trailing dot. A port is not stripped; Validate refuses it.

func Validate

func Validate(id string) error

Validate judges an operator-typed value as written, without deriving: a value narrower than the registrable domain is specification-legal and is accepted. The error is a *Error.

func ValidateForHost

func ValidateForHost(id, host string) error

ValidateForHost is Validate plus the served check: host must be id or a subdomain of it. The dot in the needle is the guard against "evilexample.com" matching "example.com".

Types

type Error

type Error struct {
	Value  string
	Detail string
	Reason Reason
	// contains filtered or unexported fields
}

Error names the offending value, why it was refused, and the remedy. The message carries no configuration key: every caller adds its own context.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap exposes the library's refusal on the illegal_domain arm, so errors.Is(err, authwebauthn.ErrIllegalRPID) reaches through.

type Reason

type Reason string

Reason names why a value cannot be a relying-party ID.

const (
	ReasonMalformedHost Reason = "malformed_host"
	ReasonIPLiteral     Reason = "ip_literal"
	ReasonSingleLabel   Reason = "single_label"
	ReasonPublicSuffix  Reason = "public_suffix"
	ReasonIllegalDomain Reason = "illegal_domain"
	ReasonNotCanonical  Reason = "not_canonical"
	ReasonNotServed     Reason = "not_served"
)

The refusal reasons, each carrying its own remedy in Error.Detail.

Jump to

Keyboard shortcuts

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