mirror of
				https://github.com/grafana/grafana.git
				synced 2025-02-25 18:55:37 -06:00 
			
		
		
		
	Merge branch 'custom-github-style-oauth' of https://github.com/kfitzpatrick/grafana into kfitzpatrick-custom-github-style-oauth
This commit is contained in:
		@@ -27,6 +27,8 @@ func LoginView(c *middleware.Context) {
 | 
			
		||||
 | 
			
		||||
	viewData.Settings["googleAuthEnabled"] = setting.OAuthService.Google
 | 
			
		||||
	viewData.Settings["githubAuthEnabled"] = setting.OAuthService.GitHub
 | 
			
		||||
	viewData.Settings["genericOAuthEnabled"] = setting.OAuthService.Generic
 | 
			
		||||
	viewData.Settings["oauthProviderName"] = setting.OAuthService.OAuthProviderName
 | 
			
		||||
	viewData.Settings["disableUserSignUp"] = !setting.AllowUserSignUp
 | 
			
		||||
	viewData.Settings["loginHint"] = setting.LoginHint
 | 
			
		||||
	viewData.Settings["allowUserPassLogin"] = setting.AllowUserPassLogin
 | 
			
		||||
 
 | 
			
		||||
@@ -11,8 +11,9 @@ type OAuthInfo struct {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type OAuther struct {
 | 
			
		||||
	GitHub, Google, Twitter bool
 | 
			
		||||
	OAuthInfos              map[string]*OAuthInfo
 | 
			
		||||
	GitHub, Google, Twitter, Generic bool
 | 
			
		||||
	OAuthInfos                       map[string]*OAuthInfo
 | 
			
		||||
	OAuthProviderName                string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var OAuthService *OAuther
 | 
			
		||||
 
 | 
			
		||||
@@ -42,7 +42,7 @@ func NewOAuthService() {
 | 
			
		||||
	setting.OAuthService = &setting.OAuther{}
 | 
			
		||||
	setting.OAuthService.OAuthInfos = make(map[string]*setting.OAuthInfo)
 | 
			
		||||
 | 
			
		||||
	allOauthes := []string{"github", "google"}
 | 
			
		||||
	allOauthes := []string{"github", "google", "generic_oauth"}
 | 
			
		||||
 | 
			
		||||
	for _, name := range allOauthes {
 | 
			
		||||
		sec := setting.Cfg.Section("auth." + name)
 | 
			
		||||
@@ -98,6 +98,22 @@ func NewOAuthService() {
 | 
			
		||||
				allowSignup: info.AllowSignup,
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Generic - Uses the same scheme as Github.
 | 
			
		||||
		if name == "generic_oauth" {
 | 
			
		||||
			setting.OAuthService.Generic = true
 | 
			
		||||
			setting.OAuthService.OAuthProviderName = sec.Key("oauth_provider_name").String()
 | 
			
		||||
			teamIds := sec.Key("team_ids").Ints(",")
 | 
			
		||||
			allowedOrganizations := sec.Key("allowed_organizations").Strings(" ")
 | 
			
		||||
			SocialMap["generic_oauth"] = &SocialGithub{
 | 
			
		||||
				Config:               &config,
 | 
			
		||||
				allowedDomains:       info.AllowedDomains,
 | 
			
		||||
				apiUrl:               info.ApiUrl,
 | 
			
		||||
				allowSignup:          info.AllowSignup,
 | 
			
		||||
				teamIds:              teamIds,
 | 
			
		||||
				allowedOrganizations: allowedOrganizations,
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user