Repository navigation
AUT-681 - Adding example for running autograph locally with a test signer #1267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
bb02d11
39e0063
b4e2f59
b81aaf2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
| healthcheck: | ||
| test: ["CMD", "curl", "-f", "http://localhost:8000/__heartbeat__"] | ||
| interval: 60s | ||
| timeout: 10s | ||
| retries: 3 | ||
| 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 |
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this +
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
| 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; |
| 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'); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
autograph/main.go
Line 136 in 01e387b
Here's where the default file for the config is set unless passed in the command.