-
Notifications
You must be signed in to change notification settings - Fork 0
/
auth.tf
95 lines (86 loc) · 3.5 KB
/
auth.tf
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
resource "aws_api_gateway_model" "mockSantanderAuthResponseModel" {
rest_api_id = aws_api_gateway_rest_api.mockSantander.id
name = "AuthResponseModel"
content_type = "application/json"
schema = <<EOF
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"access_token": {
"type": "string"
}
}
}
EOF
}
resource "aws_api_gateway_request_validator" "mockSantanderAuthRequestValidator" {
name = "AuthRequestValidator"
rest_api_id = aws_api_gateway_rest_api.mockSantander.id
validate_request_body = true
validate_request_parameters = true
}
resource "aws_api_gateway_integration" "mockSantanderAuthIntegration" {
rest_api_id = aws_api_gateway_rest_api.mockSantander.id
resource_id = aws_api_gateway_resource.mockSantanderResourceToken.id
http_method = aws_api_gateway_method.mockSantanderAuthMethod.http_method
request_templates = {
"application/json" = <<EOF
{
#if( $input.params('grant_type') == "client_credentials" )
"statusCode": 200
#else
"statusCode": 500
#end
}
EOF
}
request_parameters = { "integration.request.querystring.grant_type" = "'method.request.querystring.grant_type'" }
type = "MOCK"
}
resource "aws_api_gateway_method_response" "mockSantanderAuthResponse200" {
rest_api_id = aws_api_gateway_rest_api.mockSantander.id
resource_id = aws_api_gateway_resource.mockSantanderResourceToken.id
http_method = aws_api_gateway_method.mockSantanderAuthMethod.http_method
status_code = "200"
response_models = {
"application/json" = aws_api_gateway_model.mockSantanderAuthResponseModel.name
}
}
resource "aws_api_gateway_integration_response" "mockSantanderAuthIntegrationResponse200" {
rest_api_id = aws_api_gateway_rest_api.mockSantander.id
resource_id = aws_api_gateway_resource.mockSantanderResourceToken.id
http_method = aws_api_gateway_method.mockSantanderAuthMethod.http_method
status_code = aws_api_gateway_method_response.mockSantanderAuthResponse200.status_code
response_templates = {
"application/json" = <<EOF
{
"access_token": "mockAccessToken"
}
EOF
}
}
resource "aws_api_gateway_method_response" "mockSantanderAuthResponse500" {
rest_api_id = aws_api_gateway_rest_api.mockSantander.id
resource_id = aws_api_gateway_resource.mockSantanderResourceToken.id
http_method = aws_api_gateway_method.mockSantanderAuthMethod.http_method
status_code = "500"
response_models = {
"application/json" = aws_api_gateway_model.mockSantanderAuthResponseModel.name
}
}
resource "aws_api_gateway_integration_response" "mockSantanderAuthIntegrationResponse500" {
rest_api_id = aws_api_gateway_rest_api.mockSantander.id
resource_id = aws_api_gateway_resource.mockSantanderResourceToken.id
http_method = aws_api_gateway_method.mockSantanderAuthMethod.http_method
status_code = aws_api_gateway_method_response.mockSantanderAuthResponse500.status_code
selection_pattern = "5\\d{2}"
}
resource "aws_api_gateway_method" "mockSantanderAuthMethod" {
rest_api_id = aws_api_gateway_rest_api.mockSantander.id
resource_id = aws_api_gateway_resource.mockSantanderResourceToken.id
http_method = "POST"
authorization = "NONE"
request_validator_id = aws_api_gateway_request_validator.mockSantanderAuthRequestValidator.id
request_parameters = { "method.request.querystring.grant_type" = true }
}