mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
support logging in with grafana.net credentials
This commit is contained in:
@@ -36,7 +36,7 @@ func NewOAuthService() {
|
||||
setting.OAuthService = &setting.OAuther{}
|
||||
setting.OAuthService.OAuthInfos = make(map[string]*setting.OAuthInfo)
|
||||
|
||||
allOauthes := []string{"github", "google", "generic_oauth"}
|
||||
allOauthes := []string{"github", "google", "generic_oauth", "grafananet"}
|
||||
|
||||
for _, name := range allOauthes {
|
||||
sec := setting.Cfg.Section("auth." + name)
|
||||
@@ -108,5 +108,33 @@ func NewOAuthService() {
|
||||
allowedOrganizations: allowedOrganizations,
|
||||
}
|
||||
}
|
||||
|
||||
if name == "grafananet" {
|
||||
setting.OAuthService.GrafanaNet = true
|
||||
allowedOrganizations := sec.Key("allowed_organizations").Strings(" ")
|
||||
|
||||
url := sec.Key("url").String()
|
||||
if url == "" {
|
||||
url = "https://grafana.net"
|
||||
}
|
||||
|
||||
config := oauth2.Config{
|
||||
ClientID: info.ClientId,
|
||||
ClientSecret: info.ClientSecret,
|
||||
Endpoint: oauth2.Endpoint{
|
||||
AuthURL: url + "/oauth2/authorize",
|
||||
TokenURL: url + "/api/oauth2/token",
|
||||
},
|
||||
RedirectURL: strings.TrimSuffix(setting.AppUrl, "/") + SocialBaseUrl + name,
|
||||
Scopes: info.Scopes,
|
||||
}
|
||||
|
||||
SocialMap["grafananet"] = &SocialGrafanaNet{
|
||||
Config: &config,
|
||||
url: url,
|
||||
allowSignup: info.AllowSignup,
|
||||
allowedOrganizations: allowedOrganizations,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user