|
@@ -36,7 +36,7 @@ func NewOAuthService() {
|
|
|
setting.OAuthService = &setting.OAuther{}
|
|
setting.OAuthService = &setting.OAuther{}
|
|
|
setting.OAuthService.OAuthInfos = make(map[string]*setting.OAuthInfo)
|
|
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 {
|
|
for _, name := range allOauthes {
|
|
|
sec := setting.Cfg.Section("auth." + name)
|
|
sec := setting.Cfg.Section("auth." + name)
|
|
@@ -108,5 +108,33 @@ func NewOAuthService() {
|
|
|
allowedOrganizations: allowedOrganizations,
|
|
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,
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|