Skip to content
uatukoPublic

About

🎟️ Authentication for humans and bots

Topics

Resources

Stars

6 stars

Watchers

0 watching

Forks

Repository files navigation

tknz 🎟️

Authentication for humans and bots.

Running locally

KMS

# create an ec private key to use with local kms
mkdir .tmp
openssl ecparam -name prime256v1 -genkey -noout -out .tmp/key.pem
# convert private key to a jwk (to use when adding jwks to the db)
go run ./cmd/mkjwks -keys .tmp/key.pem \
  | jq -c '.[0] + {kid: "local", use: "sig", key_ops: ["sign", "verify"]}'
// e.g.
{
  "alg": "ES256",
  "kty": "EC",
  "crv": "P-256",
  "x": "…",
  "y": "…",
  "kid": "local",
  "use": "sig",
  "key_ops": ["sign", "verify"]
}

DB

# create postgres user and database
echo "create user tknz; create database tknz owner tknz;" | psql

# db schema
psql --username=tknz --dbname=tknz < db/schema.sql
-- create 'sys' space
insert into spaces (id, slug, attrs) values ('sys', 'sys', '{}');

update spaces
set
  attrs = jsonb_set(attrs, '{_rev}',
  to_jsonb(extract(epoch from clock_timestamp())::integer))
where id = 'sys';


-- add jwk (replace <jwk> with json from private key)
insert into jwks (id, space_id, attrs, params) values (
  'local',
  'sys',
  '{}',
  '<jwk>'
);

Run

PGDATABASE=tknz PGUSER=tknz make run

Smoke test

curl --http2 http://localhost:8080/oidc/.well-known/jwks.json

# e.g. {"keys":[{"alg":"ES256","kid":"local","kty":"EC","use":"sig","crv":"P-256","x":"…","y":"…"}]}

About

🎟️ Authentication for humans and bots

Topics

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages