userauth

package
v3.30.0-alpha Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnavailable = errors.New("userauth: anonymous-credential FFI unavailable in this build")

ErrUnavailable

Functions

func ProbeID

func ProbeID(credentialB64, probeASN, probeCC string) (string, error)

ProbeID derives the hex-encoded probe id for the given credential.

func Register

func Register(url, publicParams, manifestVersion, proxy, userAgent string, timeout float32) (string, error)

Register registers a new user and returns the base64-encoded credential.

Types

type CredStore

type CredStore struct {
	Store model.KeyValueStore
}

CredStore persists a StoredCredential in a generic key-value store, mirroring probeservices.StateFile.

func NewCredStore

func NewCredStore(kvstore model.KeyValueStore) *CredStore

NewCredStore creates a new CredStore backed by the given key-value store.

func (*CredStore) Get

func (cs *CredStore) Get() (cred StoredCredential)

Get returns the stored credential. When there is no credential yet, or the store cannot be read, it returns a zero StoredCredential

func (*CredStore) Set

func (cs *CredStore) Set(cred StoredCredential) error

Set persists the given credential.

type CredentialConfig

type CredentialConfig struct {
	// Credential is the base64-encoded credential to authenticate with.
	Credential string `json:"credential"`

	// PublicParams is the base64-encoded public parameters from the manifest.
	PublicParams string `json:"public_params"`

	// ManifestVersion is the manifest version the credential belongs to.
	ManifestVersion string `json:"manifest_version"`

	// AgeRange is the allowed credential age window.
	AgeRange ParamRange `json:"age_range"`

	// MeasurementCountRange is the allowed measurement-count window.
	MeasurementCountRange ParamRange `json:"measurement_count_range"`
}

CredentialConfig carries the stored credential together with the manifest-derived parameters

type CredentialSubmitter

type CredentialSubmitter struct {
	// contains filtered or unexported fields
}

CredentialSubmitter implements model.Submitter.

func NewCredentialSubmitter

func NewCredentialSubmitter(
	ctx context.Context, config CredentialSubmitterConfig) (*CredentialSubmitter, error)

NewCredentialSubmitter builds a CredentialSubmitter, registering for a fresh credential when there is no usable stored one.

func (*CredentialSubmitter) Submit

Submit implements model.Submitter. It submits the measurement using the stored credential and persists the rotated credential.

type CredentialSubmitterConfig

type CredentialSubmitterConfig struct {
	// BaseURL is the backend base URL (e.g. https://api.ooni.io). The register
	// and submit endpoints are resolved relative to it.
	BaseURL string

	// ProbeCC and ProbeASN identify the probe (the latter in "ASxxxx" form).
	ProbeCC  string
	ProbeASN string

	// PublicParams, ManifestVersion, AgeRange, MeasurementCountRange come from
	// the manifest and its matched submission policy.
	PublicParams          string
	ManifestVersion       string
	AgeRange              ParamRange
	MeasurementCountRange ParamRange

	// Proxy is the proxy URL to route FFI requests through ("" means none).
	Proxy string

	// Timeout is the per-request timeout in seconds (<= 0 means the default).
	Timeout float32

	// Store persists the credential across runs.
	Store *CredStore

	// Logger is the logger to use.
	Logger model.Logger

	// Fallback is the legacy submitter used when credential submission fails.
	Fallback model.Submitter

	// UserAgent is the user-agent string used with by the http client
	UserAgent string
}

CredentialSubmitterConfig carries the dependencies for NewCredentialSubmitter.

type ParamRange

type ParamRange struct {
	Min uint32 `json:"min"`
	Max uint32 `json:"max"`
}

ParamRange

type RotatedCredential

type RotatedCredential struct {
	// Credential is the updated credential to persist for the next submission.
	Credential string

	// MeasurementUID is the collector-assigned measurement identifier.
	MeasurementUID string
}

RotatedCredential is the outcome of a successful authenticated submission.

func Submit

func Submit(url, content, probeCC, probeASN, proxy, userAgent string, timeout float32,
	cfg *CredentialConfig) (RotatedCredential, error)

Submit submits a measurement.

type StoredCredential

type StoredCredential struct {
	// Credential is the base64-encoded credential.
	Credential string `json:"credential"`

	// ManifestVersion is the manifest version the credential was issued for.
	ManifestVersion string `json:"manifest_version"`

	// PublicParams is the base64-encoded public parameters of that manifest.
	PublicParams string `json:"public_params"`
}

StoredCredential is the persisted anonymous credential together with the manifest metadata it was issued against.

Jump to

Keyboard shortcuts

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