File size: 7,971 Bytes
1e3bc19 b650253 1e3bc19 b650253 1e3bc19 b650253 1e3bc19 b650253 1e3bc19 b650253 1e3bc19 b650253 1e3bc19 b650253 1e3bc19 b650253 1e3bc19 b650253 1e3bc19 b650253 1e3bc19 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "api-key.schema.json",
"title": "ApiKeyRecord",
"description": "One API key as the server stores it (INT-007/APP-10, R4; R5: the single key system). The secret is never stored: only a salted PBKDF2-HMAC-SHA256 digest, with its own random salt. A key is either a /v2 key (workspace_id null; scopes 'route:purpose' from a closed list) or a workspace key (workspace_id set; workspace:* scopes only), never both. A key is never a forecasting machine, never trains, retains or publishes. rights is the ceiling of the rights a request may claim (and, on /v2/search, the purposes every item must carry). phase is always pre_lock: a key cannot attest a lock. Cross-field rules (semantic.check_api_key): a revoked key has revoked_at and revoked_reason, a live one has neither; expires_at is after created_at; a rotating key names rotated_to and grace_until; workspace scopes exactly when workspace_id. The public view ($defs/public_view) is what /v2/keys/self answers and has no salt and no digest.",
"type": "object",
"additionalProperties": false,
"required": [
"schema_version",
"key_id",
"tenant_id",
"workspace_id",
"label",
"scopes",
"rights",
"quota",
"status",
"phase",
"hash",
"created_at",
"expires_at",
"rotated_from",
"rotated_to",
"grace_until",
"revoked_at",
"revoked_reason"
],
"properties": {
"schema_version": {
"$ref": "common.schema.json#/$defs/schema_version"
},
"key_id": {
"$ref": "#/$defs/key_id"
},
"tenant_id": {
"$ref": "#/$defs/tenant_id"
},
"workspace_id": {
"$ref": "#/$defs/workspace_id"
},
"label": {
"$ref": "#/$defs/label"
},
"scopes": {
"$ref": "#/$defs/scopes"
},
"rights": {
"$ref": "#/$defs/rights"
},
"quota": {
"$ref": "#/$defs/quota"
},
"status": {
"$ref": "#/$defs/status"
},
"phase": {
"const": "pre_lock"
},
"hash": {
"type": "object",
"additionalProperties": false,
"required": [
"algorithm",
"iterations",
"salt",
"digest"
],
"properties": {
"algorithm": {
"const": "pbkdf2-hmac-sha256"
},
"iterations": {
"type": "integer",
"minimum": 10000,
"maximum": 10000000
},
"salt": {
"type": "string",
"pattern": "^[0-9a-f]{32}$"
},
"digest": {
"$ref": "common.schema.json#/$defs/sha256"
}
}
},
"created_at": {
"$ref": "common.schema.json#/$defs/utc"
},
"expires_at": {
"type": [
"string",
"null"
],
"pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]{1,6})?(Z|\\+00:00)$"
},
"rotated_from": {
"type": [
"string",
"null"
],
"pattern": "^key_[0-9a-f]{16}$"
},
"rotated_to": {
"type": [
"string",
"null"
],
"pattern": "^key_[0-9a-f]{16}$"
},
"grace_until": {
"type": [
"string",
"null"
],
"pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]{1,6})?(Z|\\+00:00)$"
},
"revoked_at": {
"type": [
"string",
"null"
],
"pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]{1,6})?(Z|\\+00:00)$"
},
"revoked_reason": {
"type": [
"string",
"null"
],
"enum": [
null,
"owner_revoked",
"rotated",
"compromised",
"tenant_closed",
"workspace_archived"
]
}
},
"$defs": {
"key_id": {
"type": "string",
"pattern": "^key_[0-9a-f]{16}$"
},
"tenant_id": {
"description": "tenant:<slug>. Canonical: tenant:deepstack-public (every reader of the app) and tenant:deepstack-internal; keys exist locally only in tenant:deepstack-internal and, in tests, tenant:qa-*.",
"type": "string",
"pattern": "^tenant:[a-z0-9][a-z0-9-]{1,62}$"
},
"workspace_id": {
"description": "The one workspace a workspace key is bound to; null for a /v2 key.",
"type": [
"string",
"null"
],
"pattern": "^ws_[0-9A-Za-z]{4,64}$"
},
"label": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9 ._-]{0,63}$"
},
"scopes": {
"type": "array",
"minItems": 1,
"maxItems": 8,
"uniqueItems": true,
"items": {
"enum": [
"answers:analyst",
"answers:resolution_explainer",
"search:analyst",
"scenarios:analyst",
"trackrecord:read",
"workspace:read",
"workspace:collections.read",
"workspace:notes.read",
"workspace:export.process"
]
}
},
"rights": {
"type": "object",
"additionalProperties": false,
"required": [
"policy_version",
"purposes"
],
"properties": {
"policy_version": {
"$ref": "common.schema.json#/$defs/id"
},
"purposes": {
"type": "array",
"minItems": 1,
"maxItems": 3,
"uniqueItems": true,
"items": {
"enum": [
"read",
"process",
"external_provider"
]
}
}
}
},
"quota": {
"type": "object",
"additionalProperties": false,
"required": [
"per_minute",
"per_day",
"concurrency"
],
"properties": {
"per_minute": {
"type": "integer",
"minimum": 1,
"maximum": 600
},
"per_day": {
"type": "integer",
"minimum": 1,
"maximum": 100000
},
"concurrency": {
"type": "integer",
"minimum": 1,
"maximum": 16
}
}
},
"status": {
"enum": [
"active",
"rotating",
"revoked",
"expired"
]
},
"public_view": {
"description": "What a key holder may read about its own key: no salt, no digest, no other key of the tenant.",
"type": "object",
"additionalProperties": false,
"required": [
"schema_version",
"key_id",
"tenant_id",
"workspace_id",
"label",
"scopes",
"rights",
"quota",
"status",
"phase",
"principal_scope",
"expires_at",
"grace_until"
],
"properties": {
"schema_version": {
"$ref": "common.schema.json#/$defs/schema_version"
},
"key_id": {
"$ref": "#/$defs/key_id"
},
"tenant_id": {
"$ref": "#/$defs/tenant_id"
},
"workspace_id": {
"$ref": "#/$defs/workspace_id"
},
"label": {
"$ref": "#/$defs/label"
},
"scopes": {
"$ref": "#/$defs/scopes"
},
"rights": {
"$ref": "#/$defs/rights"
},
"quota": {
"$ref": "#/$defs/quota"
},
"status": {
"$ref": "#/$defs/status"
},
"phase": {
"const": "pre_lock"
},
"principal_scope": {
"$ref": "common.schema.json#/$defs/principal_scope"
},
"expires_at": {
"type": [
"string",
"null"
],
"pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]{1,6})?(Z|\\+00:00)$"
},
"grace_until": {
"type": [
"string",
"null"
],
"pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]{1,6})?(Z|\\+00:00)$"
}
}
}
}
}
|