Skip to content

Commit a1f5db8

Browse files
authored
Verify tls option (#71)
* add possibility in config to deactivate certificate verification (both GN and GS)
1 parent 6e8581c commit a1f5db8

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ The logics for credentials is by decreasing order of importance:
107107
4. Then constant login/password keys are read
108108
5. If still either "login" or "password" is not defined, the credentials are considered invalid and anonymous acces is used for the instance without authentication
109109

110+
__Nota__:
111+
112+
At each level where login/password are specified, one can add the option `verify: false` to deactivate verification of HTTPS certificates. By default the HTTPS certificate must be valid, which is equivalent to `verify: true`
113+
110114

111115
#### Example
112116

@@ -122,6 +126,7 @@ sources:
122126
- name: "b"
123127
login: "B"
124128
password: "${PASSWORD_B}"
129+
verify: false
125130
- name: "c"
126131
login: "C"
127132
```

backend/maelstro/config/config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ def get_access_info(
116116
{
117117
"auth": Credentials(gn.get("login"), gn.get("password")),
118118
"url": gn["api_url"],
119+
"verifytls": gn.get("verify", True),
119120
}
120121
for gn in self.config["sources"]["geonetwork_instances"]
121122
if gn["name"] == instance_id
@@ -125,6 +126,7 @@ def get_access_info(
125126
{
126127
"auth": Credentials(gs.get("login"), gs.get("password")),
127128
"url": gs["url"],
129+
"verifytls": gs.get("verify", True),
128130
}
129131
for gs in self.config["sources"]["geoserver_instances"]
130132
if gs["url"] == instance_id
@@ -155,6 +157,7 @@ def get_access_info(
155157
info = {
156158
"auth": Credentials(instance.get("login"), instance.get("password")),
157159
"url": instance[url_key],
160+
"verifytls": instance.get("verify", True),
158161
}
159162

160163
if (info["auth"].login is None) or (info["auth"].password is None):

backend/maelstro/core/georchestra.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def __init__(self, log_handler: LogCollectionHandler) -> None:
1717

1818
def get_gn_service(self, instance_name: str, is_source: bool) -> GnApi:
1919
gn_info = self.get_service_info(instance_name, is_source, True)
20-
return GnApi(gn_info["url"], gn_info["auth"])
20+
return GnApi(gn_info["url"], gn_info["auth"], gn_info["verifytls"])
2121

2222
def get_gs_service(self, instance_name: str, is_source: bool) -> RestService:
2323
gs_info = self.get_service_info(instance_name, is_source, False)

backend/tests/test_config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,18 +112,22 @@ def test_get_info():
112112
assert conf.get_access_info(True, True, "GeonetworkMaster") == {
113113
"auth": Credentials("demo", "demo"),
114114
"url": "https://demo.georchestra.org/geonetwork/srv/api",
115+
"verifytls": True,
115116
}
116117
assert conf.get_access_info(True, False, "https://mastergs.rennesmetropole.fr/geoserver-geofence/") == {
117118
"auth": Credentials("toto6", "Str0ng_passW0rd"),
118119
"url": "https://mastergs.rennesmetropole.fr/geoserver-geofence/",
120+
"verifytls": True,
119121
}
120122
assert conf.get_access_info(False, True, "PlateformeProfessionnelle") == {
121123
"auth": Credentials("toto", "passW0rd"),
122124
"url": "https://portail.sig.rennesmetropole.fr/geonetwork/srv/api",
125+
"verifytls": True,
123126
}
124127
assert conf.get_access_info(False, False, "CompoLocale") == {
125128
"auth": None,
126129
"url": "https://georchestra-127-0-0-1.nip.io/geoserver",
130+
"verifytls": True,
127131
}
128132
with pytest.raises(ConfigError) as err:
129133
conf.get_access_info(False, False, "MissingKey")

0 commit comments

Comments
 (0)