Commit 64124b50 by bergquist

add setting for how to long we should keep expired tokens

parent d3ec8e1c
...@@ -110,18 +110,21 @@ cache_mode = private ...@@ -110,18 +110,21 @@ cache_mode = private
[login] [login]
# login cookie name # Login cookie name
cookie_name = grafana_session cookie_name = grafana_session
# If you want login cookies to be https only. default is false # If you want login cookies to be https only. default is false
cookie_secure = false cookie_secure = false
# logged in user name # Logged in user name
cookie_username = grafana_user cookie_username = grafana_user
# how many days an session can be unused before we inactivate it # How many days an session can be unused before we inactivate it
login_remember_days = 7 login_remember_days = 7
# How long should Grafana keep expired tokens before deleting them
delete_expired_token_after_days = 30
#################################### Session ############################# #################################### Session #############################
[session] [session]
# Either "memory", "file", "redis", "mysql", "postgres", "memcache", default is "file" # Either "memory", "file", "redis", "mysql", "postgres", "memcache", default is "file"
......
...@@ -7,7 +7,7 @@ import ( ...@@ -7,7 +7,7 @@ import (
func (srv *UserAuthTokenServiceImpl) Run(ctx context.Context) error { func (srv *UserAuthTokenServiceImpl) Run(ctx context.Context) error {
ticker := time.NewTicker(time.Hour * 12) ticker := time.NewTicker(time.Hour * 12)
deleteSessionAfter := time.Hour * 24 * 7 * 30 deleteSessionAfter := time.Hour * 24 * time.Duration(srv.Cfg.LoginDeleteExpiredTokensAfterDays)
for { for {
select { select {
......
...@@ -228,6 +228,7 @@ type Cfg struct { ...@@ -228,6 +228,7 @@ type Cfg struct {
LoginCookieUsername string LoginCookieUsername string
LoginCookieSecure bool LoginCookieSecure bool
LoginCookieMaxDays int LoginCookieMaxDays int
LoginDeleteExpiredTokensAfterDays int
} }
type CommandLineArgs struct { type CommandLineArgs struct {
...@@ -553,10 +554,11 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error { ...@@ -553,10 +554,11 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error {
//login //login
login := iniFile.Section("login") login := iniFile.Section("login")
cfg.LoginCookieName = login.Key("cookie_name").String() cfg.LoginCookieName = login.Key("cookie_name").MustString("grafana_session")
cfg.LoginCookieMaxDays = login.Key("login_remember_days").MustInt() cfg.LoginCookieMaxDays = login.Key("login_remember_days").MustInt(7)
cfg.LoginCookieSecure = login.Key("cookie_secure").MustBool(false) cfg.LoginCookieSecure = login.Key("cookie_secure").MustBool(false)
cfg.LoginCookieUsername = login.Key("cookie_username").String() cfg.LoginCookieUsername = login.Key("cookie_username").MustString("grafana_username")
cfg.LoginDeleteExpiredTokensAfterDays = login.Key("delete_expired_token_after_days").MustInt(30)
Env = iniFile.Section("").Key("app_mode").MustString("development") Env = iniFile.Section("").Key("app_mode").MustString("development")
InstanceName = iniFile.Section("").Key("instance_name").MustString("unknown_instance_name") InstanceName = iniFile.Section("").Key("instance_name").MustString("unknown_instance_name")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment