From a3e50f563e87d51db3b87cb57da95e0af3479149 Mon Sep 17 00:00:00 2001
From: Joe Bowman <joe@chorus.one>
Date: Fri, 21 Dec 2018 09:45:36 +0000
Subject: [PATCH] add ability to specify postgresql and mysql based sessions

---
 grafana/files/grafana.ini | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/grafana/files/grafana.ini b/grafana/files/grafana.ini
index 6866229..b8517c0 100644
--- a/grafana/files/grafana.ini
+++ b/grafana/files/grafana.ini
@@ -83,16 +83,20 @@ provider = {{ server.session.engine }}
 # postgres: user=a password=b host=localhost port=5432 dbname=c sslmode=disable
 {%- if server.session.engine == 'redis' %}
 provider_config = addr={{ server.session.get('host', '127.0.0.1') }}:{{ server.session.get('port', 6379) }},db={{ server.session.get('db', 'grafana') }}
+{%- elif server.session.engine == 'postgres' %}
+provider_config = user={{ server.session.get('user') }} password={{ server.session.get('password') }} host={{ server.session.get('host', '127.0.0.1') }} port={{ server.session.get('port', 5432) }} dbname={{ server.session.get('db', 'grafana') }} sslmode={{ server.session.get('sslmode', 'disable') }}
+{%- elif server.session.engine == 'mysql' %}
+provider_config = {{ server.session.get('user') }}:{{ server.session.get('password') }}@tcp({{ server.session.get('host', '127.0.0.1') }}:{{ server.session.get('port', '3306') }})/{{ server.session.get('db', 'grafana') }}
 {%- endif %}
 
 # Session cookie name
-;cookie_name = grafana_sess
+cookie_name = {{ server.session.get('cookie_name', 'grafana_sess') }}
 
 # If you use session in https only, default is false
-;cookie_secure = false
+cookie_secure = {{ server.session.get('cookie_https_only', 'false') }}
 
 # Session life time, default is 86400
-;session_life_time = 86400
+session_life_time = {{ server.session.get('ttl', 86400) }}
 
 #################################### Analytics ####################################
 [analytics]