Pārlūkot izejas kodu

Updated changelog with, Github OAuth: Now works with Github for Enterprise, thanks @williamjoy

Torkel Ödegaard 10 gadi atpakaļ
vecāks
revīzija
e9afd30b47
4 mainītis faili ar 11 papildinājumiem un 6 dzēšanām
  1. 5 0
      CHANGELOG.md
  2. 1 2
      conf/defaults.ini
  3. 1 0
      pkg/setting/setting_oauth.go
  4. 4 4
      pkg/social/social.go

+ 5 - 0
CHANGELOG.md

@@ -1,3 +1,8 @@
+# 2.0.0 (unreleased)
+
+**Fixes**
+- [Issue #1782](https://github.com/grafana/grafana/issues/1782). Github OAuth: Now works with Github for Enterprise, thanks @williamjoy
+
 # 2.0.0-Beta3 (2015-04-12)
 
 **RPM / DEB Package changes (to follow HFS)**

+ 1 - 2
conf/defaults.ini

@@ -142,8 +142,7 @@ scopes = user:email
 auth_url = https://github.com/login/oauth/authorize
 token_url = https://github.com/login/oauth/access_token
 api_url = https://api.github.com/user
-# Uncomment bellow to only allow specific email domains
-; allowed_domains = mycompany.com othercompany.com
+allowed_domains =
 
 #################################### Google Auth ##########################
 [auth.google]

+ 1 - 0
pkg/setting/setting_oauth.go

@@ -6,6 +6,7 @@ type OAuthInfo struct {
 	AuthUrl, TokenUrl      string
 	Enabled                bool
 	AllowedDomains         []string
+	ApiUrl                 string
 }
 
 type OAuther struct {

+ 4 - 4
pkg/social/social.go

@@ -49,7 +49,7 @@ func NewOAuthService() {
 			Scopes:         sec.Key("scopes").Strings(" "),
 			AuthUrl:        sec.Key("auth_url").String(),
 			TokenUrl:       sec.Key("token_url").String(),
-			APIUrl:         sec.Key("api_url").String(),
+			ApiUrl:         sec.Key("api_url").String(),
 			Enabled:        sec.Key("enabled").MustBool(),
 			AllowedDomains: sec.Key("allowed_domains").Strings(" "),
 		}
@@ -73,7 +73,7 @@ func NewOAuthService() {
 		// GitHub.
 		if name == "github" {
 			setting.OAuthService.GitHub = true
-			SocialMap["github"] = &SocialGithub{Config: &config, allowedDomains: info.AllowedDomains, APIUrl: info.APIUrl}
+			SocialMap["github"] = &SocialGithub{Config: &config, allowedDomains: info.AllowedDomains, ApiUrl: info.ApiUrl}
 		}
 
 		// Google.
@@ -101,7 +101,7 @@ func isEmailAllowed(email string, allowedDomains []string) bool {
 type SocialGithub struct {
 	*oauth2.Config
 	allowedDomains []string
-	APIUrl []string
+	ApiUrl         string
 }
 
 func (s *SocialGithub) Type() int {
@@ -121,7 +121,7 @@ func (s *SocialGithub) UserInfo(token *oauth2.Token) (*BasicUserInfo, error) {
 
 	var err error
 	client := s.Client(oauth2.NoContext, token)
-	r, err := client.Get(s.APIUrl)
+	r, err := client.Get(s.ApiUrl)
 	if err != nil {
 		return nil, err
 	}