Skip to content

Commit 5b78304

Browse files
OJ-3227 - Define issue credential infrastructure
1 parent 81bea1b commit 5b78304

2 files changed

Lines changed: 114 additions & 1 deletion

File tree

infrastructure/public-api.yaml

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ paths:
7575
x-amazon-apigateway-integration:
7676
httpMethod: "GET"
7777
credentials:
78-
Fn::GetAtt: [ "JWKSBucketRole", "Arn" ]
78+
Fn::GetAtt: ["JWKSBucketRole", "Arn"]
7979
uri:
8080
Fn::Sub:
8181
- "arn:aws:apigateway:${AWS::Region}:s3:path/govuk-one-login-hmrc-check-published-keys-${env}/jwks.json"
@@ -264,6 +264,57 @@ paths:
264264
#set($context.responseOverride.header.Content-Type = "application/jwt")
265265
$output.jwt
266266
267+
/credential/issue-test:
268+
summary: Resource for the HMRC KBV API
269+
description: >-
270+
This API is expected to be called by the IPV core backend directly as the
271+
final part of the OpenId/Oauth Flow
272+
parameters:
273+
- name: Authorization
274+
in: header
275+
required: true
276+
description: "A valid access_token (e.g.: Authorization: Bearer <access-token-value>)."
277+
schema:
278+
type: string
279+
post:
280+
summary: POST request using a valid access token
281+
responses:
282+
"200":
283+
description: 200 Ok
284+
content:
285+
application/jwt:
286+
schema:
287+
$ref: "#/components/schemas/VcResponse"
288+
"400":
289+
description: 400 Bad Response
290+
content:
291+
application/json:
292+
schema:
293+
$ref: "#/components/schemas/Error"
294+
"500":
295+
description: 500 Internal server error
296+
content:
297+
application/json:
298+
schema:
299+
$ref: "#/components/schemas/Error"
300+
security:
301+
- api_key:
302+
Fn::If:
303+
- IsLocalDevEnvironment
304+
- Ref: AWS::NoValue
305+
- []
306+
x-amazon-apigateway-request-validator: "Validate both"
307+
x-amazon-apigateway-integration:
308+
httpMethod: "POST"
309+
uri:
310+
Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${IssueCredentialFunction.Arn}:live/invocations
311+
responses:
312+
default:
313+
statusCode: "200"
314+
passthroughBehavior: "when_no_match"
315+
contentHandling: "CONVERT_TO_TEXT"
316+
type: "aws_proxy"
317+
267318
components:
268319
schemas:
269320
JWKSFile:

infrastructure/template.yaml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,6 +1441,68 @@ Resources:
14411441
FunctionName: !Ref NinoCheckFunction.Alias
14421442
Principal: apigateway.amazonaws.com
14431443

1444+
IssueCredentialFunction:
1445+
Type: AWS::Serverless::Function
1446+
Metadata:
1447+
BuildMethod: esbuild
1448+
BuildProperties:
1449+
Sourcemap: true
1450+
Properties:
1451+
DeploymentPreference:
1452+
Type: !Ref LambdaDeploymentPreference
1453+
Alarms: !If
1454+
- UseCanaryDeploymentAlarms
1455+
- [!Ref NinoCheckFunctionCanaryErrors]
1456+
- [!Ref AWS::NoValue]
1457+
Role: !GetAtt CodeDeployServiceRole.Arn
1458+
Handler: lambdas/issue-credential/src/handler.handler
1459+
LoggingConfig:
1460+
LogGroup: !Sub /aws/lambda/${AWS::StackName}/IssueCredentialFunction
1461+
CodeSigningConfigArn: !If [EnforceCodeSigning, !Ref CodeSigningConfigArn, !Ref AWS::NoValue]
1462+
Policies:
1463+
- DynamoDBReadPolicy:
1464+
TableName: !Sub "{{resolve:ssm:/${CommonStackName}/SessionTableName}}"
1465+
- DynamoDBReadPolicy:
1466+
TableName: !Sub "{{resolve:ssm:/${CommonStackName}/PersonIdentityTableName}}"
1467+
- DynamoDBReadPolicy:
1468+
TableName: !Ref UserAttemptsTable
1469+
- DynamoDBReadPolicy:
1470+
TableName: !Ref NinoUsersTable
1471+
- EventBridgePutEventsPolicy:
1472+
EventBusName: !Ref CheckHmrcEventBus
1473+
Environment:
1474+
Variables:
1475+
POWERTOOLS_SERVICE_NAME: !Sub "${CriIdentifier}-IssueCredentialFunction"
1476+
SESSION_TABLE: !Sub "{{resolve:ssm:/${CommonStackName}/SessionTableName}}"
1477+
PERSON_IDENTITY_TABLE: !Sub "{{resolve:ssm:/${CommonStackName}/PersonIdentityTableName}}"
1478+
ATTEMPT_TABLE: !Ref UserAttemptsTable
1479+
NINO_USER_TABLE: !Ref NinoUsersTable
1480+
AUDIT_EVENT_BUS: !Ref CheckHmrcEventBus
1481+
AUDIT_SOURCE: !FindInMap [EnvironmentConfiguration, !Ref Environment, DOMAINNAME]
1482+
AUDIT_ISSUER: !Sub "{{resolve:ssm:/${CommonStackName}/verifiable-credential/issuer}}"
1483+
LOG_FULL_ERRORS: !If [IsProdEnvironment, "false", "true"]
1484+
1485+
IssueCredentialFunctionLogGroup:
1486+
Type: AWS::Logs::LogGroup
1487+
Properties:
1488+
LogGroupName: !Sub /aws/lambda/${AWS::StackName}/IssueCredentialFunction
1489+
RetentionInDays: 30
1490+
1491+
IssueCredentialFunctionLogsSubscriptionFilterCSLS:
1492+
Type: AWS::Logs::SubscriptionFilter
1493+
Condition: IsNotDevLikeEnvironment
1494+
Properties:
1495+
DestinationArn: !FindInMap [PlatformConfiguration, !Ref Environment, CSLSEGRESS]
1496+
FilterPattern: ""
1497+
LogGroupName: !Ref IssueCredentialFunctionLogGroup
1498+
1499+
IssueCredentialFunctionPermission:
1500+
Type: AWS::Lambda::Permission
1501+
Properties:
1502+
Action: lambda:InvokeFunction
1503+
FunctionName: !Ref IssueCredentialFunction.Alias
1504+
Principal: apigateway.amazonaws.com
1505+
14441506
NinoCheckStateMachine:
14451507
Type: AWS::Serverless::StateMachine
14461508
Properties:

0 commit comments

Comments
 (0)