mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge pull request #1782 from williamjoy/master
#1781 try fix oauth with github enterprise - add config of api_url
This commit is contained in:
commit
aefbcb7049
@ -141,6 +141,7 @@ client_secret = some_secret
|
|||||||
scopes = user:email
|
scopes = user:email
|
||||||
auth_url = https://github.com/login/oauth/authorize
|
auth_url = https://github.com/login/oauth/authorize
|
||||||
token_url = https://github.com/login/oauth/access_token
|
token_url = https://github.com/login/oauth/access_token
|
||||||
|
api_url = https://api.github.com/user
|
||||||
# Uncomment bellow to only allow specific email domains
|
# Uncomment bellow to only allow specific email domains
|
||||||
; allowed_domains = mycompany.com othercompany.com
|
; allowed_domains = mycompany.com othercompany.com
|
||||||
|
|
||||||
@ -152,6 +153,7 @@ client_secret = some_client_secret
|
|||||||
scopes = https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email
|
scopes = https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email
|
||||||
auth_url = https://accounts.google.com/o/oauth2/auth
|
auth_url = https://accounts.google.com/o/oauth2/auth
|
||||||
token_url = https://accounts.google.com/o/oauth2/token
|
token_url = https://accounts.google.com/o/oauth2/token
|
||||||
|
api_url = https://www.googleapis.com/oauth2/v1/userinfo
|
||||||
allowed_domains =
|
allowed_domains =
|
||||||
|
|
||||||
#################################### Logging ##########################
|
#################################### Logging ##########################
|
||||||
|
@ -141,6 +141,7 @@
|
|||||||
;scopes = user:email
|
;scopes = user:email
|
||||||
;auth_url = https://github.com/login/oauth/authorize
|
;auth_url = https://github.com/login/oauth/authorize
|
||||||
;token_url = https://github.com/login/oauth/access_token
|
;token_url = https://github.com/login/oauth/access_token
|
||||||
|
;api_url = https://api.github.com/user
|
||||||
# Uncomment bellow to only allow specific email domains
|
# Uncomment bellow to only allow specific email domains
|
||||||
; allowed_domains = mycompany.com othercompany.com
|
; allowed_domains = mycompany.com othercompany.com
|
||||||
|
|
||||||
@ -152,6 +153,7 @@
|
|||||||
;scopes = https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email
|
;scopes = https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email
|
||||||
;auth_url = https://accounts.google.com/o/oauth2/auth
|
;auth_url = https://accounts.google.com/o/oauth2/auth
|
||||||
;token_url = https://accounts.google.com/o/oauth2/token
|
;token_url = https://accounts.google.com/o/oauth2/token
|
||||||
|
;api_url = https://www.googleapis.com/oauth2/v1/userinfo
|
||||||
# Uncomment bellow to only allow specific email domains
|
# Uncomment bellow to only allow specific email domains
|
||||||
; allowed_domains = mycompany.com othercompany.com
|
; allowed_domains = mycompany.com othercompany.com
|
||||||
|
|
||||||
|
@ -49,6 +49,7 @@ func NewOAuthService() {
|
|||||||
Scopes: sec.Key("scopes").Strings(" "),
|
Scopes: sec.Key("scopes").Strings(" "),
|
||||||
AuthUrl: sec.Key("auth_url").String(),
|
AuthUrl: sec.Key("auth_url").String(),
|
||||||
TokenUrl: sec.Key("token_url").String(),
|
TokenUrl: sec.Key("token_url").String(),
|
||||||
|
APIUrl: sec.Key("api_url").String(),
|
||||||
Enabled: sec.Key("enabled").MustBool(),
|
Enabled: sec.Key("enabled").MustBool(),
|
||||||
AllowedDomains: sec.Key("allowed_domains").Strings(" "),
|
AllowedDomains: sec.Key("allowed_domains").Strings(" "),
|
||||||
}
|
}
|
||||||
@ -72,7 +73,7 @@ func NewOAuthService() {
|
|||||||
// GitHub.
|
// GitHub.
|
||||||
if name == "github" {
|
if name == "github" {
|
||||||
setting.OAuthService.GitHub = true
|
setting.OAuthService.GitHub = true
|
||||||
SocialMap["github"] = &SocialGithub{Config: &config, allowedDomains: info.AllowedDomains}
|
SocialMap["github"] = &SocialGithub{Config: &config, allowedDomains: info.AllowedDomains, APIUrl: info.APIUrl}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Google.
|
// Google.
|
||||||
@ -100,6 +101,7 @@ func isEmailAllowed(email string, allowedDomains []string) bool {
|
|||||||
type SocialGithub struct {
|
type SocialGithub struct {
|
||||||
*oauth2.Config
|
*oauth2.Config
|
||||||
allowedDomains []string
|
allowedDomains []string
|
||||||
|
APIUrl []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SocialGithub) Type() int {
|
func (s *SocialGithub) Type() int {
|
||||||
@ -119,7 +121,7 @@ func (s *SocialGithub) UserInfo(token *oauth2.Token) (*BasicUserInfo, error) {
|
|||||||
|
|
||||||
var err error
|
var err error
|
||||||
client := s.Client(oauth2.NoContext, token)
|
client := s.Client(oauth2.NoContext, token)
|
||||||
r, err := client.Get("https://api.github.com/user")
|
r, err := client.Get(s.APIUrl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user