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
03ac9c52
Unverified
Commit
03ac9c52
authored
Nov 19, 2018
by
Carl Bergquist
Committed by
GitHub
Nov 19, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12029 from Nick-Triller/11893_oauth_auto_login
11893 oauth auto login
parents
435079c6
3414be18
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
1 deletions
+36
-1
docs/sources/auth/overview.md
+12
-1
pkg/api/login.go
+22
-0
pkg/setting/setting.go
+2
-0
No files found.
docs/sources/auth/overview.md
View file @
03ac9c52
...
@@ -73,7 +73,18 @@ You can hide the Grafana login form using the below configuration settings.
...
@@ -73,7 +73,18 @@ You can hide the Grafana login form using the below configuration settings.
```
bash
```
bash
[
auth]
[
auth]
disable_login_form ⁼
true
disable_login_form
=
true
```
### Automatic OAuth login
Set to true to attempt login with OAuth automatically, skipping the login screen.
This setting is ignored if multiple OAuth providers are configured.
Defaults to
`false`
.
```
bash
[
auth]
oauth_auto_login
=
true
```
```
### Hide sign-out menu
### Hide sign-out menu
...
...
pkg/api/login.go
View file @
03ac9c52
...
@@ -39,6 +39,10 @@ func (hs *HTTPServer) LoginView(c *m.ReqContext) {
...
@@ -39,6 +39,10 @@ func (hs *HTTPServer) LoginView(c *m.ReqContext) {
viewData
.
Settings
[
"loginError"
]
=
loginError
viewData
.
Settings
[
"loginError"
]
=
loginError
}
}
if
tryOAuthAutoLogin
(
c
)
{
return
}
if
!
tryLoginUsingRememberCookie
(
c
)
{
if
!
tryLoginUsingRememberCookie
(
c
)
{
c
.
HTML
(
200
,
ViewIndex
,
viewData
)
c
.
HTML
(
200
,
ViewIndex
,
viewData
)
return
return
...
@@ -53,6 +57,24 @@ func (hs *HTTPServer) LoginView(c *m.ReqContext) {
...
@@ -53,6 +57,24 @@ func (hs *HTTPServer) LoginView(c *m.ReqContext) {
c
.
Redirect
(
setting
.
AppSubUrl
+
"/"
)
c
.
Redirect
(
setting
.
AppSubUrl
+
"/"
)
}
}
func
tryOAuthAutoLogin
(
c
*
m
.
ReqContext
)
bool
{
if
!
setting
.
OAuthAutoLogin
{
return
false
}
oauthInfos
:=
setting
.
OAuthService
.
OAuthInfos
if
len
(
oauthInfos
)
!=
1
{
log
.
Warn
(
"Skipping OAuth auto login because multiple OAuth providers are configured."
)
return
false
}
for
key
:=
range
setting
.
OAuthService
.
OAuthInfos
{
redirectUrl
:=
setting
.
AppSubUrl
+
"/login/"
+
key
log
.
Info
(
"OAuth auto login enabled. Redirecting to "
+
redirectUrl
)
c
.
Redirect
(
redirectUrl
,
307
)
return
true
}
return
false
}
func
tryLoginUsingRememberCookie
(
c
*
m
.
ReqContext
)
bool
{
func
tryLoginUsingRememberCookie
(
c
*
m
.
ReqContext
)
bool
{
// Check auto-login.
// Check auto-login.
uname
:=
c
.
GetCookie
(
setting
.
CookieUserName
)
uname
:=
c
.
GetCookie
(
setting
.
CookieUserName
)
...
...
pkg/setting/setting.go
View file @
03ac9c52
...
@@ -112,6 +112,7 @@ var (
...
@@ -112,6 +112,7 @@ var (
ExternalUserMngLinkUrl
string
ExternalUserMngLinkUrl
string
ExternalUserMngLinkName
string
ExternalUserMngLinkName
string
ExternalUserMngInfo
string
ExternalUserMngInfo
string
OAuthAutoLogin
bool
ViewersCanEdit
bool
ViewersCanEdit
bool
// Http auth
// Http auth
...
@@ -626,6 +627,7 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error {
...
@@ -626,6 +627,7 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error {
auth
:=
iniFile
.
Section
(
"auth"
)
auth
:=
iniFile
.
Section
(
"auth"
)
DisableLoginForm
=
auth
.
Key
(
"disable_login_form"
)
.
MustBool
(
false
)
DisableLoginForm
=
auth
.
Key
(
"disable_login_form"
)
.
MustBool
(
false
)
DisableSignoutMenu
=
auth
.
Key
(
"disable_signout_menu"
)
.
MustBool
(
false
)
DisableSignoutMenu
=
auth
.
Key
(
"disable_signout_menu"
)
.
MustBool
(
false
)
OAuthAutoLogin
=
auth
.
Key
(
"oauth_auto_login"
)
.
MustBool
(
false
)
SignoutRedirectUrl
=
auth
.
Key
(
"signout_redirect_url"
)
.
String
()
SignoutRedirectUrl
=
auth
.
Key
(
"signout_redirect_url"
)
.
String
()
// anonymous access
// anonymous access
...
...
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