credentials

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 9 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 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

View Source
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

type ValidationError struct {
	IsDomain bool
	Code     string
	Field    string
	Message  string
}

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.

Jump to

Keyboard shortcuts

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