| 1 | /* |
| 2 | * Copyright (c) 2024 Metaform Systems, Inc. |
| 3 | * |
| 4 | * This program and the accompanying materials are made available under the |
| 5 | * terms of the Apache License, Version 2.0 which is available at |
| 6 | * https://www.apache.org/licenses/LICENSE-2.0 |
| 7 | * |
| 8 | * SPDX-License-Identifier: Apache-2.0 |
| 9 | * |
| 10 | * Contributors: |
| 11 | * Metaform Systems, Inc. - initial API and implementation |
| 12 | * |
| 13 | */ |
| 14 | |
| 15 | -- only intended for and tested with Postgres! |
| 16 | CREATE TABLE IF NOT EXISTS keypair_resource |
| 17 | ( |
| 18 | id VARCHAR PRIMARY KEY NOT NULL, -- primary key |
| 19 | participant_id VARCHAR, -- ID of the owning ParticipantContext. this is a loose business key, not a FK! |
| 20 | timestamp BIGINT NOT NULL, -- creation timestamp |
| 21 | key_id VARCHAR NOT NULL, -- name/key-id of this key pair. for use in JWTs etc. |
| 22 | group_name VARCHAR, |
| 23 | is_default_pair BOOLEAN DEFAULT FALSE, -- whether this keypair is the default one for a participant context |
| 24 | use_duration BIGINT, -- maximum time this keypair can be active before it gets rotated |
| 25 | rotation_duration BIGINT, -- duration during which this keypair is in a transitional state (rotated, not yet deactivated) |
| 26 | serialized_public_key VARCHAR NOT NULL, -- serialized public key (PEM, JWK,...) |
| 27 | private_key_alias VARCHAR NOT NULL, -- alias under which the private key is stored in the HSM/Vault |
| 28 | state INT NOT NULL DEFAULT 100 -- KeyPairState |
| 29 | ); |
| 30 | |