Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
a6bd2c73
Commit
a6bd2c73
authored
Feb 01, 2019
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
introduce samesite setting for login cookie
ref #15067
parent
68ae17e4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
0 deletions
+23
-0
conf/defaults.ini
+3
-0
conf/sample.ini
+3
-0
pkg/services/auth/auth_token.go
+1
-0
pkg/setting/setting.go
+16
-0
No files found.
conf/defaults.ini
View file @
a6bd2c73
...
...
@@ -113,6 +113,9 @@ cache_mode = private
# Login cookie name
cookie_name
=
grafana_session
# Login cookie same site setting. defaults to `lax`. can be set to "lax", "strict" and "none"
cookie_samesite
=
lax
# How many days an session can be unused before we inactivate it
login_remember_days
=
7
...
...
conf/sample.ini
View file @
a6bd2c73
...
...
@@ -109,6 +109,9 @@ log_queries =
# Login cookie name
;cookie_name = grafana_session
# Login cookie same site setting. defaults to `lax`. can be set to "lax", "strict" and "none"
;cookie_samesite = lax
# How many days an session can be unused before we inactivate it
;login_remember_days = 7
...
...
pkg/services/auth/auth_token.go
View file @
a6bd2c73
...
...
@@ -96,6 +96,7 @@ func (s *UserAuthTokenServiceImpl) writeSessionCookie(ctx *models.ReqContext, va
Path
:
setting
.
AppSubUrl
+
"/"
,
Secure
:
s
.
Cfg
.
SecurityHTTPSCookies
,
MaxAge
:
maxAge
,
SameSite
:
s
.
Cfg
.
LoginCookieSameSite
,
}
http
.
SetCookie
(
ctx
.
Resp
,
&
cookie
)
...
...
pkg/setting/setting.go
View file @
a6bd2c73
...
...
@@ -6,6 +6,7 @@ package setting
import
(
"bytes"
"fmt"
"net/http"
"net/url"
"os"
"path"
...
...
@@ -227,6 +228,7 @@ type Cfg struct {
LoginCookieMaxDays
int
LoginCookieRotation
int
LoginDeleteExpiredTokensAfterDays
int
LoginCookieSameSite
http
.
SameSite
SecurityHTTPSCookies
bool
}
...
...
@@ -557,6 +559,20 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error {
cfg
.
LoginCookieName
=
login
.
Key
(
"cookie_name"
)
.
MustString
(
"grafana_session"
)
cfg
.
LoginCookieMaxDays
=
login
.
Key
(
"login_remember_days"
)
.
MustInt
(
7
)
cfg
.
LoginDeleteExpiredTokensAfterDays
=
login
.
Key
(
"delete_expired_token_after_days"
)
.
MustInt
(
30
)
samesiteString
:=
login
.
Key
(
"cookie_samesite"
)
.
MustString
(
"lax"
)
validSameSiteValues
:=
map
[
string
]
http
.
SameSite
{
"lax"
:
http
.
SameSiteLaxMode
,
"strict"
:
http
.
SameSiteStrictMode
,
"none"
:
http
.
SameSiteDefaultMode
,
}
if
samesite
,
ok
:=
validSameSiteValues
[
samesiteString
];
ok
{
cfg
.
LoginCookieSameSite
=
samesite
}
else
{
cfg
.
LoginCookieSameSite
=
http
.
SameSiteLaxMode
}
cfg
.
LoginCookieRotation
=
login
.
Key
(
"rotate_token_minutes"
)
.
MustInt
(
10
)
if
cfg
.
LoginCookieRotation
<
2
{
cfg
.
LoginCookieRotation
=
2
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment