-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
INCIDEN-922: WIP access controls other lambdas [deploy]
- Loading branch information
1 parent
0cf6821
commit 775d1bb
Showing
8 changed files
with
151 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,40 @@ | ||
import {APIGatewayProxyEvent, APIGatewayProxyResult, Context} from "aws-lambda"; | ||
import {stepFunctionHandler} from "./step-function-handler"; | ||
import {validateAuthorisationHeader} from "../helper/validate-authorisation-header"; | ||
import DynamoDbClient from "../../dynamodb-client"; | ||
|
||
const client = new DynamoDbClient(); | ||
|
||
export const doUpdateClientHandler = async (event: APIGatewayProxyEvent, context: Context): Promise<APIGatewayProxyResult> => { | ||
if (!event.body) { | ||
return {statusCode: 400, body: "Invalid Request, missing body"}; | ||
} | ||
|
||
const updateClientBody: { | ||
serviceId: string; | ||
updates: Record<string, string>; | ||
} = JSON.parse(event.body); | ||
|
||
const serviceId = updateClientBody.serviceId; | ||
|
||
if (!serviceId) { | ||
return {statusCode: 400, body: "Invalid Request, missing service ID"}; | ||
} | ||
|
||
const authHeaderValidationResult = validateAuthorisationHeader(event.headers.Authorization); | ||
|
||
if (!authHeaderValidationResult.valid) { | ||
return authHeaderValidationResult.errorResponse; | ||
} | ||
|
||
const isUserAuthorised = await client.checkServiceUserExists(serviceId, authHeaderValidationResult.userId); | ||
|
||
if (!isUserAuthorised) { | ||
return { | ||
statusCode: 403, | ||
body: "Forbidden" | ||
}; | ||
} | ||
|
||
return stepFunctionHandler(event, context); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters