diff --git a/internal/config/config.go b/internal/config/config.go
index e4a51d24..4280ba1e 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -141,6 +141,7 @@ type Config struct {
type OAuth2Provider struct {
Name string
+ Title string
ClientID string
ClientSecret string
Icon string
@@ -152,8 +153,9 @@ type OAuth2Provider struct {
}
type NavigationLink struct {
- Title string
- Url string
+ Title string
+ Url string
+ Target string
}
type SaveLogsConfig struct {
diff --git a/internal/executor/arguments.go b/internal/executor/arguments.go
index f525c0ef..8fc6a740 100644
--- a/internal/executor/arguments.go
+++ b/internal/executor/arguments.go
@@ -138,6 +138,7 @@ func typecheckChoiceEntity(value string, arg *config.ActionArgument) error {
// TypeSafetyCheck checks argument values match a specific type. The types are
// defined in typecheckRegex, and, you guessed it, uses regex to check for allowed
// characters.
+//
//gocyclo:ignore
func TypeSafetyCheck(name string, value string, argumentType string) error {
switch argumentType {
diff --git a/internal/httpservers/oauth2.go b/internal/httpservers/oauth2.go
index b2e4a0d2..1adb6649 100644
--- a/internal/httpservers/oauth2.go
+++ b/internal/httpservers/oauth2.go
@@ -31,10 +31,33 @@ func assignIfEmpty(target *string, value string) {
}
}
+func oauth2Init(cfg *config.Config) {
+ for providerName, providerConfig := range cfg.AuthOAuth2Providers {
+ completeProviderConfig(providerName, providerConfig)
+
+ newConfig := &oauth2.Config{
+ ClientID: providerConfig.ClientID,
+ ClientSecret: providerConfig.ClientSecret,
+ Scopes: providerConfig.Scopes,
+ Endpoint: oauth2.Endpoint{
+ AuthURL: providerConfig.AuthUrl,
+ TokenURL: providerConfig.TokenUrl,
+ },
+ RedirectURL: cfg.AuthOAuth2RedirectURL,
+ }
+
+ registeredProviders[providerName] = newConfig
+
+ log.Debugf("Dumping newly registered provider: %v = %+v", providerName, providerConfig)
+ }
+}
+
func completeProviderConfig(providerName string, providerConfig *config.OAuth2Provider) {
dbConfig, ok := oauth2ProviderDatabase[providerName]
if ok {
+ assignIfEmpty(&providerConfig.Name, dbConfig.Name)
+ assignIfEmpty(&providerConfig.Title, dbConfig.Title)
assignIfEmpty(&providerConfig.WhoamiUrl, dbConfig.WhoamiUrl)
assignIfEmpty(&providerConfig.TokenUrl, dbConfig.TokenUrl)
assignIfEmpty(&providerConfig.AuthUrl, dbConfig.AuthUrl)
@@ -53,28 +76,7 @@ func getOAuth2Config(cfg *config.Config, providerName string) (*oauth2.Config, e
config, ok := registeredProviders[providerName]
if !ok {
- providerConfig, ok := cfg.AuthOAuth2Providers[providerName]
-
- if !ok {
- return nil, fmt.Errorf("Provider not found in config: %v", providerName)
- }
-
- completeProviderConfig(providerName, providerConfig)
-
- config = &oauth2.Config{
- ClientID: providerConfig.ClientID,
- ClientSecret: providerConfig.ClientSecret,
- Scopes: providerConfig.Scopes,
- Endpoint: oauth2.Endpoint{
- AuthURL: providerConfig.AuthUrl,
- TokenURL: providerConfig.TokenUrl,
- },
- RedirectURL: cfg.AuthOAuth2RedirectURL,
- }
-
- registeredProviders[providerName] = config
-
- log.Debugf("Dumping newly registered provider: %v = %+v", providerName, providerConfig)
+ return nil, fmt.Errorf("Provider not found in config: %v", providerName)
}
return config, nil
diff --git a/internal/httpservers/oauth2_providers.go b/internal/httpservers/oauth2_providers.go
index 9e7af74d..3da2d567 100644
--- a/internal/httpservers/oauth2_providers.go
+++ b/internal/httpservers/oauth2_providers.go
@@ -7,7 +7,9 @@ import (
var oauth2ProviderDatabase = map[string]config.OAuth2Provider{
"github": {
- Icon: "github",
+ Title: "GitHub",
+ Name: "github",
+ Icon: "",
WhoamiUrl: "https://api.github.com/user",
TokenUrl: endpoints.GitHub.TokenURL,
AuthUrl: endpoints.GitHub.AuthURL,
diff --git a/internal/httpservers/singleFrontend.go b/internal/httpservers/singleFrontend.go
index 0a2ab6a9..66626c2d 100644
--- a/internal/httpservers/singleFrontend.go
+++ b/internal/httpservers/singleFrontend.go
@@ -77,6 +77,8 @@ func StartSingleHTTPFrontend(cfg *config.Config) {
})
}
+ oauth2Init(cfg)
+
srv := &http.Server{
Addr: cfg.ListenAddressSingleHTTPFrontend,
Handler: mux,
diff --git a/internal/httpservers/webuiServer.go b/internal/httpservers/webuiServer.go
index 9e10e761..5c71f351 100644
--- a/internal/httpservers/webuiServer.go
+++ b/internal/httpservers/webuiServer.go
@@ -33,6 +33,8 @@ type webUISettings struct {
SshFoundConfig string
EnableCustomJs bool
AuthLoginUrl string
+ AuthLocalLogin bool
+ AuthOAuth2Providers []publicOAuth2Provider
AdditionalLinks []*config.NavigationLink
}
@@ -105,6 +107,26 @@ func generateThemeCss(w http.ResponseWriter, r *http.Request) {
w.Write(customThemeCss)
}
+type publicOAuth2Provider struct {
+ Name string
+ Title string
+ Icon string
+}
+
+func buildPublicOAuth2ProvidersList(cfg *config.Config) []publicOAuth2Provider {
+ var publicProviders []publicOAuth2Provider
+
+ for _, provider := range cfg.AuthOAuth2Providers {
+ publicProviders = append(publicProviders, publicOAuth2Provider{
+ Name: provider.Name,
+ Title: provider.Title,
+ Icon: provider.Icon,
+ })
+ }
+
+ return publicProviders
+}
+
func generateWebUISettings(w http.ResponseWriter, r *http.Request) {
jsonRet, _ := json.Marshal(webUISettings{
Rest: cfg.ExternalRestAddress + "/api/",
@@ -120,6 +142,8 @@ func generateWebUISettings(w http.ResponseWriter, r *http.Request) {
SshFoundConfig: installationinfo.Runtime.SshFoundConfig,
EnableCustomJs: cfg.EnableCustomJs,
AuthLoginUrl: cfg.AuthLoginUrl,
+ AuthLocalLogin: true,
+ AuthOAuth2Providers: buildPublicOAuth2ProvidersList(cfg),
AdditionalLinks: cfg.AdditionalNavigationLinks,
})
diff --git a/webui.dev/index.html b/webui.dev/index.html
index 035e25a9..bd1bcdd0 100644
--- a/webui.dev/index.html
+++ b/webui.dev/index.html
@@ -92,35 +92,6 @@
-
- Status: unknown + Status: unknown