Skip to content

Commit 7c39564

Browse files
4.2.4 (#45)
* 20240329-01 commit - changed return code to 412 if devportal service unreachable * 20240409-01 commit - mTLS fixes
1 parent 912854e commit 7c39564

File tree

6 files changed

+40
-33
lines changed

6 files changed

+40
-33
lines changed

FEATURES.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,16 @@ Client-side authentication profiles to be defined under `.declaration.http.authe
6767
"type": "mtls",
6868
"mtls": {
6969
"enabled": "<on|off|optional|optional_no_ca>",
70-
"client_certificates": "<CLIENT_CERTIFICATES_OBJECT_NAME>"
70+
"client_certificates": "<CLIENT_CERTIFICATES_OBJECT_NAME>",
71+
"ocsp": {
72+
"enabled": "on",
73+
"responder": "<OCSP_RESPONDER_URL>"
74+
},
75+
"stapling": {
76+
"enabled": true,
77+
"verify": true,
78+
"responder": "<OCSP_RESPONDER_URL>"
79+
}
7180
}
7281
}
7382
```

contrib/postman/NGINX Declarative API.postman_collection.json

Lines changed: 5 additions & 5 deletions
Large diffs are not rendered by default.

src/V4_2_CreateConfig.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ def createconfig(declaration: ConfigDeclaration, apiversion: str, runfromautosyn
393393
status, devPortalHTML = v4_2.DevPortal.createDevPortal(locationDeclaration = loc, authProfiles = d['declaration']['http']['authentication'])
394394

395395
if status != 200:
396-
return {"status_code": 400,
396+
return {"status_code": 412,
397397
"message": {"status_code": status, "message":
398398
{"code": status, "content": f"Developer Portal creation failed for {loc['uri']}"}}}
399399

src/V4_2_NginxConfigDeclaration.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ class Ocsp(BaseModel, extra="forbid"):
166166
class AuthClientMtls(BaseModel, extra="forbid"):
167167
enabled: Optional[str] = "off"
168168
client_certificates: str = ""
169+
ocsp: Optional[Ocsp] = {}
170+
stapling: Optional[OcspStapling] = {}
169171

170172
@model_validator(mode='after')
171173
def check_type(self) -> 'AuthClientMtls':
@@ -184,8 +186,6 @@ class Tls(BaseModel, extra="forbid"):
184186
trusted_ca_certificates: str = ""
185187
ciphers: Optional[str] = ""
186188
protocols: Optional[List[str]] = []
187-
ocsp: Optional[Ocsp] = {}
188-
stapling: Optional[OcspStapling] = {}
189189
authentication: Optional[LocationAuth] = {}
190190

191191

@@ -453,13 +453,13 @@ def check_type(self) -> 'NjsHookLocationDetails':
453453

454454
return self
455455

456+
456457
class NjsHookHttpServer(BaseModel, extra="forbid"):
457458
hook: NjsHookHttpServerDetails
458459
profile: str
459460
function: str
460461

461462

462-
463463
class NjsHookLocation(BaseModel, extra="forbid"):
464464
hook: NjsHookLocationDetails
465465
profile: str

templates/v4.2/authn/client/mtls.tmpl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,23 @@ ssl_verify_client {{ authprofile.mtls.enabled }};
33
{% if authprofile.mtls.client_certificates -%}
44
ssl_client_certificate {{ ncgconfig.nms.certs_dir }}/{{ authprofile.mtls.client_certificates }}.crt;
55
{% endif %}
6+
7+
{# --- OCSP section start --- #}
8+
{%- if authprofile.mtls.ocsp and authprofile.mtls.ocsp.enabled|lower != "off" -%}
9+
ssl_ocsp {{ authprofile.mtls.ocsp.enabled }};
10+
{% if authprofile.mtls.ocsp.responder -%}
11+
ssl_ocsp_responder {{ authprofile.mtls.ocsp.responder }};
12+
{% endif %}
13+
{% endif %}
14+
{# --- OCSP section end --- #}
15+
16+
{# --- TLS stapling section start --- #}
17+
{%- if authprofile.mtls.stapling and authprofile.mtls.stapling.enabled == True -%}
18+
ssl_stapling on;
19+
ssl_stapling_verify {% if authprofile.mtls.stapling.verify == True %}on{% else %}off{% endif %};
20+
{% if authprofile.mtls.stapling.responder -%}
21+
ssl_stapling_responder {{ authprofile.mtls.stapling.responder }};
22+
{% endif -%}
23+
{%- endif %}
24+
{# --- TLS stapling section end --- #}
625
{% endif %}

templates/v4.2/http.tmpl

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -143,26 +143,6 @@ server {
143143
include "{{ ncgconfig.nms.auth_client_dir }}/{{ s.listen.tls.authentication.client[0].profile | replace(" ", "_") }}.conf";
144144
{% endif %}
145145

146-
{# --- OCSP section start --- #}
147-
{%- if s.listen.tls.ocsp and s.listen.tls.ocsp.enabled|lower != "off" -%}
148-
ssl_ocsp {{ s.listen.tls.ocsp.enabled }};
149-
{% if s.listen.tls.ocsp.responder -%}
150-
ssl_ocsp_responder {{ s.listen.tls.ocsp.responder }};
151-
{% endif %}
152-
{% endif %}
153-
{# --- OCSP section end --- #}
154-
155-
{# --- TLS stapling section start --- #}
156-
{%- if s.listen.tls.stapling and s.listen.tls.stapling.enabled == True -%}
157-
ssl_stapling on;
158-
ssl_stapling_verify {% if s.listen.tls.stapling.verify == True %}on{% else %}off{% endif %};
159-
{% if s.listen.tls.stapling.responder -%}
160-
ssl_stapling_responder {{ s.listen.tls.stapling.responder }};
161-
162-
{% endif -%}
163-
{%- endif %}
164-
{# --- TLS stapling section end --- #}
165-
166146
{%- endif %}
167147
{# --- TLS section end --- #}
168148

@@ -418,12 +398,11 @@ server {
418398
{% endif %}
419399
{% endif %}
420400

421-
{# --- Location snippets --- #}
422-
423-
{% if loc.apigateway.api_gateway.enabled == True %}
401+
{% if loc.apigateway and loc.apigateway.api_gateway.enabled == True %}
424402
include "{{ ncgconfig.nms.apigw_dir }}{{ loc.uri }}.conf";
425403
{% endif %}
426404

405+
{# --- Location snippets --- #}
427406
{% if loc.snippet and loc.snippet.content %}{{ loc.snippet.content | b64decode }}{% endif %}
428407

429408
}

0 commit comments

Comments
 (0)