Documentation
¶
Overview ¶
Package factors makes macOS's authentication factors usable by github.com/go-authn/mfa.
It exists so the bindings do not have to know about policy. A binding's job is to reach a framework; deciding how much proof is enough is somebody else's, and a low-level package that imported a policy package would drag that decision into every program that only wanted Touch ID.
r, err := mfa.Verify(ctx, mfa.Policy{Count: 2, DistinctKinds: true},
factors.TouchID("unlock the vault"),
factors.SecurityKey("example.test", credentialID, publicKey),
)
What each factor actually proves ¶
TouchID proves that whoever is at this machine can satisfy the sensor the account owner enrolled — something they ARE. SecurityKey proves that a particular credential is present and that a human touched it — something they HAVE. Those are different kinds, which is what lets a policy asking for distinct kinds be satisfied by the two together and not by either twice.
Unavailable is not refused ¶
A Mac with no Touch ID sensor has refused nobody, and neither has an empty USB port. Both report mfa.ErrUnavailable, which a policy counts separately: a person can be told to plug their key in, which is not the same as being told they failed.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrUnsupported = errors.New("factors: these are macOS factors")
ErrUnsupported is what these factors report off macOS.
It is wrapped as unavailable rather than as a refusal: a Linux machine has not failed anyone's Touch ID, it has no Touch ID. The Linux and Windows adapters are go-gnulinux/factors and go-mswin/factors.
Functions ¶
func DeviceOwner ¶
DeviceOwner is the sensor OR the login password, whichever the person chooses.
Its kind is mfa.Unknown, honestly: which one they used is not reported back, so this factor cannot say what it proved. A policy asking for distinct kinds will therefore never count it towards them -- which is the right answer rather than a limitation, because two factors that might both be passwords are not two factors.
func SecurityKey ¶
SecurityKey is a registered credential 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.
This proves POSSESSION and nothing more. A key on a desk that anybody can reach is still a key anybody can reach, which is exactly why it belongs alongside a factor of another kind rather than alone.
The asking itself is keyfactor's: it is the same everywhere CTAP is, and this package once carried its own copy. What is macOS's is [platformOpen] — finding the key, and knowing what its absence means.
func TouchID ¶
TouchID is the sensor as a factor. reason is what macOS shows the person in its own prompt, so it should say what is being unlocked.
It asks for BIOMETRY only. The framework can also be asked to accept the login password, and this deliberately does not: a factor that answered yes to either would be reporting mfa.Inherence when what happened was mfa.Knowledge. Use DeviceOwner when either will do, and it says so.
func VerifiedSecurityKey ¶
func VerifiedSecurityKey(rpID string, credentialID []byte, publicKey *ecdsa.PublicKey, pin string) mfa.Factor
VerifiedSecurityKey is the same, with the key asked to verify who holds it.
The PIN travels no further than the key: what goes over the wire is the first sixteen bytes of its SHA-256, encrypted under a secret agreed for that one exchange. It is still a secret in a Go string, so a caller that can avoid holding one should.
A wrong PIN costs the key a retry and a key that runs out locks. The key is asked how many are left first, and refuses rather than spending the last one blindly.
Types ¶
This section is empty.