-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpolicy-server-api.yaml
More file actions
301 lines (270 loc) · 9.41 KB
/
Copy pathpolicy-server-api.yaml
File metadata and controls
301 lines (270 loc) · 9.41 KB
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
openapi: 3.0.3
info:
title: Epithet Policy Server API
version: 2.0.0
description: |
The Policy Server API is called by the Epithet CA to make authorization decisions
for SSH certificate requests. Your policy server receives authentication tokens,
connection details, and returns certificate parameters if the request is approved.
This OpenAPI specification can be used to:
- Generate server stubs in your preferred language
- Configure API gateways (AWS API Gateway, Kong, etc.)
- Validate requests and responses
- Generate client libraries
## Security
The CA signs the authentication token with its private key and includes the signature
in the request. Your policy server MUST verify this signature before processing
the request to prevent unauthorized certificate issuance.
contact:
name: Epithet Project
url: https://github.com/epithet-ssh/epithet
license:
name: MIT
url: https://opensource.org/licenses/MIT
servers:
- url: https://policy.example.com
description: Your policy server endpoint
paths:
/:
post:
operationId: evaluatePolicy
summary: Evaluate certificate request policy
description: |
Evaluate whether to approve an SSH certificate request and determine
the certificate parameters (principals, expiration, extensions).
The policy server should:
1. Verify the signature to ensure the request came from your CA
2. Validate the authentication token
3. Check authorization (can this user access this host?)
4. Determine principals (which usernames to allow)
5. Set appropriate expiration and extensions
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/PolicyRequest'
examples:
typical:
summary: Typical policy request
value:
token: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."
signature: "MEUCIQDx1KZ2vH..."
connection:
localHost: "alice-laptop.corp.example.com"
localUser: "alice"
remoteHost: "prod-web-01.example.com"
remoteUser: "deploy"
port: 22
proxyJump: ""
hash: "a1b2c3d4e5f67890"
responses:
'200':
description: Certificate request approved
content:
application/json:
schema:
$ref: '#/components/schemas/PolicyResponse'
examples:
approved:
summary: Approved with standard permissions
value:
certParams:
identity: "alice@example.com"
principals: ["deploy", "www-data"]
expiration: "5m0s"
extensions:
permit-pty: ""
permit-agent-forwarding: ""
policy:
hostPattern: "*.example.com"
'401':
description: Invalid signature or authentication token
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
examples:
invalidSignature:
summary: Signature verification failed
value:
error: "invalid signature from CA"
'403':
description: User not authorized for this access
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
examples:
notAuthorized:
summary: User not permitted
value:
error: "user alice not authorized for deploy@prod-web-01.example.com"
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
components:
schemas:
PolicyRequest:
type: object
required:
- token
- signature
- connection
properties:
token:
type: string
description: |
Authentication token from the user. The format is determined by your
auth plugin (could be JWT, OIDC token, SAML assertion, etc.)
example: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."
signature:
type: string
description: |
Base64-encoded cryptographic signature of the token, signed by the
CA's private key using Rekor/Sigstore. MUST be verified before
processing the request.
example: "MEUCIQDx1KZ2vH..."
connection:
$ref: '#/components/schemas/Connection'
Connection:
type: object
required:
- localHost
- localUser
- remoteHost
- remoteUser
- port
- hash
properties:
localHost:
type: string
description: User's local hostname (OpenSSH %l)
example: "alice-laptop.corp.example.com"
localUser:
type: string
description: User's local username
example: "alice"
remoteHost:
type: string
description: Target SSH server hostname (OpenSSH %h)
example: "prod-web-01.example.com"
remoteUser:
type: string
description: Target username on remote server (OpenSSH %r)
example: "deploy"
port:
type: integer
format: uint32
description: Target SSH port (OpenSSH %p)
example: 22
minimum: 1
maximum: 65535
proxyJump:
type: string
description: ProxyJump configuration (OpenSSH %j), empty string if not used
example: ""
hash:
type: string
description: |
OpenSSH %C hash - unique identifier for this connection, computed
from local host, remote host, port, remote user, and proxy jump
example: "a1b2c3d4e5f67890"
pattern: "^[a-f0-9]{16}$"
PolicyResponse:
type: object
required:
- certParams
- policy
properties:
certParams:
$ref: '#/components/schemas/CertParams'
policy:
$ref: '#/components/schemas/Policy'
CertParams:
type: object
required:
- identity
- principals
- expiration
- extensions
properties:
identity:
type: string
description: |
Certificate identity/key ID used for audit logging and display.
Typically user email or username.
example: "alice@example.com"
principals:
type: array
description: |
List of usernames this certificate can authenticate as on the
remote server. Must match entries in the server's authorized_principals
file or TrustedUserCAKeys configuration.
items:
type: string
example: ["deploy", "www-data", "ubuntu"]
minItems: 1
expiration:
type: string
description: |
Certificate validity duration in Go duration format (e.g., "5m", "10m", "1h").
Recommended: 2-10 minutes for short-lived certificates that limit
exposure if compromised.
example: "5m0s"
pattern: "^[0-9]+(ns|us|µs|ms|s|m|h)$"
extensions:
type: object
description: |
SSH certificate extensions to grant. Keys are extension names,
values are typically empty strings. Common extensions:
- permit-pty: Allow terminal allocation
- permit-agent-forwarding: Allow SSH agent forwarding
- permit-port-forwarding: Allow port forwarding
- permit-user-rc: Allow executing ~/.ssh/rc
- permit-X11-forwarding: Allow X11 forwarding
additionalProperties:
type: string
example:
permit-pty: ""
permit-agent-forwarding: ""
minProperties: 0
Policy:
type: object
required:
- hostPattern
properties:
hostPattern:
type: string
description: |
Glob pattern for hosts this certificate is valid for. The pattern
is matched against the remote hostname. Use specific patterns in
production to limit certificate scope.
Examples:
- "*.example.com" - All hosts in example.com
- "prod-*.example.com" - Production hosts only
- "server-01.example.com" - Single specific host
- "*" - All hosts (NOT recommended for production)
example: "*.example.com"
pattern: "^[a-zA-Z0-9.*_-]+$"
Error:
type: object
required:
- error
properties:
error:
type: string
description: Human-readable error message
example: "user not authorized"
securitySchemes:
SignatureVerification:
type: apiKey
in: header
name: X-CA-Signature
description: |
While not a traditional API key, the signature field in the request
body serves as authentication. Your implementation MUST verify this
signature using the CA's public key before processing requests.