Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,12 @@ be used with the following self-signed certificate:
> vxT5RAdzQRp9/l3OqnUP+kK42tRk05c9UGDFXLLVH/4CMH/ZmcpvtM0sCjeAWzGs
> gnw91z0443965WZmaeBKpbinxB1PpnNMCnPhd9J/Hz40+Q==
> -----END CERTIFICATE-----



## Running autograph locally or in automated tests with your client application

A minimal example using docker compose that will run autograph with a test
signer can be found under [docs/local-example](./local-example/docker-compose.yml).
You can use this as a reference implementation to run a local autograph
instance for dev or testing.
31 changes: 31 additions & 0 deletions docs/local-example/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
services:
autograph-db:
image: postgres:18
environment:
- POSTGRES_DB=autograph
- POSTGRES_HOST_AUTH_METHOD=trust
volumes:
# initdb scripts are ran in alphabetical order
- ./pg-init:/docker-entrypoint-initdb.d
healthcheck:
test: ["CMD-SHELL", "pg_isready", "-d", "autograph"]
interval: 5s
timeout: 3s
retries: 5
start_period: 5s

autograph-app:
image: mozilla/autograph
ports:
- 8000:8000
depends_on:
autograph-db:
condition: service_healthy
volumes:
- ./my-service-config.yml:/app/my-service-config.yml
command: /go/bin/autograph -c /app/my-service-config.yml
Comment on lines +24 to +26

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I notice we don't have this custom config + command, and tests work for us. Is that by accident? What would this give us over the default?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default service config points at a different database container and has some additional properties defined. This is mainly a stripped down example.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fset.StringVar(&serviceFile, "c", "autograph-service.yaml", "Path to service configuration file")

Here's where the default file for the config is set unless passed in the command.

healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/__heartbeat__"]
interval: 60s
timeout: 10s
retries: 3
21 changes: 21 additions & 0 deletions docs/local-example/my-service-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
server:
listen: "0.0.0.0:8000"
noncecachesize: 524288
idletimeout: 60s
readtimeout: 60s
writetimeout: 60s

database:
name: autograph
user: myautographdbuser
password: myautographdbpassword
host: autograph-db:5432
maxopenconns: 100
maxidleconns: 10
monitorpollinterval: 10s

heartbeat:
hsmchecktimeout: 100ms
dbchecktimeout: 150ms

hawktimestampvalidity: 10m
62 changes: 62 additions & 0 deletions docs/local-example/pg-init/autograph-schema.sql

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this + my-signer-config.sql the same as https://github.com/mozilla-services/autograph/blob/main/database/schema.sql, or are there any notable changes to call out?

@alexcottner alexcottner Oct 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

database/schema.sql includes all of the test signers for unit tests. my-signer-config.sql is just one example signer and one auth. It's a very stripped down to show how somebody could add their specific test signer and auth. The DB schema is the same though.

Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
Autograph v9 database schema
*/

CREATE ROLE myautographdbuser;
ALTER ROLE myautographdbuser WITH NOSUPERUSER INHERIT NOCREATEROLE NOCREATEDB LOGIN PASSWORD 'myautographdbpassword';

