Expand description
Maps peer certificates, verified by the transport, to directory identities.
The transport (see coqui-peer-tls) proves a peer holds the key of its certificate and
hands the certificate’s fingerprint in [Attempt::certificate]. This provider keeps the
fingerprints that were accepted in a [Table], each under a name and groups. A
certificate nobody accepted is not authenticated and is kept for a while as waiting, in a
second table, so whoever runs the service can accept it. Build the provider in code with
MtlsAccounts::builder.
§coqui-access-mtls
Client certificates as accounts. The transport (see coqui-peer-tls) proves a client holds
the key of its certificate and hands over the certificate; this provider trusts it pinned (an
accepted fingerprint kept in a Table, mapped to a name and groups), signed by a CA, or
either. A pinned certificate nobody accepted is not authenticated and is kept for a while as
waiting, with the address it came from, in a second Table, so an operator can accept it. A
CA-trusted one names its account by a field the deployment picks: an email or UPN SAN, the
subject’s CN, the fingerprint.
§Features
- Code first -
MtlsAccounts::builder()works out of the box with in-memory tables. - Any source - an
Arc<dyn Table<PeerRecord>>for the peers and anArc<dyn Table<Unaccepted>>for the waiting list. - Waiting list - unaccepted fingerprints under coqui-peer’s
WaitingQueue: one place per source (an IPv4 address or an IPv6 /64), 16 in all, the same certificate from one source written down at most once a minute; each bound is an option. - Any spelling -
sha256:<hex>, bare hex, colon-separated hex or grouped base32. - Claims - a certificate is answered with everything it said (subject and issuer names,
serial, UPN, email, DNS, URI and IP SANs, fingerprint, public key hash and the DER), and with no
accountpicks asby: "claims", for the consumer’s matcher to tie to a directory account. - Pinned by fingerprint or by public key - a key pin (
key:sha256:<hex>of the SubjectPublicKeyInfo) keeps signing in a certificate renewed on the same key, as a smartcard’s is; an account holds several pins, up tomax_pins(4), and one is removed alone. - CA trust -
TrustMode::CaorPinnedOrCawith aCaPolicy(CA file, subject and SAN globs), andaccountpicks over the certificate’s fields; an IP written as a DNS name counts as an IP by default.
§Installation
cargo add coqui-access-mtls --git https://github.com/Boriken-Dev/coqui-accessBuild coqui-access-mtls-plugin for the loadable library.
§Quick start
use coqui_access::{Attempt, Authenticator, Verdict};
use coqui_access_mtls::{MtlsAccounts, default_waiting_limits};
let peers = MtlsAccounts::builder().waiting_limits(default_waiting_limits()).build().unwrap();
let verdict = peers
.authenticate(Attempt { certificate: Some("not a fingerprint".into()), ..Attempt::default() })
.unwrap();
assert_eq!(verdict, Verdict::Unknown);MtlsAccounts of your own come from a table: MtlsAccounts::builder().table(table).build()?, where table
is a MemoryTable::from_records([PeerRecord::new(id, name, &fingerprint)]) or your own
Table<PeerRecord>; .waiting(table) keeps the waiting list somewhere else. The records
derive guatiao’s value traits, so any table keeps them.
The loadable plugin (provider id coqui_access_mtls) is configured with a source, for example
{ "source": { "file": { "path": "peers.toml", "format": "toml" } } } (format is toml or
json); the waiting list defaults to
peers.toml.waiting beside a file source and can be given its own waiting source. With no
source both live in memory.
§API overview
| Item | Purpose |
|---|---|
MtlsAccounts | The provider: builder() and the three kinds. |
MtlsAccountsBuilder | Options: table, waiting, max_records, max_pins, waiting_limits, record_limits; build. |
PeerRecord, Unaccepted | The records the two tables keep; guatiao value traits. |
Pin | One thing an account pins: a fingerprint or a key; key_of_certificate, parse, text. |
§Development
cargo test -p coqui-access-mtls --all-features
cargo clippy -p coqui-access-mtls --all-targets --all-features -- -D warnings§Releasing
This project follows Semantic Versioning and keeps a
CHANGELOG.md.
Pushing a tag matching v* triggers the release workflow of the repository.
§License
MPL-2.0 — see LICENSE.
Structs§
- Mtls
Accounts - MtlsAccounts as an Authenticator, Directory and Accounts implementation.
- Mtls
Accounts Builder - Options for
MtlsAccounts; every one has a default. - Peer
Record - One accepted peer as a [
Table] keeps it, keyed byname. - Pin
- One thing an account pins, as a record names it: a
kindand a canonicalvalue. - PinError
- Text that is not a pin. It never quotes the text.
- Unaccepted
- A fingerprint shown to the service that nobody has accepted, keyed by
fingerprint.
Enums§
- Trust
Mode - How a client certificate is trusted.
Constants§
- DEFAULT_
MAX_ CHAIN - The most certificates a client may send, leaf included, unless the builder says otherwise.
- DEFAULT_
MAX_ PINS - The most pins (fingerprints and keys together) one account may hold unless the builder says otherwise.
- DEFAULT_
MAX_ RECORDS - The most peers a table may hold unless the builder says otherwise.
- DEFAULT_
WAITING_ PER_ SOURCE - Places one source holds on the waiting list unless the builder says otherwise.
- DEFAULT_
WAITING_ RERECORD - How soon one fingerprint from one source is written down again unless the builder says otherwise.
- DEFAULT_
WAITING_ TOTAL - Places on the waiting list in all unless the builder says otherwise.
Functions§
- default_
account - The picks a CA-trusted certificate names its account by unless told otherwise: none. It
is then answered by its claims (
Lookup { by: "claims", .. }), and the consumer’s matcher ties it to a directory account. - default_
waiting_ limits - The bounds on the waiting list unless the builder says otherwise: one place per source (an IPv4 address, or an IPv6 /64), 16 in all, and a fingerprint from one source written down again at most once a minute.