Documentation
¶
Overview ¶
Package counter provides functionality to count unique labels in a .well-known/webauthn endpoint.
Index ¶
Constants ¶
const ( // MaxLabels is the maximum number of unique labels allowed in a .well-known/webauthn endpoint. MaxLabels = 5 // WellKnownPath is the path to the .well-known/webauthn endpoint. WellKnownPath = "/.well-known/webauthn" // MaxBodySize is the maximum size of the response body in bytes. MaxBodySize = 1 << 18 // 256KB // Timeout is the timeout for the HTTP request. Timeout = 10 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func FormatResults ¶
func FormatResults(result *LabelCount) string
FormatResults formats the label count results into a human-readable string.
Types ¶
type AuthenticatorStatus ¶
type AuthenticatorStatus int
AuthenticatorStatus represents the status of a WebAuthn authentication request.
const ( // StatusSuccess indicates that the authentication request was successful. StatusSuccess AuthenticatorStatus = iota // StatusBadRelyingPartyIDJSONParseError indicates that the relying party ID JSON could not be parsed. StatusBadRelyingPartyIDJSONParseError // StatusBadRelyingPartyIDNoJSONMatch indicates that the relying party ID JSON did not match the caller origin. StatusBadRelyingPartyIDNoJSONMatch // StatusBadRelyingPartyIDNoJSONMatchHitLimits indicates that the relying party ID JSON did not match the caller origin and hit the label limit. StatusBadRelyingPartyIDNoJSONMatchHitLimits )
func ValidateWellKnownJSON ¶
func ValidateWellKnownJSON(callerOrigin string, jsonData []byte) AuthenticatorStatus
ValidateWellKnownJSON validates if a caller origin is authorized by a relying party's .well-known/webauthn file. This function is based on the Chromium implementation of ValidateWellKnownJSON. It checks if the caller origin is in the list of authorized origins in the .well-known/webauthn file. It also enforces a limit on the number of unique eTLD+1 labels (MaxLabels) that can be processed. If the limit is reached before finding the caller origin, it returns StatusBadRelyingPartyIDNoJSONMatchHitLimits.
func (AuthenticatorStatus) String ¶
func (s AuthenticatorStatus) String() string
String returns a string representation of the AuthenticatorStatus.
type LabelCount ¶
type LabelCount struct {
URL string
UniqueLabels map[string]bool
Count int
ExceedsLimit bool
LabelsFound []string
ErrorMessage string
RawJSON string
}
LabelCount represents the count of unique labels found in a .well-known/webauthn endpoint.
func CountLabels ¶
func CountLabels(domain string) (*LabelCount, error)
CountLabels fetches the .well-known/webauthn endpoint for the given domain and counts the unique labels.
func CountLabelsFromFile ¶
func CountLabelsFromFile(filePath string) (*LabelCount, error)
CountLabelsFromFile reads a JSON file and counts the unique labels.
type WebAuthnResponse ¶
type WebAuthnResponse struct {
Origins []string `json:"origins"`
}
WebAuthnResponse represents the JSON structure of a .well-known/webauthn response.