commit
1ec5cf07f2
@ -54,16 +54,12 @@ COPY --from=builder /usr/local/src/dex/go.mod /usr/local/src/dex/go.sum /usr/loc
|
|||||||
COPY --from=builder /usr/local/src/dex/api/v2/go.mod /usr/local/src/dex/api/v2/go.sum /usr/local/src/dex/api/v2/
|
COPY --from=builder /usr/local/src/dex/api/v2/go.mod /usr/local/src/dex/api/v2/go.sum /usr/local/src/dex/api/v2/
|
||||||
|
|
||||||
COPY --from=builder /go/bin/dex /usr/local/bin/dex
|
COPY --from=builder /go/bin/dex /usr/local/bin/dex
|
||||||
|
COPY --from=builder /usr/local/src/dex/web /srv/dex/web
|
||||||
|
|
||||||
COPY --from=gomplate /usr/local/bin/gomplate /usr/local/bin/gomplate
|
COPY --from=gomplate /usr/local/bin/gomplate /usr/local/bin/gomplate
|
||||||
|
|
||||||
USER 1001:1001
|
USER 1001:1001
|
||||||
|
|
||||||
# Import frontend assets and set the correct CWD directory so the assets
|
|
||||||
# are in the default path.
|
|
||||||
COPY --from=builder /usr/local/src/dex/web /web
|
|
||||||
|
|
||||||
USER 1001:1001
|
|
||||||
|
|
||||||
COPY docker-entrypoint.sh /entrypoint.sh
|
COPY docker-entrypoint.sh /entrypoint.sh
|
||||||
|
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
|
@ -523,4 +523,8 @@ func applyConfigOverrides(options serveOptions, config *Config) {
|
|||||||
if options.grpcAddr != "" {
|
if options.grpcAddr != "" {
|
||||||
config.GRPC.Addr = options.grpcAddr
|
config.GRPC.Addr = options.grpcAddr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if config.Frontend.Dir == "" {
|
||||||
|
config.Frontend.Dir = os.Getenv("DEX_FRONTEND_DIR")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ web:
|
|||||||
# frontend:
|
# frontend:
|
||||||
# issuer: dex
|
# issuer: dex
|
||||||
# logoURL: theme/logo.png
|
# logoURL: theme/logo.png
|
||||||
# dir: web/
|
# dir: ""
|
||||||
# theme: light
|
# theme: light
|
||||||
|
|
||||||
# Telemetry configuration
|
# Telemetry configuration
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"io/fs"
|
"io/fs"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -41,6 +42,7 @@ import (
|
|||||||
"github.com/dexidp/dex/connector/saml"
|
"github.com/dexidp/dex/connector/saml"
|
||||||
"github.com/dexidp/dex/pkg/log"
|
"github.com/dexidp/dex/pkg/log"
|
||||||
"github.com/dexidp/dex/storage"
|
"github.com/dexidp/dex/storage"
|
||||||
|
"github.com/dexidp/dex/web"
|
||||||
)
|
)
|
||||||
|
|
||||||
// LocalConnector is the local passwordDB connector which is an internal
|
// LocalConnector is the local passwordDB connector which is an internal
|
||||||
@ -101,20 +103,20 @@ type Config struct {
|
|||||||
|
|
||||||
// WebConfig holds the server's frontend templates and asset configuration.
|
// WebConfig holds the server's frontend templates and asset configuration.
|
||||||
type WebConfig struct {
|
type WebConfig struct {
|
||||||
// A file path to web static. If set, WebFS will be ignored.
|
// A file path to static web assets.
|
||||||
//
|
//
|
||||||
// It is expected to contain the following directories:
|
// It is expected to contain the following directories:
|
||||||
//
|
//
|
||||||
// * static - Static static served at "( issuer URL )/static".
|
// * static - Static static served at "( issuer URL )/static".
|
||||||
// * templates - HTML templates controlled by dex.
|
// * templates - HTML templates controlled by dex.
|
||||||
// * themes/(theme) - Static static served at "( issuer URL )/theme".
|
// * themes/(theme) - Static static served at "( issuer URL )/theme".
|
||||||
//
|
|
||||||
Dir string
|
Dir string
|
||||||
|
|
||||||
// Alternative way to configure web static filesystem. Dir overrides this.
|
// Alternative way to programatically configure static web assets.
|
||||||
// It's expected to contain the same files and directories as mentioned
|
// If Dir is specified, WebFS is ignored.
|
||||||
// above in Dir doc.
|
// It's expected to contain the same files and directories as mentioned above.
|
||||||
//
|
//
|
||||||
|
// Note: this is experimental. Might get removed without notice!
|
||||||
WebFS fs.FS
|
WebFS fs.FS
|
||||||
|
|
||||||
// Defaults to "( issuer URL )/theme/logo.png"
|
// Defaults to "( issuer URL )/theme/logo.png"
|
||||||
@ -210,9 +212,15 @@ func newServer(ctx context.Context, c Config, rotationStrategy rotationStrategy)
|
|||||||
supported[respType] = true
|
supported[respType] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
webFS := web.FS()
|
||||||
|
if c.Web.Dir != "" {
|
||||||
|
webFS = os.DirFS(c.Web.Dir)
|
||||||
|
} else if c.Web.WebFS != nil {
|
||||||
|
webFS = c.Web.WebFS
|
||||||
|
}
|
||||||
|
|
||||||
web := webConfig{
|
web := webConfig{
|
||||||
dir: c.Web.Dir,
|
webFS: webFS,
|
||||||
webFS: c.Web.WebFS,
|
|
||||||
logoURL: c.Web.LogoURL,
|
logoURL: c.Web.LogoURL,
|
||||||
issuerURL: c.Issuer,
|
issuerURL: c.Issuer,
|
||||||
issuer: c.Web.Issuer,
|
issuer: c.Web.Issuer,
|
||||||
|
@ -7,7 +7,6 @@ import (
|
|||||||
"io/fs"
|
"io/fs"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
@ -45,7 +44,6 @@ type templates struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type webConfig struct {
|
type webConfig struct {
|
||||||
dir string
|
|
||||||
webFS fs.FS
|
webFS fs.FS
|
||||||
logoURL string
|
logoURL string
|
||||||
issuer string
|
issuer string
|
||||||
@ -77,11 +75,6 @@ func loadWebConfig(c webConfig) (http.Handler, http.Handler, *templates, error)
|
|||||||
if c.issuer == "" {
|
if c.issuer == "" {
|
||||||
c.issuer = "dex"
|
c.issuer = "dex"
|
||||||
}
|
}
|
||||||
if c.dir != "" {
|
|
||||||
c.webFS = os.DirFS(c.dir)
|
|
||||||
} else if c.webFS == nil {
|
|
||||||
c.webFS = os.DirFS("./web")
|
|
||||||
}
|
|
||||||
if c.logoURL == "" {
|
if c.logoURL == "" {
|
||||||
c.logoURL = "theme/logo.png"
|
c.logoURL = "theme/logo.png"
|
||||||
}
|
}
|
||||||
|
14
web/web.go
Normal file
14
web/web.go
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package web
|
||||||
|
|
||||||
|
import (
|
||||||
|
"embed"
|
||||||
|
"io/fs"
|
||||||
|
)
|
||||||
|
|
||||||
|
//go:embed static/* templates/* themes/*
|
||||||
|
var files embed.FS
|
||||||
|
|
||||||
|
// FS returns a filesystem with the default web assets.
|
||||||
|
func FS() fs.FS {
|
||||||
|
return files
|
||||||
|
}
|
Reference in New Issue
Block a user