Skip to content

Commit 9aefb50

Browse files
committed
mgr/cephadm: harmonize mgmt-gateway and oauth2-proxy spec fields
Let's rename the spec fields for mgmt-gateway and oauth2-proxy from ssl_certificate to ssl_cert, and from ssl_certificate_key to ssl_key, to align with the naming conventions used by other Cephadm services such as iscsi and ingress. Fixes: https://tracker.ceph.com/issues/70359 Signed-off-by: Redouane Kachach <[email protected]>
1 parent 8ad480d commit 9aefb50

File tree

8 files changed

+38
-37
lines changed

8 files changed

+38
-37
lines changed

doc/cephadm/services/mgmt-gateway.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ A ``mgmt-gateway`` service can be applied using a specification. An example in Y
128128
- ceph0
129129
spec:
130130
port: 5000
131+
ssl: True
131132
ssl_protocols:
132133
- TLSv1.2
133134
- TLSv1.3
@@ -136,13 +137,13 @@ A ``mgmt-gateway`` service can be applied using a specification. An example in Y
136137
- AES128-SHA
137138
- AES256-SHA
138139
- ...
139-
ssl_certificate: |
140+
ssl_cert: |
140141
-----BEGIN CERTIFICATE-----
141142
MIIDtTCCAp2gAwIBAgIYMC4xNzc1NDQxNjEzMzc2MjMyXzxvQ7EcMA0GCSqGSIb3
142143
DQEBCwUAMG0xCzAJBgNVBAYTAlVTMQ0wCwYDVQQIDARVdGFoMRcwFQYDVQQHDA5T
143144
[...]
144145
-----END CERTIFICATE-----
145-
ssl_certificate_key: |
146+
ssl_key: |
146147
-----BEGIN PRIVATE KEY-----
147148
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC5jdYbjtNTAKW4
148149
/CwQr/7wOiLGzVxChn3mmCIF3DwbL/qvTFTX2d8bDf6LjGwLYloXHscRfxszX/4h

src/pybind/mgr/cephadm/module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ def _get_mgmt_gw_endpoint(self, is_internal: bool) -> Optional[str]:
751751
endpoint_suffix = '/internal'
752752
else:
753753
mgmt_gw_port = dd.ports[0] if dd.ports else None
754-
protocol = 'http' if mgmt_gw_spec.disable_https else 'https'
754+
protocol = 'https' if mgmt_gw_spec.ssl else 'http'
755755
endpoint_suffix = ''
756756

757757
mgmt_gw_endpoint = build_url(scheme=protocol, host=mgmt_gw_addr, port=mgmt_gw_port)

