Skip to content

Commit 4b8e408

Browse files
Merge pull request #15 from minvws/bug/minor-fixes
Allow to override version_url and validate if env is allowed
2 parents 5b59595 + 3b50317 commit 4b8e408

4 files changed

Lines changed: 29 additions & 12 deletions

File tree

public/check_status.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
'ca' => $_ENV['MTLS_CA'] ?: null
2525
];
2626

27+
$env = $_ENV['SERVICES_ENVIRONMENT'] ?: null;
28+
2729
// Get requested Service
2830
if (!isset($_GET['service'])) {
2931
http_response_code(400);
@@ -38,6 +40,12 @@
3840
exit;
3941
}
4042

43+
if (isset($env) && $env !== $_GET['env']) {
44+
http_response_code(400);
45+
echo json_encode(['error' => 'Environment not allowed']);
46+
exit;
47+
}
48+
4149
$service = get_service(__DIR__ . '/../services.json', $_GET['service'], $_GET['env']);
4250
if (!$service) {
4351
http_response_code(400);

public/check_version.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
'key' => $_ENV['MTLS_KEY'] ?: null,
2323
'ca' => $_ENV['MTLS_CA'] ?: null
2424
];
25+
$env = $_ENV['SERVICES_ENVIRONMENT'] ?: null;
2526

2627
// Get requested Service
2728
if (!isset($_GET['service'])) {
@@ -37,6 +38,12 @@
3738
exit;
3839
}
3940

41+
if (isset($env) && $env !== $_GET['env']) {
42+
http_response_code(400);
43+
echo json_encode(['error' => 'Environment not allowed']);
44+
exit;
45+
}
46+
4047
$service = get_service(__DIR__ . '/../services.json', $_GET['service'], $_GET['env']);
4148
if (!$service) {
4249
http_response_code(400);
@@ -45,7 +52,8 @@
4552
}
4653

4754
// Check cache
48-
$cacheKey = sha1($service['url']);
55+
$versionUrl = $service['version_url'] ?? $service['url'];
56+
$cacheKey = sha1($versionUrl);
4957
$cachedItem = $cache->getItem($cacheKey);
5058

5159
if ($cachedItem->isHit()) {
@@ -105,11 +113,11 @@ function fetch_version_info(array $service, array $mtls) {
105113
]);
106114
try {
107115
if(strcmp($service['type'], "HAPI") == 0){
108-
$response = $client->get($service['url'] . '/fhir/metadata');
116+
$response = $client->get($service['version_url'] ?? $service['url'] . '/fhir/metadata');
109117
$json = $response->getBody()->getContents();
110118
return json_decode($json, true)['software'];
111119
} else {
112-
$response = $client->get($service['url'] . '/version.json');
120+
$response = $client->get($service['version_url'] ?? $service['url'] . '/version.json');
113121
$json = $response->getBody()->getContents();
114122
return json_decode($json, true);
115123
}

services.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,24 @@
2222
"name": "Adresseringsdienst",
2323
"url": "https://adressering.test.gf.irealisatie.nl",
2424
"type": "HAPI",
25-
"has_version": false,
25+
"has_version": true,
2626
"description": "The Addressing Service manages the translation between healthcare providers and the endpoints where the metadata can be retrieved."
2727
},
2828
{
2929
"name": "Max (inge6)",
3030
"url": "https://emax.test.gf.irealisatie.nl",
31+
"version_url": "https://emax.test.gf.irealisatie.nl/static/version.json",
3132
"type": "Python",
3233
"github": "minvws/nl-rdo-max-private",
33-
"has_version": false,
34+
"has_version": true,
3435
"description": "This is the login service, this will provide eHerkenning SAML to OIDC bridge."
3536
},
3637
{
3738
"name": "Documentation",
3839
"url": "https://fdocs.test.gf.irealisatie.nl",
3940
"github": "minvws/gfmodules-functional-documentation",
4041
"type": "Sphinx",
41-
"has_version": false,
42+
"has_version": true,
4243
"description": "This is the documentation for the functional aspects of the system."
4344
},
4445
{
@@ -52,21 +53,21 @@
5253
"name": "LMR Noord",
5354
"url": "https://lmr-noord.test.gf.irealisatie.nl",
5455
"type": "HAPI",
55-
"has_version": false,
56+
"has_version": true,
5657
"description": "HAPI Storage system for LMR Noord."
5758
},
5859
{
5960
"name": "LMR Oost",
6061
"url": "https://lmr-oost.test.gf.irealisatie.nl",
6162
"type": "HAPI",
62-
"has_version": false,
63+
"has_version": true,
6364
"description": "HAPI Storage system for LMR Oost."
6465
},
6566
{
6667
"name": "LMR Zuid",
6768
"url": "https://lmr-zuid.test.gf.irealisatie.nl",
6869
"type": "HAPI",
69-
"has_version": false,
70+
"has_version": true,
7071
"description": "HAPI Storage system for LMR Zuid."
7172
},
7273
{
@@ -95,7 +96,7 @@
9596
"name": "MCSD Registratie Portaal",
9697
"url": "https://mcsd-registratie-portaal.test.gf.irealisatie.nl",
9798
"github": "",
98-
"type": "Python",
99+
"type": "PHP",
99100
"has_version": true
100101
},
101102
{
@@ -109,7 +110,7 @@
109110
"name": "National Referral Index",
110111
"url": "https://nvi.test.gf.irealisatie.nl",
111112
"github": "minvws/gfmodules-national-referral-index",
112-
"type": "PHP",
113+
"type": "Python",
113114
"has_version": true
114115
},
115116
{

templates/index.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
<tr>
137137
<td>{{ service.name }}<br><small>{{ service.description }}</small></td>
138138
<td>{{ service.type|default('') }}</td>
139-
<td><a href="{{ service.external_url }}" target="_blank">{{ service.external_url ?? service.url }}</a></td>
139+
<td><a href="{{ service.external_url ?? service.url }}" target="_blank">{{ service.external_url ?? service.url }}</a></td>
140140
<td class="status" data-status-service="{{ service.name }}" data-status-env="{{ env }}">Loading…</td>
141141
<td class="version">
142142
{% if service.has_version %}

0 commit comments

Comments
 (0)