|
|
@@ -51,6 +51,7 @@ func NewOAuthService() {
|
|
|
Enabled: sec.Key("enabled").MustBool(),
|
|
|
AllowedDomains: sec.Key("allowed_domains").Strings(" "),
|
|
|
AllowSignup: sec.Key("allow_sign_up").MustBool(),
|
|
|
+ Name: sec.Key("name").MustString(name),
|
|
|
}
|
|
|
|
|
|
if !info.Enabled {
|
|
|
@@ -71,22 +72,18 @@ func NewOAuthService() {
|
|
|
|
|
|
// GitHub.
|
|
|
if name == "github" {
|
|
|
- setting.OAuthService.GitHub = true
|
|
|
- teamIds := sec.Key("team_ids").Ints(",")
|
|
|
- allowedOrganizations := sec.Key("allowed_organizations").Strings(" ")
|
|
|
SocialMap["github"] = &SocialGithub{
|
|
|
Config: &config,
|
|
|
allowedDomains: info.AllowedDomains,
|
|
|
apiUrl: info.ApiUrl,
|
|
|
allowSignup: info.AllowSignup,
|
|
|
- teamIds: teamIds,
|
|
|
- allowedOrganizations: allowedOrganizations,
|
|
|
+ teamIds: sec.Key("team_ids").Ints(","),
|
|
|
+ allowedOrganizations: sec.Key("allowed_organizations").Strings(" "),
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// Google.
|
|
|
if name == "google" {
|
|
|
- setting.OAuthService.Google = true
|
|
|
SocialMap["google"] = &SocialGoogle{
|
|
|
Config: &config, allowedDomains: info.AllowedDomains,
|
|
|
apiUrl: info.ApiUrl,
|
|
|
@@ -96,35 +93,23 @@ func NewOAuthService() {
|
|
|
|
|
|
// 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"] = &GenericOAuth{
|
|
|
Config: &config,
|
|
|
allowedDomains: info.AllowedDomains,
|
|
|
apiUrl: info.ApiUrl,
|
|
|
allowSignup: info.AllowSignup,
|
|
|
- teamIds: teamIds,
|
|
|
- allowedOrganizations: allowedOrganizations,
|
|
|
+ teamIds: sec.Key("team_ids").Ints(","),
|
|
|
+ allowedOrganizations: sec.Key("allowed_organizations").Strings(" "),
|
|
|
}
|
|
|
}
|
|
|
|
|
|
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",
|
|
|
+ AuthURL: setting.GrafanaNetUrl + "/oauth2/authorize",
|
|
|
+ TokenURL: setting.GrafanaNetUrl + "/api/oauth2/token",
|
|
|
},
|
|
|
RedirectURL: strings.TrimSuffix(setting.AppUrl, "/") + SocialBaseUrl + name,
|
|
|
Scopes: info.Scopes,
|
|
|
@@ -132,9 +117,9 @@ func NewOAuthService() {
|
|
|
|
|
|
SocialMap["grafananet"] = &SocialGrafanaNet{
|
|
|
Config: &config,
|
|
|
- url: url,
|
|
|
+ url: setting.GrafanaNetUrl,
|
|
|
allowSignup: info.AllowSignup,
|
|
|
- allowedOrganizations: allowedOrganizations,
|
|
|
+ allowedOrganizations: sec.Key("allowed_organizations").Strings(" "),
|
|
|
}
|
|
|
}
|
|
|
}
|