src/pybind/mgr/cephadm/services/mgmt_gateway.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ def get_external_certificates(self, svc_spec: MgmtGatewaySpec, daemon_spec: Ceph
5757
user_made = False
5858
if not (cert and key):
5959
# not available on store, check if provided on the spec
60-
if svc_spec.ssl_certificate and svc_spec.ssl_certificate_key:
60+
if svc_spec.ssl_cert and svc_spec.ssl_key:
6161
user_made = True
62-
cert = svc_spec.ssl_certificate
63-
key = svc_spec.ssl_certificate_key
62+
cert = svc_spec.ssl_cert
63+
key = svc_spec.ssl_key
6464
else:
6565
# not provided on the spec, let's generate self-sigend certificates
6666
ip = self.get_mgmt_gw_ip(svc_spec, daemon_spec)
@@ -147,7 +147,6 @@ def generate_config(self, daemon_spec: CephadmDaemonDeploySpec) -> Tuple[Dict[st
147147
'enable_oauth2_proxy': bool(oauth2_proxy_endpoints),
148148
}
149149

150-
cert, key = self.get_external_certificates(svc_spec, daemon_spec)
151150
internal_cert, internal_pkey = self.get_internal_certificates(svc_spec, daemon_spec)
152151
daemon_config = {
153152
"files": {
@@ -159,7 +158,8 @@ def generate_config(self, daemon_spec: CephadmDaemonDeploySpec) -> Tuple[Dict[st
159158
"ca.crt": self.mgr.cert_mgr.get_root_ca()
160159
}
161160
}
162-
if not svc_spec.disable_https:
161+
if svc_spec.ssl:
162+
cert, key = self.get_external_certificates(svc_spec, daemon_spec)
163163
daemon_config["files"]["nginx.crt"] = cert
164164
daemon_config["files"]["nginx.key"] = key
165165

src/pybind/mgr/cephadm/services/oauth2_proxy.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ def get_certificates(self, svc_spec: OAuth2ProxySpec, daemon_spec: CephadmDaemon
4848
user_made = False
4949
if not (cert and key):
5050
# not available on store, check if provided on the spec
51-
if svc_spec.ssl_certificate and svc_spec.ssl_certificate_key:
51+
if svc_spec.ssl_cert and svc_spec.ssl_key:
5252
user_made = True
53-
cert = svc_spec.ssl_certificate
54-
key = svc_spec.ssl_certificate_key
53+
cert = svc_spec.ssl_cert
54+
key = svc_spec.ssl_key
5555
else:
5656
# not provided on the spec, let's generate self-sigend certificates
5757
addr = self.mgr.inventory.get_addr(daemon_spec.host)

src/pybind/mgr/cephadm/templates/services/mgmt-gateway/external_server.conf.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
server {
3-
{% if spec.disable_https %}
3+
{% if not spec.ssl %}
44
listen {{ spec.port or 80 }};
55
{% else %}
66
listen {{ spec.port or 443 }} ssl;

src/pybind/mgr/cephadm/tests/test_services.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,8 +1588,8 @@ def inline_certificate(multi_line_cert):
15881588
client_secret='my_client_secret',
15891589
oidc_issuer_url='http://192.168.10.10:8888/dex',
15901590
cookie_secret='kbAEM9opAmuHskQvt0AW8oeJRaOM2BYy5Loba0kZ0SQ=',
1591-
ssl_certificate=ceph_generated_cert,
1592-
ssl_certificate_key=ceph_generated_key)
1591+
ssl_cert=ceph_generated_cert,
1592+
ssl_key=ceph_generated_key)
15931593

15941594
with with_host(cephadm_module, "test"):
15951595
cephadm_module.cert_mgr.save_cert('grafana_cert', ceph_generated_cert, host='test')
@@ -4005,8 +4005,8 @@ def get_services_endpoints(name):
40054005

40064006
server_port = 5555
40074007
spec = MgmtGatewaySpec(port=server_port,
4008-
ssl_certificate=ceph_generated_cert,
4009-
ssl_certificate_key=ceph_generated_key)
4008+
ssl_cert=ceph_generated_cert,
4009+
ssl_key=ceph_generated_key)
40104010

40114011
expected = {
40124012
"fsid": "fsid",
@@ -4253,8 +4253,8 @@ def get_services_endpoints(name):
42534253

42544254
server_port = 5555
42554255
spec = MgmtGatewaySpec(port=server_port,
4256-
ssl_certificate=ceph_generated_cert,
4257-
ssl_certificate_key=ceph_generated_key,
4256+
ssl_cert=ceph_generated_cert,
4257+
ssl_key=ceph_generated_key,
42584258
enable_auth=True)
42594259

42604260
expected = {
@@ -4603,8 +4603,8 @@ def get_services_endpoints(name):
46034603

46044604
server_port = 5555
46054605
mgmt_gw_spec = MgmtGatewaySpec(port=server_port,
4606-
ssl_certificate=ceph_generated_cert,
4607-
ssl_certificate_key=ceph_generated_key,
4606+
ssl_cert=ceph_generated_cert,
4607+
ssl_key=ceph_generated_key,
46084608
enable_auth=True,
46094609
virtual_ip=virtual_ip)
46104610

@@ -4614,8 +4614,8 @@ def get_services_endpoints(name):
46144614
client_secret='my_client_secret',
46154615
oidc_issuer_url='http://192.168.10.10:8888/dex',
46164616
cookie_secret='kbAEM9opAmuHskQvt0AW8oeJRaOM2BYy5Loba0kZ0SQ=',
4617-
ssl_certificate=ceph_generated_cert,
4618-
ssl_certificate_key=ceph_generated_key,
4617+
ssl_cert=ceph_generated_cert,
4618+
ssl_key=ceph_generated_key,
46194619
allowlist_domains=[allowed_domain])
46204620

46214621
whitelist_domains = f"{allowed_domain},1::4,ceph-node" if virtual_ip is None else f"{allowed_domain},{virtual_ip},1::4,ceph-node"

src/pybind/mgr/orchestrator/module.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2048,7 +2048,7 @@ def _apply_iscsi(self,
20482048
@_cli_write_command('orch apply mgmt-gateway')
20492049
def _apply_mgmt_gateway(self,
20502050
port: Optional[int] = None,
2051-
disable_https: Optional[bool] = False,
2051+
ssl: Optional[bool] = True,
20522052
enable_auth: Optional[bool] = False,
20532053
virtual_ip: Optional[str] = None,
20542054
placement: Optional[str] = None,
@@ -2066,7 +2066,7 @@ def _apply_mgmt_gateway(self,
20662066
unmanaged=unmanaged,
20672067
port=port,
20682068
virtual_ip=virtual_ip,
2069-
disable_https=disable_https,
2069+
ssl=ssl,
20702070
enable_auth=enable_auth,
20712071
preview_only=dry_run
20722072
)

src/python-common/ceph/deployment/service_spec.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,11 +1853,11 @@ def __init__(self,
18531853
config: Optional[Dict[str, str]] = None,
18541854
networks: Optional[List[str]] = None,
18551855
placement: Optional[PlacementSpec] = None,
1856-
disable_https: Optional[bool] = False,
1856+
ssl: Optional[bool] = True,
18571857
enable_auth: Optional[bool] = False,
18581858
port: Optional[int] = None,
1859-
ssl_certificate: Optional[str] = None,
1860-
ssl_certificate_key: Optional[str] = None,
1859+
ssl_cert: Optional[str] = None,
1860+
ssl_key: Optional[str] = None,
18611861
ssl_prefer_server_ciphers: Optional[str] = None,
18621862
ssl_session_tickets: Optional[str] = None,
18631863
ssl_session_timeout: Optional[str] = None,
@@ -1886,16 +1886,16 @@ def __init__(self,
18861886
extra_entrypoint_args=extra_entrypoint_args,
18871887
custom_configs=custom_configs
18881888
)
1889-
#: Is a flag to disable HTTPS. If True, the server will use unsecure HTTP
1890-
self.disable_https = disable_https
1889+
#: Is a flag to enable/disable HTTPS. By default set to True.
1890+
self.ssl = ssl
18911891
#: Is a flag to enable SSO auth. Requires oauth2-proxy to be active for SSO authentication.
18921892
self.enable_auth = enable_auth
18931893
#: The port number on which the server will listen
18941894
self.port = port
18951895
#: A multi-line string that contains the SSL certificate
1896-
self.ssl_certificate = ssl_certificate
1896+
self.ssl_cert = ssl_cert
18971897
#: A multi-line string that contains the SSL key
1898-
self.ssl_certificate_key = ssl_certificate_key
1898+
self.ssl_key = ssl_key
18991899
#: Prefer server ciphers over client ciphers: on | off
19001900
self.ssl_prefer_server_ciphers = ssl_prefer_server_ciphers
19011901
#: A multioption flag to control session tickets: on | off
@@ -1927,8 +1927,8 @@ def get_port_start(self) -> List[int]:
19271927
def validate(self) -> None:
19281928
super(MgmtGatewaySpec, self).validate()
19291929
self._validate_port(self.port)
1930-
self._validate_certificate(self.ssl_certificate, "ssl_certificate")
1931-
self._validate_private_key(self.ssl_certificate_key, "ssl_certificate_key")
1930+
self._validate_certificate(self.ssl_cert, "ssl_cert")
1931+
self._validate_private_key(self.ssl_key, "ssl_key")
19321932
self._validate_boolean_switch(self.ssl_prefer_server_ciphers, "ssl_prefer_server_ciphers")
19331933
self._validate_boolean_switch(self.ssl_session_tickets, "ssl_session_tickets")
19341934
self._validate_session_timeout(self.ssl_session_timeout)
@@ -1997,8 +1997,8 @@ def __init__(self,
19971997
oidc_issuer_url: Optional[str] = None,
19981998
redirect_url: Optional[str] = None,
19991999
cookie_secret: Optional[str] = None,
2000-
ssl_certificate: Optional[str] = None,
2001-
ssl_certificate_key: Optional[str] = None,
2000+
ssl_cert: Optional[str] = None,
2001+
ssl_key: Optional[str] = None,
20022002
allowlist_domains: Optional[List[str]] = None,
20032003
unmanaged: bool = False,
20042004
extra_container_args: Optional[GeneralArgList] = None,
@@ -2032,9 +2032,9 @@ def __init__(self,
20322032
# 24, or 32 bytes to create an AES cipher.
20332033
self.cookie_secret = cookie_secret or self.generate_random_secret()
20342034
#: The multi-line SSL certificate for encrypting communications.
2035-
self.ssl_certificate = ssl_certificate
2035+
self.ssl_cert = ssl_cert
20362036
#: The multi-line SSL certificate private key for decrypting communications.
2037-
self.ssl_certificate_key = ssl_certificate_key
2037+
self.ssl_key = ssl_key
20382038
#: List of allowed domains for safe redirection after login or logout,
20392039
# preventing unauthorized redirects.
20402040
self.allowlist_domains = allowlist_domains

0 commit comments

Comments
 (0)