# Cosmian KMS Configuration File
# Generated by provisioning system

[server]
port = {{ kms.port }}
bind_addr = "{{ kms.bind_addr }}"

{% if kms.tls_enabled %}
[tls]
cert_file = "{{ kms.cert_file }}"
key_file = "{{ kms.key_file }}"
{% if kms.ca_cert_file is defined %}
ca_cert_file = "{{ kms.ca_cert_file }}"
{% endif %}
{% endif %}

[database]
{% if kms.database.typ == "sqlite" %}
database_type = "sqlite"
database_path = "{{ kms.database.path }}"
{% elif kms.database.typ == "mysql" %}
database_type = "mysql"
database_url = "mysql://{{ kms.database.username }}:{{ kms.database.password }}@{{ kms.database.host }}:{{ kms.database.port }}/{{ kms.database.database }}"
{% elif kms.database.typ == "postgresql" %}
database_type = "postgresql" 
database_url = "postgresql://{{ kms.database.username }}:{{ kms.database.password }}@{{ kms.database.host }}:{{ kms.database.port }}/{{ kms.database.database }}"
{% elif kms.database.typ == "redis" %}
database_type = "redis-findex"
database_url = "redis://{{ kms.database.host }}:{{ kms.database.port }}"
{% if kms.database.password %}
redis_master_password = "{{ kms.database.password }}"
{% endif %}
{% endif %}

{% if kms.auth.enabled %}
[auth]
jwt_issuer_uri = "{{ kms.auth.jwt_issuer_uri }}"
{% if kms.auth.jwks_uri is defined %}
jwks_uri = "{{ kms.auth.jwks_uri }}"
{% endif %}
{% if kms.auth.jwt_audience is defined %}
jwt_audience = "{{ kms.auth.jwt_audience }}"
{% endif %}
{% endif %}

[logging]
level = "{{ kms.log_level }}"