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
c201fc17
Unverified
Commit
c201fc17
authored
Dec 19, 2018
by
Carl Bergquist
Committed by
GitHub
Dec 19, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14563 from tdabasinskas/broken_oauth_provider
Support OAuth providers that are not RFC6749 compliant
parents
71837fe1
eb517a37
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
31 deletions
+54
-31
conf/defaults.ini
+1
-0
conf/sample.ini
+4
-0
docs/sources/auth/generic-oauth.md
+12
-1
pkg/setting/setting_oauth.go
+15
-14
pkg/social/social.go
+22
-16
No files found.
conf/defaults.ini
View file @
c201fc17
...
...
@@ -335,6 +335,7 @@ tls_skip_verify_insecure = false
tls_client_cert
=
tls_client_key
=
tls_client_ca
=
send_client_credentials_via_post
=
false
#################################### Basic Auth ##########################
[auth.basic]
...
...
conf/sample.ini
View file @
c201fc17
...
...
@@ -284,6 +284,10 @@ log_queries =
;tls_client_key =
;tls_client_ca =
; Set to true to enable sending client_id and client_secret via POST body instead of Basic authentication HTTP header
; This might be required if the OAuth provider is not RFC6749 compliant, only supporting credentials passed via POST payload
;send_client_credentials_via_post = false
#################################### Grafana.com Auth ####################
[auth.grafana_com]
;enabled = false
...
...
docs/sources/auth/generic-oauth.md
View file @
c201fc17
...
...
@@ -17,7 +17,7 @@ can find examples using Okta, BitBucket, OneLogin and Azure.
This callback URL must match the full HTTP address that you use in your browser to access Grafana, but with the prefix path of
`/login/generic_oauth`
.
You may have to set the
`root_url`
option of
`[server]`
for the callback URL to be
You may have to set the
`root_url`
option of
`[server]`
for the callback URL to be
correct. For example in case you are serving Grafana behind a proxy.
Example config:
...
...
@@ -209,6 +209,17 @@ allowed_organizations =
token_url = https://<your domain>.my.centrify.com/OAuth2/Token/<Application ID>
```
## Set up OAuth2 with non-compliant providers
Some OAuth2 providers might not support
`client_id`
and
`client_secret`
passed via Basic Authentication HTTP header, which
results in
`invalid_client`
error. To allow Grafana to authenticate via these type of providers, the client identifiers must be
send via POST body, which can be enabled via the following settings:
```bash
[auth.generic_oauth]
send_client_credentials_via_post = true
```
<hr>
pkg/setting/setting_oauth.go
View file @
c201fc17
package
setting
type
OAuthInfo
struct
{
ClientId
,
ClientSecret
string
Scopes
[]
string
AuthUrl
,
TokenUrl
string
Enabled
bool
EmailAttributeName
string
AllowedDomains
[]
string
HostedDomain
string
ApiUrl
string
AllowSignup
bool
Name
string
TlsClientCert
string
TlsClientKey
string
TlsClientCa
string
TlsSkipVerify
bool
ClientId
,
ClientSecret
string
Scopes
[]
string
AuthUrl
,
TokenUrl
string
Enabled
bool
EmailAttributeName
string
AllowedDomains
[]
string
HostedDomain
string
ApiUrl
string
AllowSignup
bool
Name
string
TlsClientCert
string
TlsClientKey
string
TlsClientCa
string
TlsSkipVerify
bool
SendClientCredentialsViaPost
bool
}
type
OAuther
struct
{
...
...
pkg/social/social.go
View file @
c201fc17
...
...
@@ -63,28 +63,34 @@ func NewOAuthService() {
for
_
,
name
:=
range
allOauthes
{
sec
:=
setting
.
Raw
.
Section
(
"auth."
+
name
)
info
:=
&
setting
.
OAuthInfo
{
ClientId
:
sec
.
Key
(
"client_id"
)
.
String
(),
ClientSecret
:
sec
.
Key
(
"client_secret"
)
.
String
(),
Scopes
:
util
.
SplitString
(
sec
.
Key
(
"scopes"
)
.
String
()),
AuthUrl
:
sec
.
Key
(
"auth_url"
)
.
String
(),
TokenUrl
:
sec
.
Key
(
"token_url"
)
.
String
(),
ApiUrl
:
sec
.
Key
(
"api_url"
)
.
String
(),
Enabled
:
sec
.
Key
(
"enabled"
)
.
MustBool
(),
EmailAttributeName
:
sec
.
Key
(
"email_attribute_name"
)
.
String
(),
AllowedDomains
:
util
.
SplitString
(
sec
.
Key
(
"allowed_domains"
)
.
String
()),
HostedDomain
:
sec
.
Key
(
"hosted_domain"
)
.
String
(),
AllowSignup
:
sec
.
Key
(
"allow_sign_up"
)
.
MustBool
(),
Name
:
sec
.
Key
(
"name"
)
.
MustString
(
name
),
TlsClientCert
:
sec
.
Key
(
"tls_client_cert"
)
.
String
(),
TlsClientKey
:
sec
.
Key
(
"tls_client_key"
)
.
String
(),
TlsClientCa
:
sec
.
Key
(
"tls_client_ca"
)
.
String
(),
TlsSkipVerify
:
sec
.
Key
(
"tls_skip_verify_insecure"
)
.
MustBool
(),
ClientId
:
sec
.
Key
(
"client_id"
)
.
String
(),
ClientSecret
:
sec
.
Key
(
"client_secret"
)
.
String
(),
Scopes
:
util
.
SplitString
(
sec
.
Key
(
"scopes"
)
.
String
()),
AuthUrl
:
sec
.
Key
(
"auth_url"
)
.
String
(),
TokenUrl
:
sec
.
Key
(
"token_url"
)
.
String
(),
ApiUrl
:
sec
.
Key
(
"api_url"
)
.
String
(),
Enabled
:
sec
.
Key
(
"enabled"
)
.
MustBool
(),
EmailAttributeName
:
sec
.
Key
(
"email_attribute_name"
)
.
String
(),
AllowedDomains
:
util
.
SplitString
(
sec
.
Key
(
"allowed_domains"
)
.
String
()),
HostedDomain
:
sec
.
Key
(
"hosted_domain"
)
.
String
(),
AllowSignup
:
sec
.
Key
(
"allow_sign_up"
)
.
MustBool
(),
Name
:
sec
.
Key
(
"name"
)
.
MustString
(
name
),
TlsClientCert
:
sec
.
Key
(
"tls_client_cert"
)
.
String
(),
TlsClientKey
:
sec
.
Key
(
"tls_client_key"
)
.
String
(),
TlsClientCa
:
sec
.
Key
(
"tls_client_ca"
)
.
String
(),
TlsSkipVerify
:
sec
.
Key
(
"tls_skip_verify_insecure"
)
.
MustBool
(),
SendClientCredentialsViaPost
:
sec
.
Key
(
"send_client_credentials_via_post"
)
.
MustBool
(),
}
if
!
info
.
Enabled
{
continue
}
// handle the clients that do not properly support Basic auth headers and require passing client_id/client_secret via POST payload
if
info
.
SendClientCredentialsViaPost
{
oauth2
.
RegisterBrokenAuthHeaderProvider
(
info
.
TokenUrl
)
}
if
name
==
"grafananet"
{
name
=
grafanaCom
}
...
...
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