counter

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 30, 2025 License: MIT Imports: 10 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 counter provides functionality to count unique labels in a .well-known/webauthn endpoint.

Index

Constants

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

Jump to

Keyboard shortcuts

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