factors

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: BSD-3-Clause Imports: 7 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

factors

Go Reference License CI

Linux's authentication factors, as factors — mfa.Factor values a policy can ask. Pure Go, CGO_ENABLED=0.

r, err := mfa.Verify(ctx, mfa.Policy{Count: 2},
    somethingYouKnow,                              // yours to supply
    factors.SecurityKey("example.test", credID, pubKey),   // this
)

There is one factor here, and that is the honest count

Linux has no standard biometric service the way macOS has LocalAuthentication and Windows has Hello. fprintd exists, over D-Bus, on some desktops, for some readers; PAM sits at a different layer and answers a different question. Neither is the platform's authenticator in the sense the other two packages mean, and shipping one here would put a factor in front of people that works on one machine in ten.

So this offers possession, and says so. A caller who needs two kinds supplies the other themselves — more honest than a package guessing, and no worse off than Windows, where nothing reports which modality answered anyway.

A fingerprint factor over fprintd is the obvious thing to add. It wants its own bibliography and a machine to be proven on, not a hurried afternoon.

Almost nothing is here, on purpose

Asking a security key is the same everywhere CTAP is, so it lives once, in go-authn/keyfactor: the assertion, the flag checks, the refusal to spend somebody's last PIN attempt. This package was about to be a second copy of it that differed in one line.

What stays here is what only Linux knows: where a key is, and what its absence means.

⛔ A key you may not open is not a key that refused. /dev/hidraw* is root-only on a stock system; libfido2 ships udev/70-u2f.rules to change that. Reporting it as a refusal would send somebody to touch their key harder when the answer is a file in /etc/udev. It is reported as mfa.ErrUnavailable, and the wrapped error names the rule.

Only the named conditions are excused. Excusing everything would turn every fault into "no key", which is the same mistake wearing the opposite coat.

Coverage

100%, on any machine, with no key: the classification, the error mapping and the seam all run without hardware. platformOpen reaches a real /dev/hidraw*, so no runner can exercise it — and the transport it opens (go-gnulinux/fido) has not been run against a key either. Both say so.

Documentation

Overview

Package factors makes Linux's authentication factors usable by github.com/go-authn/mfa.

r, err := mfa.Verify(ctx, mfa.Policy{Count: 2},
    somethingYouKnow,                            // yours to supply
    factors.SecurityKey("example.test", credID, pubKey), // this
)

There is one factor here, and that is the honest count

Linux has no standard biometric service the way macOS has LocalAuthentication and Windows has Hello. fprintd exists, over D-Bus, on some desktops, for some readers; PAM sits at a different layer and answers a different question. Neither is "the platform's authenticator" in the sense the other two packages mean, and shipping one here would put a factor in front of people that works on one machine in ten.

So this offers possession, and says so. A caller who needs two KINDS supplies the other themselves — which is more honest than a package guessing, and no worse off than Windows, where nothing reports which modality answered anyway.

A fingerprint factor over fprintd is the obvious thing to add. It wants its own bibliography and a machine to be proven on, not a hurried afternoon.

What is here, and what is elsewhere

Almost nothing. Asking a security key is the same everywhere CTAP is, so it lives once, in github.com/go-authn/keyfactor. What Linux knows — where a key is, and what its absence means — is what stays here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SecurityKey

func SecurityKey(rpID string, credentialID []byte, publicKey *ecdsa.PublicKey) mfa.Factor

SecurityKey is a registered credential on an attached key, as a factor: the key must be present and a human must touch it.

credentialID and publicKey are what a registration returned: the credential's id, and the P-256 key from its attestation (fido.AuthData.PublicKey). Passing no id asks the key for a discoverable credential, which it has only if one was registered with the "rk" option.

⛔ The public key is required. Without it nothing could check the assertion's signature, and any device that speaks CTAPHID -- a programmable USB board -- would pass as the key (go-authn/keyfactor v0.3.0, after a security audit). A factor built without one refuses when asked.

func VerifiedSecurityKey

func VerifiedSecurityKey(rpID string, credentialID []byte, publicKey *ecdsa.PublicKey, pin string) mfa.Factor

VerifiedSecurityKey is the same, with the key asked to establish who is holding it.

The kind does not change: see github.com/go-authn/keyfactor. A wrong PIN costs the key a retry and a key that runs out locks, so how many are left is asked for before one is spent.

Types

This section is empty.

Jump to

Keyboard shortcuts

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