Skip to content

About

Shared Go security primitives for the Ky Suite: OIDC, TOTP, recovery keys, Shamir

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

292 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ky-primitives

OpenSSF Best Practices OpenSSF Scorecard

Shared security primitives for the Busness.app suite.

The offsite/ directory is a separately versioned nested module. Its transport dependencies are not requirements of this root module.

  • Contributing — how to propose a change and what it must pass.
  • Verifying releases — check a module version against this repository and the Go checksum database.
  • Release notes — changes and upgrade impact for every root/offsite module tag.
  • Assurance case — threat model, trust boundaries, and why the security requirements are met.
  • Strong-cryptography configuration — required source/key sizes, verified TLS peer policy and excluded compatibility destinations.

The root module's dependency budget is golang.org/x/crypto and the golang.org/x/sys it drags in, and nothing else. In that module, everything but password is standard-library-only. The rule was "no dependencies, ever" so that products with minimal trees could import this for free — kypassword-server's go.mod named no third-party module at all, and now names exactly one: this library — and Argon2 is the one thing that broke it: the suite standardised on it for password hashing, and it is neither in the standard library nor on a proposal track.

Two tests hold that line. TestModuleDependenciesAreAllowlisted fails on any require outside the budget; TestOnlyPasswordImportsADependency discovers every other package and fails if any of them imports one. A consumer that only wants capsule compiles none of x/crypto, but it does inherit the requirement in its own go.mod — that is the cost.

go list -m all names five golang.org/x modules because they sit in x/crypto's own requirement graph. Only two reach go.sum, and the build compiles three packages: x/sys/cpu, x/crypto/blake2b and x/crypto/argon2.

A primitive belongs here when the suite's copies of it disagree in a way that silently corrupts or loses recovery data. Duplicated HTTP, session and header code across the suite is real security debt, but it is per-product configuration rather than a durable format, so it is fixed in place rather than moved here.

Packages

Each package's contract, the flaws it replaced and the tests that pin it are in the linked page.

Package What it is
capsule Reads and writes the suite's encrypted backup container.
recoverykey The suite's recovery keypair; its private key exists only while it is split into shares or combined for a restore.
shamir Splits a secret into custodian shares and reconstructs it.
recoverycode One-time codes that bypass every other factor, so their strength is the account's strength.
recoveryclient The product side of the suite's backup contract with KyRecovery.
auditchain Builds and verifies a tamper-evident hash chain over audit records.
logging Emits JSON lines on stderr.
health Serves /healthz in the suite's one shape, ky.health/1, which kyPulse reads.
password Hashes and verifies passwords with Argon2id.
totp RFC 6238 one-time passwords.
keyfile Loads a long-lived secret from disk, creating it on first use.
derive The login secret a client sends in place of a password: PBKDF2-SHA256 stretched, then HKDF-SHA256 expanded.
syncauth One definition of how KySignOn signs a directory-sync event and how a product verifies it.
oidcverify Verifies the RS256 tokens KySignOn issues against its JWKS, on the standard library.
scim The SCIM 2.0 client KySignOn provisions accounts with, and the RFC 7643 User type it shares with a server.
suitedir Asks KyIdentity which suite apps a user may open, which organisation people the calling app can offer, its suite groups, a paired app's URL and shared syncauth secret, and a multi-tenant install's organisations and erased subjects.
s3 Shared signed HTTPS object/version client; products own storage policy.
netallow The office-network allowlist that exempts requests from per-IP rate limits.

offsite nested module

One client for copying opaque data to S3-compatible storage, pinned SFTP, signed SMB 2/3, or a local directory. It is a nested module so products that only use the root primitives do not inherit the SFTP and SMB dependency trees.

target, err := offsite.Parse(offsite.Config{
	URL: "sftp://backup@vault.example/copies",
	Secret: privateKey,
	HostKey: "SHA256:...",
})
err = target.Put(ctx, "attachments/object-id", body, size)

See offsite/README.md for URL forms and the security contract. Release tags are namespaced for the nested module: offsite/v0.1.0. Consumers install that release with go get github.com/Busnes-app/ky-primitives/offsite@v0.1.0.

Contributing

Nothing in this repository builds its consumers. The check that does lives in each of them: .github/workflows/ky-primitives-compat.yml in gridlock-server, kybookmarks-server and kypassword-server builds and tests that consumer against this module's default branch instead of the version it pins. It runs on a daily schedule and on workflow_dispatch, not on pull requests -- in either repository.

It lives there rather than here because the dependency only points one way without a credential. A consumer, public or private, can read this repository anonymously; reaching a private consumer from here needed an organisation token, which is why the job that used to do it never ran.

The cost is immediacy. A change that breaks a consumer will not fail your pull request. It will fail in that consumer's scheduled run, up to a day later, in a repository you may not watch, and the person who sees it red will be someone whose own work is unrelated. If you are making a change you expect to break a consumer, do not wait for the schedule: open the consumer's PR alongside yours and run its compatibility workflow by hand from the Actions tab once this change is on master.

The other six suite repositories do not import this module and have no such workflow; adding one is a copy of the file with the cron minute changed.

License

ky-primitives is released under the MIT License.

OctoCounts

Documentation

About

Shared Go security primitives for the Ky Suite: OIDC, TOTP, recovery keys, Shamir

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages