Skip to content
This repository has been archived by the owner on May 31, 2023. It is now read-only.

Failed to load LDAP config file when using Jinja templated integer variable #175

Closed
xpacm opened this issue Sep 6, 2019 · 3 comments · Fixed by #180
Closed

Failed to load LDAP config file when using Jinja templated integer variable #175

xpacm opened this issue Sep 6, 2019 · 3 comments · Fixed by #180

Comments

@xpacm
Copy link
Contributor

xpacm commented Sep 6, 2019

When a Jinja templated variable is used as LDAP port value like this:

grafana_ldap:
  servers:
    host: "{{ ldap_server_name }}"
    port: "{{ ports.ldap }}"

this is parsed as a string in ldap.toml, resulting in the following error:

t=2019-09-06T14:26:47+0200 lvl=eror msg="Error while trying to authenticate user" logger=context userId=0 orgId=0 uname= error="Failed to get LDAP config: Failed to load LDAP config file: toml: cannot load TOML value of type string into a Go integer"

Possible solution:

in ldap.toml.j2

{% for k,v in grafana_ldap.servers.items() if k != 'attributes' %}
{%   if k == 'port' %}
{{ k }} = {{ v | int }}
{%   elif v in [True, False] %}
{{ k }} = {{ 'true' if v else 'false' }}
{%   else %}
{{ k }} = {{ v | to_nice_json }}
{%   endif %}
{% endfor %}
@stale
Copy link

stale bot commented Oct 21, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Oct 21, 2019
@paulfantom
Copy link
Member

Sorry, this flew under the radar. Your fix seems good and I included it in #180.

@stale stale bot removed the wontfix This will not be worked on label Oct 21, 2019
@lock
Copy link

lock bot commented Nov 30, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Nov 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants