Documentation
¶
Overview ¶
Package credentials validates and normalizes IServ school connection details with SSRF hostname guards and secret redaction for formatting and logging.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalid = errors.New("invalid credentials input")
ErrInvalid is the sentinel error wrapped by ValidationError.
Functions ¶
This section is empty.
Types ¶
type Credentials ¶
type Credentials struct {
Domain string
Scheme string
BasePath string
Username string
Password string
AllowInsecureHTTP bool
}
Credentials is an immutable value object holding validated IServ connection details. Its formatting and logging methods always redact Password.
func New ¶
func New(rawDomain, rawUsername, password string, allowInsecureHTTP bool) (Credentials, error)
New validates and normalizes an IServ school domain or URL, username, and password. When allowInsecureHTTP is false, only HTTPS public FQDNs on default port 443 are accepted.
func (Credentials) BaseURL ¶
func (c Credentials) BaseURL() string
BaseURL returns the normalized scheme://host plus any subpath mount prefix without a trailing slash.
func (Credentials) Fingerprint ¶
func (c Credentials) Fingerprint() string
Fingerprint returns a deterministic SHA-256 hex digest identifying these exact credentials.
func (Credentials) GoString ¶
func (c Credentials) GoString() string
GoString redacts the password for %#v formatting.
func (Credentials) Host ¶
func (c Credentials) Host() string
Host returns the hostname (without port) of the normalized Domain.
func (Credentials) LogValue ¶
func (c Credentials) LogValue() slog.Value
LogValue implements slog.LogValuer so structured logs never expose the password.
func (Credentials) MailAccount ¶
func (c Credentials) MailAccount() string
MailAccount returns the inferred user email address (username@domain) used by modern IServ Mail v2 endpoints, or "" when a non-mail host:port is configured.
func (Credentials) String ¶
func (c Credentials) String() string
String redacts the password to prevent accidental leakage in fmt output.
type ValidationError ¶
ValidationError describes a credentials validation failure along with whether it is a domain/SSRF rejection or a general field validation error.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
Error implements the error interface.
func (*ValidationError) Unwrap ¶
func (e *ValidationError) Unwrap() error
Unwrap links ValidationError to ErrInvalid.