Newer
Older
worker_processes auto;
error_log /var/log/nginx/error.log debug;
pid /tmp/nginx.pid;
events {
worker_connections 1024;
}
http {
map $ssl_client_s_dn $ssl_client_s_dn_cn {
default "";
~(^|,)CN=(?<CN>[^,]+) $CN;
}
map "$request_method:$uri:$ssl_client_s_dn_cn" $helper_error_message {
default 'SUCCESS';
"~*(GET|DELETE):.*:(?!(superadmin))(.*)" '{"status":401, "title":"Unauthorized" ,"detail":"Role not authorized for this API route", "cause":"User role must be superadmin"}';
}
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
map "$request_method:$uri:$ssl_client_s_dn_cn" $invoker_error_message {
default 'SUCCESS';
"~*(PUT|DELETE):.*:(?!(INV|superadmin))(.*)" '{"status":401, "title":"Unauthorized" ,"detail":"Role not authorized for this API route", "cause":"User role must be invoker"}';
}
map "$request_method:$uri:$ssl_client_s_dn_cn" $provider_error_message {
default 'SUCCESS';
"~*(PUT|DELETE|PATCH):.*:(?!(AMF|superadmin))(.*)" '{"status":401, "title":"Unauthorized" ,"detail":"Role not authorized for this API route", "cause":"User role must be amf"}';
}
map "$request_method:$uri:$ssl_client_s_dn_cn" $publish_error_message {
default 'SUCCESS';
"~*.*:.*:(?!(APF|ccf|superadmin))(.*)" '{"status":401, "title":"Unauthorized" ,"detail":"User not authorized", "cause":"Certificate not authorized"}';
}
map "$request_method:$uri:$ssl_client_s_dn_cn" $acl_error_message {
default 'SUCCESS';
"~*.*:.*:(?!(AEF|ccf|superadmin))(.*)" '{"status":401, "title":"Unauthorized" ,"detail":"Role not authorized for this API route", "cause":"Certificate not authorized"}';
}
map "$request_method:$uri:$ssl_client_s_dn_cn" $discover_error_message {
default 'SUCCESS';
"~*.*:.*:(?!(INV|ccf|superadmin))(.*)" '{"status":401, "title":"Unauthorized" ,"detail":"User not authorized", "cause":"Certificate not authorized"}';
}
map "$request_method:$uri:$ssl_client_s_dn_cn" $security_error_message {
default 'SUCCESS';
"~*DELETE:.*:(?!(AEF|superadmin))(.*)" '{"status":401, "title":"Unauthorized" ,"detail":"Role not authorized for this API route", "cause":"User role must be aef"}';
"~*PUT:.*:(?!(INV|superadmin))(.*)" '{"status":401, "title":"Unauthorized" ,"detail":"Role not authorized for this API route", "cause":"User role must be invoker"}';
"~*GET:.*:(?!(AEF|superadmin))(.*)" '{"status":401, "title":"Unauthorized" ,"detail":"Role not authorized for this API route", "cause":"User role must be aef"}';
"~*POST:.*/update:(?!(INV|superadmin))(.*)" '{"status":401, "title":"Unauthorized" ,"detail":"Role not authorized for this API route", "cause":"User role must be invoker"}';
"~*POST:.*/delete:(?!(AEF|superadmin))(.*)" '{"status":401, "title":"Unauthorized" ,"detail":"Role not authorized for this API route", "cause":"User role must be aef"}';
"~*POST:.*/token:(?!(INV|superadmin))(.*)" '{"error":"unauthorized_client", "error_description":"Role not authorized for this API route"}';
}
map "$request_method:$uri:$ssl_client_s_dn_cn" $events_error_message {
default 'SUCCESS';
"~*.*:.*:ccf" '{"status":401, "title":"Unauthorized" ,"detail":"User not authorized", "cause":"Certificate not authorized"}';
}
server {
listen 8080;
location /test {
add_header Content-Type 'application/json';
return 200 '{ "message": "Endpoint for testing purpouse" }';
}
}
server {
listen 443 ssl;
# server_name capifcore;
# server_name openshift.evolved-5g.eu;
ssl_certificate /etc/nginx/certs/server.crt;
ssl_certificate_key /etc/nginx/certs/server.key;
ssl_client_certificate /etc/nginx/certs/ca.crt;
ssl_verify_client optional;
ssl_verify_depth 2;
location / {
proxy_pass $scheme://$http_host/api-invoker-management/v1/ui/;
}
location /api-invoker-management {
if ( $invoker_error_message != SUCCESS ) {
add_header Content-Type 'application/problem+json';
return 401 $invoker_error_message;
}
proxy_set_header X-SSL-Client-Cert $ssl_client_cert;
proxy_pass http://api-invoker-management:8080;
}
location /api-provider-management {
if ( $provider_error_message != SUCCESS ) {
add_header Content-Type 'application/problem+json';
return 401 $provider_error_message;
}
proxy_set_header X-SSL-Client-Cert $ssl_client_cert;
proxy_pass http://api-provider-management:8080;
}
location /service-apis {
if ($ssl_client_verify != SUCCESS) {
return 403;
}
if ( $discover_error_message != SUCCESS ) {
add_header Content-Type 'application/problem+json';
return 401 $discover_error_message;
}
proxy_set_header X-SSL-Client-Cert $ssl_client_cert;
proxy_pass http://service-apis:8080;
}
location /published-apis {
if ($ssl_client_verify != SUCCESS) {
return 403;
}
if ( $publish_error_message != SUCCESS ) {
add_header Content-Type 'application/problem+json';
return 401 $publish_error_message;
}
proxy_set_header X-SSL-Client-Cert $ssl_client_cert;
proxy_pass http://published-apis:8080;
}
location /api-invocation-logs {
if ($ssl_client_verify != SUCCESS) {
return 403;
}
proxy_set_header X-SSL-Client-Cert $ssl_client_cert;
proxy_pass http://api-invocation-logs:8080;
}
location /logs {
if ($ssl_client_verify != SUCCESS) {
return 403;
}
proxy_set_header X-SSL-Client-Cert $ssl_client_cert;
proxy_pass http://logs:8080;
}
location /capif-security {
if ($ssl_client_verify != SUCCESS) {
return 403;
}
if ( $security_error_message != SUCCESS ) {
add_header Content-Type 'application/problem+json';
return 401 $security_error_message;
}
proxy_set_header X-SSL-Client-Cert $ssl_client_cert;
proxy_pass http://capif-security:8080;
}
location /capif-events {
if ($ssl_client_verify != SUCCESS) {
return 403;
}
if ( $events_error_message != SUCCESS ) {
add_header Content-Type 'application/problem+json';
return 401 $events_error_message;
}
proxy_set_header X-SSL-Client-Cert $ssl_client_cert;
proxy_pass http://capif-events:8080;
}
location /access-control-policy {
if ( $acl_error_message != SUCCESS ) {
add_header Content-Type 'application/problem+json';
return 401 $acl_error_message;
}
proxy_set_header X-SSL-Client-Cert $ssl_client_cert;
proxy_pass http://access-control-policy:8080;
}
location /helper {
if ( $helper_error_message != SUCCESS ) {
add_header Content-Type 'application/problem+json';
return 401 $helper_error_message;
}
proxy_set_header X-SSL-Client-Cert $ssl_client_cert;
proxy_pass http://helper:8080;
}