CREATE TABLE endentities(
id SERIAL PRIMARY KEY,
label VARCHAR NOT NULL,
hsm_handle BIGINT NOT NULL,
signer_id VARCHAR NOT NULL,
is_current BOOLEAN NOT NULL,
x5u VARCHAR NULL,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
CREATE INDEX endentities_latest_idx ON endentities(label, signer_id, is_current);
ALTER TABLE endentities ADD CONSTRAINT endentities_unique_label UNIQUE (label);
GRANT SELECT, INSERT ON endentities TO myautographdbuser;
GRANT UPDATE (is_current) ON endentities TO myautographdbuser;
GRANT USAGE ON endentities_id_seq TO myautographdbuser;

CREATE TABLE endentities_lock(
id SERIAL PRIMARY KEY,
is_locked BOOLEAN NOT NULL,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
freed_at TIMESTAMP WITH TIME ZONE

);
GRANT SELECT, INSERT, UPDATE ON endentities_lock TO myautographdbuser;
GRANT USAGE ON endentities_lock_id_seq TO myautographdbuser;

CREATE TABLE auth(
id VARCHAR(128) PRIMARY KEY,
key VARCHAR(64) NOT NULL,
comments varchar,
created TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
updated TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
GRANT SELECT, INSERT ON auth TO myautographdbuser;

CREATE TABLE signer (
id VARCHAR(128) PRIMARY KEY,
type VARCHAR(64) NOT NULL,
mode VARCHAR(64) NULL,
comments VARCHAR,
created TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
updated TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
secret VARCHAR(256), -- points to a secret that can be read by application
public JSONB
);
GRANT SELECT, INSERT, UPDATE ON signer TO myautographdbuser;

CREATE TABLE auth_signers(
auth varchar(128),
signer varchar(128),
created TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
CONSTRAINT auth_signers_pk PRIMARY KEY(auth, signer),
CONSTRAINT auth_signers_fk_auth FOREIGN KEY(auth) REFERENCES auth(id),
CONSTRAINT auth_signers_fk_signer FOREIGN KEY(signer) REFERENCES signer(id)
);
GRANT SELECT, INSERT ON auth_signers TO myautographdbuser;
60 changes: 60 additions & 0 deletions docs/local-example/pg-init/my-signer-config.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@


/*
Example signer/auth config that could be used for local dev or tests
*/

INSERT INTO signer(id, type, mode, public, comments)
values('remote-settings', 'contentsignaturepki', null, jsonb_build_object(
'validity', '708h',
'clockskewtolerance', '1h',
'chainlocation', '/tmp/autograph/chains/remotesettingsdev/',
'x5u', 'file:///tmp/autograph/chains/remotesettingsdev/',
'issuerprivkey', '-----BEGIN EC PRIVATE KEY-----
MIGkAgEBBDBEk1fq5FMwBSLKDldmW+QRo15eebdJK1DdrUlp2SmwVf85TffXlFsa
accDMiiow/WgBwYFK4EEACKhZANiAARP5dbB0qgDev4IRzVkuHDYf2TDc8YkpNFW
nQ/KonN1EWrMIWNAeuOOJgjswwq0+M2J0/TNcnYlts5tVZh6MFYKwYHG/NlkTZZ5
5wb3GKy8JkoFH/X74Tm3o06hf0BuCfY=
-----END EC PRIVATE KEY-----
', 'issuercert', '-----BEGIN CERTIFICATE-----
MIICWzCCAeKgAwIBAgIIFY4HHiYeU5AwCgYIKoZIzj0EAwMwXzELMAkGA1UEBhMC
VVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRAwDgYDVQQK
EwdNb3ppbGxhMRkwFwYDVQQDExBjc3Jvb3QxNTUzMTg2NzQ3MB4XDTE5MDEyMDE3
NDU0N1oXDTI5MDMyMTE2NDU0N1owYDELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNB
MRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRAwDgYDVQQKEwdNb3ppbGxhMRowGAYD
VQQDExFjc2ludGVyMTU1MzE4Njc0NzB2MBAGByqGSM49AgEGBSuBBAAiA2IABE/l
1sHSqAN6/ghHNWS4cNh/ZMNzxiSk0VadD8qic3URaswhY0B6444mCOzDCrT4zYnT
9M1ydiW2zm1VmHowVgrBgcb82WRNlnnnBvcYrLwmSgUf9fvhObejTqF/QG4J9qNq
MGgwDgYDVR0PAQH/BAQDAgGGMBMGA1UdJQQMMAoGCCsGAQUFBwMDMA8GA1UdEwEB
/wQFMAMBAf8wMAYDVR0eAQH/BCYwJKAiMCCCHi5jb250ZW50LXNpZ25hdHVyZS5t
b3ppbGxhLm9yZzAKBggqhkjOPQQDAwNnADBkAjBPi4uhzbCzoFxYD2LZY+hUQ1kX
eHE9YmF0NOBbosIY041UrbLQLpQRXi4LFku9008CMGoSf/UGB6qV9KzsCY3s51Lp
Rw/oK58D2n63FpPnOTICWvWAYsG3HPNCoURfLqlEOQ==
-----END CERTIFICATE-----
', 'cacert', '-----BEGIN CERTIFICATE-----
MIICKjCCAa+gAwIBAgIIFY4HHiViG/gwCgYIKoZIzj0EAwMwXzELMAkGA1UEBhMC
VVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRAwDgYDVQQK
EwdNb3ppbGxhMRkwFwYDVQQDExBjc3Jvb3QxNTUzMTg2NzQ3MB4XDTE5MDExOTE3
NDU0N1oXDTQ5MDMyMTE3NDU0N1owXzELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNB
MRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRAwDgYDVQQKEwdNb3ppbGxhMRkwFwYD
VQQDExBjc3Jvb3QxNTUzMTg2NzQ3MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEhpId
iezJa9Ab2dCesA0pc5FIBdkA6uWWVU2hN3/CpTWcTbhZ6JRCSsGa31YEUEGkDuGl
C1ti6hzL0gq/vlnRkMoAcdPU8qdeOp/ZAmVYP+CZcQ0F0S/7PFjqE+5AiLGmozgw
NjAOBgNVHQ8BAf8EBAMCAYYwEwYDVR0lBAwwCgYIKwYBBQUHAwMwDwYDVR0TAQH/
BAUwAwEB/zAKBggqhkjOPQQDAwNpADBmAjEA1UhMQI32zwh4+UmD1tVYRFRLM0sy
raFyXTzUlrYF0YW89gvUXETPTmewAST397LAAjEAzGUC8N7h8BWfj6R9ES88UPgr
yhRZrsaFZybKjZnBwG7lN9AkrjpKC1h2z4naOXX3
-----END CERTIFICATE-----
'), 'Signer for local remote settings development. Will issue a certificate
valid for remote-settings.content-signature.mozilla.org. To use this
with Firefox, set security.content.signature.root_hash to
5E:36:F2:14:DE:82:3F:8B:29:96:89:23:5F:03:41:AC:AF:A0:75:AF:82:CB:4C:D4:30:7C:3D:B3:43:39:2A:FE

Note the private key of the root was not saved. Use tools/genpki to
make a new config as needed.');

INSERT INTO auth(id, key)
values('alice', 'fs5wgcer9qj819kfptdlp8gm227ewxnzvsuj9ztycsx08hfhzu');

INSERT INTO auth_signers(auth, signer)
values('alice', 'remote-settings');
Loading