mds

package module
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: Apache-2.0 Imports: 21 Imported by: ? 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.

README

telesma-app/mds

Go Reference Go

telesma-app/mds is a Go client for the FIDO Metadata Service (MDS3).

[!WARNING] This module is under active development. Its public API may change during v0.x.

Features

  • downloads and verifies the signed FIDO metadata BLOB;
  • validates the signing certificate chain and CRLs;
  • rejects metadata rollback;
  • caches verified metadata and limits network requests;
  • looks up metadata by AAGUID;
  • checks verified authenticator attestations against metadata roots and status reports.

Installation

go get github.com/telesma-app/mds@latest

See go.mod for the required Go version.

Quick start

client := mds.NewClient()

result, err := client.Lookup(ctx, aaguid, mds.LookupOptions{})
if err != nil {
    return err
}
if result.Found {
    fmt.Println(result.Entry.MetadataStatement.Description)
}

Lookup uses the official FIDO MDS endpoint by default.

Caching

The client shares an in-memory cache and stores verified, signed BLOBs in the platform user cache directory; use mds.WithCacheDir to choose another location. Cached metadata refreshes automatically after a day. LookupOptions{Refresh: true} requests an earlier refresh, subject to a one-hour minimum interval.

Cached identifies a local result, and CheckedAt records its last successful network check. If an update fails, verified cached data remains available with RefreshErr; failures without usable cache and canceled refreshes return an error.

Attestation checks

AssessAttestation compares an already verified attestation with metadata roots and status reports. Parse and verify the attestation with ctap/attestation first; the relying party owns acceptance policy. An AAGUID lookup alone does not authenticate the connected device.

Testing

go test ./...
go vet ./...

Linting

With golangci-lint v2 installed, run:

golangci-lint run ./...

License

Apache License 2.0. See LICENSE.

Documentation

Overview

Package mds fetches, verifies, caches, and queries FIDO Metadata Service blobs.

Index

Constants

View Source
const (
	DefaultSource          = "https://mds.fidoalliance.org/"
	DefaultRefreshInterval = 24 * time.Hour
	DefaultMaxBlobBytes    = 64 << 20 // 64 MiB

)

Variables

View Source
var (
	ErrInvalidAAGUID = errors.New("invalid AAGUID")
	ErrFetch         = errors.New("fetch MDS blob")
	ErrVerify        = errors.New("verify MDS blob")
)

Functions

func AssessAttestation

func AssessAttestation(
	evidence AttestationEvidence,
	metadata model.LookupResult,
	currentTime time.Time,
) model.AttestationTrustAssessment

AssessAttestation evaluates attestation evidence against one verified MDS lookup result. It does not apply relying-party certification policy.

Types

type AttestationEvidence

type AttestationEvidence struct {
	AAGUID           uuid.UUID
	Type             AttestationType
	CertificateChain [][]byte
}

AttestationEvidence identifies the authenticator and carries the untrusted certificate chain extracted from a verified attestation statement.

type AttestationType

type AttestationType string

AttestationType describes the trust material exposed by a format-level attestation verifier. It deliberately does not prescribe relying-party certification policy.

const (
	AttestationTypeNone        AttestationType = "none"
	AttestationTypeSelf        AttestationType = "self"
	AttestationTypeBasic       AttestationType = "basic"
	AttestationTypeUnsupported AttestationType = "unsupported"
)

type Blob

type Blob struct {
	Number uint64

	// IssuedAt is best-effort metadata. It is read from the MDS JWT header iat
	// when present, otherwise from the standard payload iat parsed by
	// jwt.RegisteredClaims. It is zero when both are absent.
	IssuedAt time.Time

	Entries map[uuid.UUID]*appmds.PayloadEntry

	// CheckedAt is the last successful network retrieval or revalidation.
	CheckedAt time.Time
	// contains filtered or unexported fields
}

Blob is a verified and indexed MDS payload. Treat it as immutable after storing it in Cache.

type Cache

type Cache interface {
	Get(key string) (*Blob, bool)
	Set(key string, blob *Blob)
	Refresh(context.Context, string, func() (*Blob, bool, error)) (*Blob, bool, error)
}

Cache stores immutable verified blobs. Refresh runs one callback per key; concurrent callers share its result unless their context is canceled.

func NewCache

func NewCache() Cache

NewCache creates a process-local MDS blob cache.

type Client

type Client struct {
	Source     string
	HTTPClient *http.Client
	Cache      Cache
	CacheDir   string

	// TrustAnchors overrides the pinned roots when non-empty. Certificates must be non-nil.
	TrustAnchors []*x509.Certificate

	// MaxBlobBytes bounds metadata BLOB downloads. Zero means DefaultMaxBlobBytes.
	MaxBlobBytes int64

	// Now is injectable for deterministic tests.
	Now func() time.Time
}

Client fetches, caches, and looks up verified FIDO Metadata Service blobs. Signature, x5u/x5c, certificate-chain and CRL validation live in internal/mdsverify. The zero value is ready to use.

func NewClient

func NewClient(options ...Option) *Client

NewClient creates an MDS client with cache-first defaults. Each option must be non-nil.

func (*Client) Lookup

func (c *Client) Lookup(ctx context.Context, aaguid uuid.UUID, opts LookupOptions) (appmds.LookupResult, error)

Lookup returns verified metadata, using cached data with RefreshErr on failure. Canceled refreshes and failures without a verified cache return an error.

type HTTPStatusError

type HTTPStatusError struct {
	StatusCode int
}

HTTPStatusError reports a non-success response from the configured MDS endpoint.

func (*HTTPStatusError) Error

func (e *HTTPStatusError) Error() string

func (*HTTPStatusError) Unwrap

func (e *HTTPStatusError) Unwrap() error

type LookupOptions

type LookupOptions struct {
	// Refresh requests a network refresh, subject to the minimum request delay.
	Refresh bool
}

LookupOptions configures one MDS lookup.

type Option

type Option func(*Client)

Option configures a Client created by NewClient.

func WithCacheDir

func WithCacheDir(dir string) Option

WithCacheDir stores verified MDS JWTs below dir.

Directories

Path Synopsis
internal
Package model contains public FIDO Metadata Service DTOs.
Package model contains public FIDO Metadata Service DTOs.

Jump to

Keyboard shortcuts

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