Documentation
¶
Overview ¶
Package serviceauthority verifies account authority records without I/O.
Index ¶
- Constants
- Variables
- func Compare(previous, next Generation) error
- func DecodeBase64(value string, limit int) ([]byte, error)
- func DerivePasswordVerifier(role PasswordRole, username, password string) (string, error)
- func NormalizeUsername(raw string) (string, error)
- func PublicKey(value string) ([32]byte, error)
- func ValidLoginPassword(password string) bool
- func ValidNewPassword(password string) bool
- func VerifySigned(domain, encoded string, key [32]byte, limit int) ([]byte, error)
- type AdmissionState
- type Allowance
- type Descriptor
- type Entitlement
- type Generation
- type GossipDescriptor
- type PasswordRole
- type PublicRelay
- type RegistrationAuthorization
- type RegistrationDelivery
- type RegistrationReservation
- type Ticket
Constants ¶
const ( CertificateDomain = "windshare/authority-certificate/v1\x00" TicketDomain = "windshare/account-ticket/v1\x00" DescriptorDomain = "windshare/node-descriptor/v2\x00" MaximumTicketBytes = 512 MaximumDescriptorBytes = 16 << 10 MaximumResponseBytes = 512 << 10 MaximumCounter = 1<<53 - 1 DaySeconds = 86400 ClockSkew = 300 TicketLifetime = 12 * 60 * 60 EntitlementLifetime = 5 * 60 CertificateLifetime = 180 * DaySeconds )
const ( GossipLifetime = 24 * 60 * 60 GossipDomain = "windshare/node-gossip/v1\x00" MaximumSTUNURLs = 4 )
const ( UsernameMaxBytes = 64 PasswordMinBytes = 12 PasswordMaxBytes = 256 PasswordVerifierBytes = 32 PasswordPBKDF2Iterations = 600_000 AccountPasswordDomain = "windshare-account-password-v1:" AdminPasswordDomain = "windshare-admin-password-v1:" )
Variables ¶
Functions ¶
func Compare ¶
func Compare(previous, next Generation) error
Compare is independent of wall time: expiry never erases the rollback barrier.
func DerivePasswordVerifier ¶ added in v0.1.6
func DerivePasswordVerifier(role PasswordRole, username, password string) (string, error)
DerivePasswordVerifier stretches a password locally with PBKDF2-HMAC-SHA256 using a deterministic, role-separated username salt so plaintext passwords never cross the wire and offline brute-force work stays off the authority.
func NormalizeUsername ¶ added in v0.1.6
NormalizeUsername trims surrounding whitespace, lowercases ASCII letters, and verifies the authority's canonical identifier alphabet.
func ValidLoginPassword ¶ added in v0.1.6
func ValidNewPassword ¶ added in v0.1.6
Types ¶
type AdmissionState ¶
type AdmissionState uint8
const ( AdmissionReady AdmissionState = iota + 1 AdmissionPendingSetup AdmissionExpired AdmissionTemporaryFailure AdmissionDenied AdmissionUserActionRequired AdmissionPendingAttribution )
func (AdmissionState) Name ¶
func (state AdmissionState) Name() string
type Descriptor ¶
type Descriptor struct {
Version int `json:"version"`
NodeID string `json:"node_id"`
NodeKey string `json:"node_key"`
RelayEndpoint string `json:"relay_endpoint"`
Platform string `json:"platform"`
Services struct {
Relay bool `json:"relay"`
STUN bool `json:"stun"`
} `json:"services"`
STUN []string `json:"stun"`
Zone string `json:"zone"`
Region string `json:"region"`
PublicCapacity *uint64 `json:"public_capacity_bytes_per_second"`
Operator string `json:"operator"`
Provider string `json:"provider"`
Authority *struct {
URL string `json:"url"`
Issuer string `json:"issuer"`
} `json:"authority"`
Classes []string `json:"classes"`
IssuedAt uint64 `json:"issued_at"`
ExpiresAt uint64 `json:"expires_at"`
PublicRelay PublicRelay `json:"public_relay"`
ConsoleURL string `json:"console_url"`
AccountLoginPage string `json:"account_login_page,omitempty"`
}
func InspectDescriptor ¶
func InspectDescriptor(data []byte, now time.Time) (Descriptor, error)
InspectDescriptor verifies a self-asserted identity for manual enrollment. Official admission must still pin that key with VerifyDescriptor.
func VerifyDescriptor ¶
func (Descriptor) OffersCommunityService ¶ added in v0.1.7
func (descriptor Descriptor) OffersCommunityService() bool
OffersCommunityService reports whether this descriptor qualifies for community peer discovery: self-hosted (no accounting authority), not opted out, and offering either anonymous public relaying or STUN.
func (Descriptor) RelayBaseURL ¶
func (descriptor Descriptor) RelayBaseURL() string
RelayBaseURL is for APIs that append their protocol path. The signed descriptor carries the complete canonical WebSocket endpoint, never an ambiguous base.
type Entitlement ¶
type Entitlement struct {
Version uint64 `json:"version"`
Day uint64 `json:"day"`
ValidUntil uint64 `json:"valid_until"`
RemainingBytes uint64 `json:"remaining_bytes"`
}
func Advance ¶
func Advance(previous, next Entitlement) Entitlement
func (Entitlement) ResetAt ¶
func (value Entitlement) ResetAt() time.Time
func (Entitlement) ValidSnapshot ¶
func (value Entitlement) ValidSnapshot(issued uint64) bool
type Generation ¶
type Generation struct {
Issuer [32]byte
Number uint64
Key [32]byte
NotBefore uint64
ExpiresAt uint64
}
func VerifyGeneration ¶
func VerifyGeneration(certificate string, root [32]byte) (Generation, error)
type GossipDescriptor ¶ added in v0.1.7
type GossipDescriptor struct{ Descriptor }
GossipDescriptor cannot be supplied to enrollment or official account verification.
func InspectGossip ¶ added in v0.1.7
func InspectGossip(data []byte, now time.Time) (GossipDescriptor, error)
type PasswordRole ¶ added in v0.1.6
type PasswordRole string
PasswordRole separates client-derived password verifiers across distinct authority namespaces so identical credentials never collide between roles.
const ( PasswordRoleAccount PasswordRole = "account" PasswordRoleAdmin PasswordRole = "admin" )
type PublicRelay ¶ added in v0.1.7
type PublicRelay uint8
Each value represents a complete signed public-admission decision.
const ( RelayUnknown PublicRelay = iota RelayAnonymous RelayAuthenticated RelayBudgetExhausted RelayDisabled )
func (PublicRelay) MarshalJSON ¶ added in v0.1.7
func (state PublicRelay) MarshalJSON() ([]byte, error)
func (*PublicRelay) UnmarshalJSON ¶ added in v0.1.7
func (state *PublicRelay) UnmarshalJSON(data []byte) error
type RegistrationAuthorization ¶
type RegistrationAuthorization struct {
State AdmissionState
Bearer string `json:"-"`
Changed <-chan struct{} `json:"-"`
Cause error `json:"-"`
Reservation RegistrationReservation `json:"-"`
}
A waiting RegistrationAuthorization and its Changed signal describe the same revision so progress cannot be missed while starting a wait.
type RegistrationDelivery ¶ added in v0.1.4
type RegistrationDelivery uint8
const ( RegistrationMayHaveBeenSent RegistrationDelivery = iota RegistrationNotSent )
type RegistrationReservation ¶ added in v0.1.4
type RegistrationReservation func(RegistrationDelivery)
A RegistrationReservation pins attribution for one ready attempt. Settle it with the dial result before applying any local cancellation or admission policy.
func (RegistrationReservation) Finish ¶ added in v0.1.4
func (reservation RegistrationReservation) Finish(delivery RegistrationDelivery)