Skip to content

Commit

Permalink
feat: introduce tls_file_mapper
Browse files Browse the repository at this point in the history
  • Loading branch information
saurabh6790 committed Aug 20, 2024
1 parent 7a6f0b2 commit 926b82b
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 0 deletions.
7 changes: 7 additions & 0 deletions press/playbooks/roles/agent/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@
content: '{{ certificate_intermediate_chain }}'
dest: /home/frappe/agent/tls/chain.pem

- name: Setup TLS Mapper
become: yes
become_user: frappe
copy:
content: '{{ certificate_file_mapper }}'
dest: /home/frappe/agent/tls/tls_file_mapper.json

- name: Setup Agent NGINX
become: yes
become_user: frappe
Expand Down
1 change: 1 addition & 0 deletions press/press/doctype/analytics_server/analytics_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def _setup_server(self):
"certificate_private_key": certificate.private_key,
"certificate_full_chain": certificate.full_chain,
"certificate_intermediate_chain": certificate.intermediate_chain,
"certificate_file_mapper": certificate.tls_file_mapper,
},
)
play = ansible.run()
Expand Down
1 change: 1 addition & 0 deletions press/press/doctype/database_server/database_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ def _setup_server(self):
"certificate_private_key": config.certificate.private_key,
"certificate_full_chain": config.certificate.full_chain,
"certificate_intermediate_chain": config.certificate.intermediate_chain,
"certificate_file_mapper": config.certificate.tls_file_mapper,
},
)
play = ansible.run()
Expand Down
1 change: 1 addition & 0 deletions press/press/doctype/log_server/log_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def _setup_server(self):
"certificate_private_key": certificate.private_key,
"certificate_full_chain": certificate.full_chain,
"certificate_intermediate_chain": certificate.intermediate_chain,
"certificate_file_mapper": certificate.tls_file_mapper,
},
)
play = ansible.run()
Expand Down
1 change: 1 addition & 0 deletions press/press/doctype/monitor_server/monitor_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def _setup_server(self):
"certificate_private_key": certificate.private_key,
"certificate_full_chain": certificate.full_chain,
"certificate_intermediate_chain": certificate.intermediate_chain,
"certificate_file_mapper": certificate.tls_file_mapper,
},
)
play = ansible.run()
Expand Down
1 change: 1 addition & 0 deletions press/press/doctype/proxy_server/proxy_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ def _setup_server(self):
"certificate_private_key": certificate.private_key,
"certificate_full_chain": certificate.full_chain,
"certificate_intermediate_chain": certificate.intermediate_chain,
"certificate_file_mapper": certificate.tls_file_mapper,
"press_url": frappe.utils.get_url(),
},
)
Expand Down
1 change: 1 addition & 0 deletions press/press/doctype/registry_server/registry_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def _setup_server(self):
"certificate_private_key": certificate.private_key,
"certificate_full_chain": certificate.full_chain,
"certificate_intermediate_chain": certificate.intermediate_chain,
"certificate_file_mapper": certificate.tls_file_mapper,
},
)
play = ansible.run()
Expand Down
1 change: 1 addition & 0 deletions press/press/doctype/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1340,6 +1340,7 @@ def _setup_server(self):
"certificate_private_key": certificate.private_key,
"certificate_full_chain": certificate.full_chain,
"certificate_intermediate_chain": certificate.intermediate_chain,
"certificate_file_mapper": certificate.tls_file_mapper,
},
)
play = ansible.run()
Expand Down
18 changes: 18 additions & 0 deletions press/press/doctype/tls_certificate/tls_certificate.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,24 @@ def _trigger_callbacks(self):
self.trigger_server_tls_setup_callback()
self._update_secondary_wildcard_domains()

@property
def tls_file_mapper(self):
if self.intermediate_chain:
return """
{
"ssl_certificate": "fullchain.pem",
"ssl_certificate_key": "privkey.pem",
"ssl_trusted_certificate": "chain.pem"
}
"""
else:
return """
{
"ssl_certificate": "cert.pem",
"ssl_certificate_key": "privkey.pem"
}
"""


get_permission_query_conditions = get_permission_query_conditions_for_doctype(
"TLS Certificate"
Expand Down
1 change: 1 addition & 0 deletions press/press/doctype/trace_server/trace_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def _setup_server(self):
"certificate_private_key": certificate.private_key,
"certificate_full_chain": certificate.full_chain,
"certificate_intermediate_chain": certificate.intermediate_chain,
"certificate_file_mapper": certificate.tls_file_mapper,
},
)
play = ansible.run()
Expand Down

0 comments on commit 926b82b

Please sign in to comment.