forked from traefik/traefik
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: nrwiersma <[email protected]>
- Loading branch information
Showing
27 changed files
with
142 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ jobs: | |
- name: Build webui | ||
run: | | ||
make generate-webui | ||
tar czvf webui.tar.gz ./static/ | ||
tar czvf webui.tar.gz ./webui/static/ | ||
- name: Artifact webui | ||
uses: actions/upload-artifact@v2 | ||
|
@@ -66,9 +66,6 @@ jobs: | |
key: ${{ runner.os }}-build-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: ${{ runner.os }}-build-go- | ||
|
||
- name: Installing dependencies | ||
run: go install github.com/containous/go-bindata/[email protected] | ||
|
||
- name: Artifact webui | ||
uses: actions/download-artifact@v2 | ||
with: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,8 +39,8 @@ jobs: | |
key: ${{ runner.os }}-test-unit-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: ${{ runner.os }}-test-unit-go- | ||
|
||
- name: Installing dependencies | ||
run: go install github.com/containous/go-bindata/[email protected] | ||
- name: Avoid generating webui | ||
run: mkdir -p webui/static && touch webui/static/index.html | ||
|
||
- name: Tests | ||
run: make test-unit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,15 +41,15 @@ jobs: | |
key: ${{ runner.os }}-validate-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: ${{ runner.os }}-validate-go- | ||
|
||
- name: Installing dependencies | ||
run: go install github.com/containous/go-bindata/[email protected] | ||
|
||
- name: Install golangci-lint ${{ env.GOLANGCI_LINT_VERSION }} | ||
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_LINT_VERSION} | ||
|
||
- name: Install missspell ${{ env.MISSSPELL_VERSION }} | ||
run: curl -sfL https://raw.githubusercontent.com/client9/misspell/master/install-misspell.sh | sh -s -- -b $(go env GOPATH)/bin ${MISSSPELL_VERSION} | ||
|
||
- name: Avoid generating webui | ||
run: mkdir -p webui/static && touch webui/static/index.html | ||
|
||
- name: Validate | ||
run: make validate | ||
|
||
|
@@ -81,9 +81,6 @@ jobs: | |
key: ${{ runner.os }}-validate-generate-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: ${{ runner.os }}-validate-generate-go- | ||
|
||
- name: Installing dependencies | ||
run: go install github.com/containous/go-bindata/[email protected] | ||
|
||
- name: go generate | ||
run: | | ||
go generate | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,6 @@ global_job_config: | |
- export GOPROXY=https://proxy.golang.org,direct | ||
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "${GOPATH}/bin" v1.41.1 | ||
- curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | bash -s -- -b "${GOPATH}/bin" | ||
- go install github.com/containous/go-bindata/[email protected] | ||
- checkout | ||
- cache restore traefik-$(checksum go.sum) | ||
|
||
|
@@ -41,7 +40,7 @@ blocks: | |
- name: Test Integration Container | ||
commands: | ||
- make pull-images | ||
- mkdir -p static # Avoid to generate webui | ||
- mkdir -p webui/static && touch webui/static/index.html # Avoid generating webui | ||
- PRE_TARGET="" make binary | ||
- make test-integration-container | ||
- df -h | ||
|
@@ -61,7 +60,7 @@ blocks: | |
jobs: | ||
- name: Test Integration Host | ||
commands: | ||
- mkdir -p static # Avoid to generate webui | ||
- mkdir -p webui/static && touch webui/static/index.html # Avoid generating webui | ||
- make test-integration-host | ||
epilogue: | ||
always: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package dashboard | ||
|
||
import ( | ||
"io/fs" | ||
"net/http" | ||
"net/url" | ||
|
||
"github.com/gorilla/mux" | ||
"github.com/traefik/traefik/v2/webui" | ||
) | ||
|
||
// Handler expose dashboard routes. | ||
type Handler struct { | ||
assets fs.FS // optional assets, to override the webui.FS default | ||
} | ||
|
||
// Append adds dashboard routes on the given router, optionally using the given | ||
// assets (or webui.FS otherwise). | ||
func Append(router *mux.Router, customAssets fs.FS) { | ||
assets := customAssets | ||
if assets == nil { | ||
assets = webui.FS | ||
} | ||
// Expose dashboard | ||
router.Methods(http.MethodGet). | ||
Path("/"). | ||
HandlerFunc(func(resp http.ResponseWriter, req *http.Request) { | ||
http.Redirect(resp, req, safePrefix(req)+"/dashboard/", http.StatusFound) | ||
}) | ||
|
||
router.Methods(http.MethodGet). | ||
PathPrefix("/dashboard/"). | ||
HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
// allow iframes from our domains only | ||
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-src | ||
w.Header().Set("Content-Security-Policy", "frame-src 'self' https://traefik.io https://*.traefik.io;") | ||
http.StripPrefix("/dashboard/", http.FileServer(http.FS(assets))).ServeHTTP(w, r) | ||
}) | ||
} | ||
|
||
func (g Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { | ||
assets := g.assets | ||
if assets == nil { | ||
assets = webui.FS | ||
} | ||
// allow iframes from our domains only | ||
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-src | ||
w.Header().Set("Content-Security-Policy", "frame-src 'self' https://traefik.io https://*.traefik.io;") | ||
http.FileServer(http.FS(assets)).ServeHTTP(w, r) | ||
} | ||
|
||
func safePrefix(req *http.Request) string { | ||
prefix := req.Header.Get("X-Forwarded-Prefix") | ||
if prefix == "" { | ||
return "" | ||
} | ||
|
||
parse, err := url.Parse(prefix) | ||
if err != nil { | ||
return "" | ||
} | ||
|
||
if parse.Host != "" { | ||
return "" | ||
} | ||
|
||
return parse.Path | ||
} |
Oops, something went wrong.