-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpublic-api.yaml
More file actions
361 lines (357 loc) · 12.4 KB
/
public-api.yaml
File metadata and controls
361 lines (357 loc) · 12.4 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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
openapi: "3.0.1"
info:
title: "HMRC NINO Check Credential Issuer Public Api"
version: "1.0"
paths:
/.well-known/jwks.json:
get:
operationId: getWellKnownJwksJson
summary: Retrieve the public encryption keys issued by Check HMRC CRI.
description: >-
Return the current valid public keys as a JSON Web Key Set used to Encrypt JAR(s) requests for Check HMRC CRI
tags:
- Backend - Check HMRC CRI
responses:
"200":
description: >-
OK - key ring returned
headers:
Cache-Control:
schema:
type: "string"
Content-Type:
schema:
type: "string"
Strict-Transport-Security:
schema:
type: "string"
X-Content-Type-Options:
schema:
type: "string"
X-Frame-Options:
schema:
type: "string"
content:
application/json:
schema:
$ref: "#/components/schemas/JWKSFile"
"400":
description: 400 response
headers:
Cache-Control:
schema:
type: "string"
Content-Type:
schema:
type: "string"
Strict-Transport-Security:
schema:
type: "string"
X-Content-Type-Options:
schema:
type: "string"
X-Frame-Options:
schema:
type: "string"
"500":
description: Internal Server Error
headers:
Cache-Control:
schema:
type: "string"
Content-Type:
schema:
type: "string"
Strict-Transport-Security:
schema:
type: "string"
X-Content-Type-Options:
schema:
type: "string"
X-Frame-Options:
schema:
type: "string"
x-amazon-apigateway-integration:
httpMethod: "GET"
credentials:
Fn::GetAtt: ["JWKSBucketRole", "Arn"]
uri:
Fn::Sub:
- "arn:aws:apigateway:${AWS::Region}:s3:path/govuk-one-login-hmrc-check-published-keys-${env}/jwks.json"
- env:
Fn::If:
- IsLocalDevEnvironment
- dev
- Ref: Environment
responses:
default:
statusCode: "200"
responseParameters:
method.response.header.Cache-Control: "'max-age=300'"
passthroughBehavior: "when_no_match"
contentHandling: "CONVERT_TO_TEXT"
type: "aws"
/token:
post:
requestBody:
content:
application/x-www-form-urlencoded:
schema:
required:
- "grant_type"
- "code"
- "client_assertion_type"
- "client_assertion"
- "redirect_uri"
properties:
grant_type:
type: "string"
pattern: "authorization_code"
example: "authorization_code"
code:
type: "string"
minLength: 1
client_assertion_type:
type: "string"
pattern: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer"
example: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer"
client_assertion:
type: "string"
pattern: "[a-zA-Z0-9_=]+\\.[a-zA-Z0-9_=]+\\.[a-zA-Z0-9_\\-\\+\\/=]+"
redirect_uri:
type: "string"
format: "uri"
example: "https://di-ipv-core-stub.london.cloudapps.digital/callback"
examples:
201:
summary: "Example body to receive a HTTP 201 response"
value:
grant_type: "string"
code: "1fbc5730-9d17-416d-b2ca-0be90e1e93f5"
client_assertion_type: "string"
client_assertion: "string"
redirect_uri: "https://di-ipv-core-stub.london.cloudapps.digital/callback"
400:
summary: "Example body to receive a HTTP 400 response"
value:
grant_type: "string"
code: "fad21bea-bce9-4aa7-8889-d50c7d26616e"
client_assertion_type: "string"
client_assertion: "string"
redirect_uri: "string"
500:
summary: "Example body to receive a HTTP 500 response"
value:
grant_type: "string"
code: "f27b8afc-90ef-4e0f-83ad-00a2f5692590"
client_assertion_type: "string"
client_assertion: "string"
redirect_uri: "string"
responses:
"201":
description: "201 response"
content:
application/json:
schema:
$ref: "#/components/schemas/TokenResponse"
examples:
201:
value:
access_token: "1fbc5730-9d17-416d-b2ca-0be90e1e93f5"
token_type: "Bearer"
expires_in: "3600"
refresh_token: "uuid"
"400":
description: "400 response"
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"500":
description: "500 response"
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
security:
- api_key:
Fn::If:
- IsDevEnvironment
- Ref: AWS::NoValue
- []
x-amazon-apigateway-request-validator: "Validate both"
x-amazon-apigateway-integration:
httpMethod: "POST"
uri:
Fn::Sub: arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/arn:${AWS::Partition}:lambda:${AWS::Region}:${AWS::AccountId}:function:${CommonStackName}-AccessTokenFunctionTS:live/invocations
responses:
default:
statusCode: "200"
passthroughBehavior: "when_no_match"
contentHandling: "CONVERT_TO_TEXT"
type: "aws_proxy"
/credential/issue:
summary: Resource for the HMRC KBV API
description: >-
This API is expected to be called by the IPV core backend directly as the
final part of the OpenId/Oauth Flow
parameters:
- name: Authorization
in: header
required: true
description: "A valid access_token (e.g.: Authorization: Bearer <access-token-value>)."
schema:
type: string
post:
summary: POST request using a valid access token
responses:
"200":
description: 200 Ok
content:
application/jwt:
schema:
$ref: "#/components/schemas/VcResponse"
"400":
description: 400 Bad Response
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"500":
description: 500 Internal server error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
security:
- api_key:
Fn::If:
- IsLocalDevEnvironment
- Ref: AWS::NoValue
- []
x-amazon-apigateway-request-validator: "Validate both"
x-amazon-apigateway-integration:
httpMethod: "POST"
passthroughBehavior: "when_no_templates"
type: "aws"
credentials:
Fn::Sub: ${ExecuteStateMachineRole.Arn}
uri:
Fn::Sub: arn:${AWS::Partition}:apigateway:${AWS::Region}:states:action/StartSyncExecution
requestTemplates:
application/json:
Fn::Sub: |-
{
"input": "{\"bearerToken\": \"$util.escapeJavaScript($input.params('Authorization').trim())\"}",
"stateMachineArn": "${NinoIssueCredentialStateMachine.Arn}:live"
}
responses:
default:
statusCode: 500
responseTemplates:
application/jwt: |
#set($response = $util.parseJson($input.body))
#set($output = $util.parseJson($response.output))
#if($response.status == "FAILED")
#set($context.responseOverride.status = 500)
#elseif($output.httpStatus)
#set($context.responseOverride.status = $output.httpStatus)
#else
#set($context.responseOverride.status = 200)
#end
#set($context.responseOverride.header.Content-Type = "application/jwt")
$output.jwt
components:
schemas:
JWKSFile:
type: object
required:
- keys
additionalProperties: true
properties:
keys:
type: array
description: >-
The value of the `keys` parameter is an array of JWK values. By default, the order of the JWK
values within the array does not imply an order of preference among them, although applications of
JWK Sets can choose to assign a meaning to the order for their purposes, if desired.
items:
type: object
additionalProperties: true
description: >-
A JSON Web Key (JWK) as defined by [RFC7517](https://www.rfc-editor.org/rfc/rfc7517)
properties:
kty:
type: string
description: >-
The `kty` (key type) parameter identifies the cryptographic algorithm family used with the
key, such as `RSA or `EC`
use:
type: string
enum:
- sig
- enc
description: >-
The "use" (public key use) parameter identifies the intended use of the public key. The
"use" parameter is employed to indicate whether a public key is used for encrypting data or
verifying the signature on data. Valid values are `sig` (signature) and `enc` (encryption).
alg:
type: string
description: >-
The `alg` (algorithm) parameter identifies the algorithm intended for use with the key.
kid:
type: string
description: >-
The `kid` (key ID) parameter is used to match a specific key. This is used, for instance,
to choose among a set of keys within a JWK Set during key rollover. The structure of the
`kid` value is unspecified.
e:
type: string
description: >-
public exponent
n:
type: string
description: >-
public modulus
required:
- kty
VcResponse:
title: "Vc"
type: string
format: application/jwt
pattern: ^([a-zA-Z0-9_=]+)\.([a-zA-Z0-9_=]+)\.([a-zA-Z0-9_\-\+\/=]+)$
example: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
TokenResponse:
title: "AccessToken"
required:
- "access_token"
- "expires_in"
type: "object"
properties:
access_token:
type: string
description: "The access token for the given token request"
token_type:
type: string
description: "The authentication scheme"
example: Bearer
expires_in:
type: string
description: "The token expiration time in seconds"
example: "3600"
refresh_token:
type: string
description: "The refresh token is optional and not currently applicable"
Error:
title: "Error Schema"
type: "object"
properties:
message:
type: "string"
x-amazon-apigateway-request-validators:
Validate both:
validateRequestBody: true
validateRequestParameters: true
Validate Param only:
validateRequestParameters: true
validateRequestBody: false