6 Commits

12 changed files with 146 additions and 45 deletions

72
.github/ISSUE_TEMPLATE/bug_report.yml vendored Normal file
View File

@ -0,0 +1,72 @@
name: Bug Report
description: Create a report to help us improve.
body:
- type: checkboxes
id: terms
attributes:
label: Welcome!
description: |
The issue tracker is for reporting bugs and feature requests only.
All new/updated issues are triaged regularly by the maintainers.
All issues closed by a bot are subsequently double-checked by the maintainers.
DO NOT FILE ISSUES FOR GENERAL SUPPORT QUESTIONS.
options:
- label: Yes, I've searched similar issues on [GitHub](https://github.com/traefik/whoami/issues) and didn't find any.
required: true
- type: textarea
attributes:
label: What did you do?
description: |
How to write a good bug report?
- Respect the issue template as much as possible.
- The title should be short and descriptive.
- Explain the conditions which led you to report this issue: the context.
- The context should lead to something, an idea or a problem that youre facing.
- Remain clear and concise.
- Format your messages to help the reader focus on what matters and understand the structure of your message, use [Markdown syntax](https://help.github.com/articles/github-flavored-markdown)
placeholder: What did you do?
validations:
required: true
- type: textarea
attributes:
label: What were you expecting?
placeholder: What were you expecting?
validations:
required: true
- type: textarea
attributes:
label: What version are you using?
description: |
`latest` is not considered as a valid version.
placeholder: Paste your output here.
validations:
required: true
- type: textarea
attributes:
label: What is your environment & configuration?
description: arguments, toml, provider, platform, ...
placeholder: Add information here.
value: |
```yaml
# (paste your configuration here)
```
Add more configuration information here.
validations:
required: true
- type: textarea
attributes:
label: If applicable, please paste the log output in DEBUG level
description: "`--log.level=DEBUG` switch."
placeholder: Paste your output here.
validations:
required: false

5
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Traefik Community Support
url: https://community.traefik.io/
about: If you have a question, or are looking for advice, please post on our Discuss forum! The community loves to chime in to help. Happy Coding!

View File

@ -0,0 +1,30 @@
name: Feature Request
description: Suggest an idea for this project.
body:
- type: checkboxes
id: terms
attributes:
label: Welcome!
description: |
The issue tracker is for reporting bugs and feature requests only.
DO NOT FILE ISSUES FOR GENERAL SUPPORT QUESTIONS.
options:
- label: Yes, I've searched similar issues on [GitHub](https://github.com/traefik/whoami/issues) and didn't find any.
required: true
- type: textarea
attributes:
label: What did you expect to see?
description: |
How to write a good issue?
- Respect the issue template as much as possible.
- The title should be short and descriptive.
- Explain the conditions which led you to report this issue: the context.
- The context should lead to something, an idea or a problem that youre facing.
- Remain clear and concise.
- Format your messages to help the reader focus on what matters and understand the structure of your message, use [Markdown syntax](https://help.github.com/articles/github-flavored-markdown)
placeholder: What did you expect to see?
validations:
required: true

View File

@ -12,21 +12,21 @@ jobs:
name: Main Process
runs-on: ubuntu-latest
env:
GO_VERSION: '1.20'
GOLANGCI_LINT_VERSION: v1.53.3
GO_VERSION: stable
GOLANGCI_LINT_VERSION: v1.63.4
CGO_ENABLED: 0
steps:
# https://github.com/marketplace/actions/checkout
- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
# https://github.com/marketplace/actions/setup-go-environment
- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

View File

@ -15,17 +15,17 @@ jobs:
strategy:
matrix:
go-version: [ 1.19, 1.x ]
go-version: [ stable, oldstable ]
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
# https://github.com/marketplace/actions/checkout
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
# https://github.com/marketplace/actions/setup-go-environment
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

View File

@ -9,47 +9,47 @@ jobs:
name: Release Process
runs-on: ubuntu-latest
env:
GO_VERSION: '1.20'
GO_VERSION: stable
CGO_ENABLED: 0
steps:
# https://github.com/marketplace/actions/checkout
- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
# https://github.com/marketplace/actions/setup-go-environment
- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: dockerhub-login
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: ghcr-login
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
registry: ghcr.io
username: traefiker
password: ${{ secrets.GHCR_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
# https://goreleaser.com/ci/actions/
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --rm-dist
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_REPO }}

View File

@ -1,6 +1,5 @@
run:
timeout: 2m
skip-files: []
linters-settings:
govet:
@ -53,29 +52,18 @@ linters-settings:
linters:
enable-all: true
disable:
- deadcode # deprecated
- exhaustivestruct # deprecated
- golint # deprecated
- ifshort # deprecated
- interfacer # deprecated
- maligned # deprecated
- nosnakecase # deprecated
- scopelint # deprecated
- scopelint # deprecated
- structcheck # deprecated
- varcheck # deprecated
- execinquery # not relevant (SQL)
- rowserrcheck # not relevant (SQL)
- sqlclosecheck # not relevant (SQL)
- cyclop # duplicate of gocyclo
- dupl
- exhaustive
- exhaustruct
- exportloopref
- forbidigo
- gochecknoglobals
- gochecknoinits
- goerr113
- gomnd
- err113
- mnd
- gosec
- lll
- nilnil
@ -90,7 +78,7 @@ linters:
issues:
exclude-use-default: false
max-per-linter: 0
max-issues-per-linter: 0
max-same-issues: 0
exclude:
- 'package-comments: should have a package comment'

View File

@ -20,7 +20,7 @@ The optional `env` query parameter can be set to `true` to add the environment v
#### `/api`
Returns the whoami information as JSON.
Returns the whoami information (and some extra information) as JSON.
The optional `env` query parameter can be set to `true` to add the environment variables to the response.

16
app.go
View File

@ -31,7 +31,7 @@ const (
var upgrader = websocket.Upgrader{
ReadBufferSize: 1024,
WriteBufferSize: 1024,
CheckOrigin: func(r *http.Request) bool {
CheckOrigin: func(_ *http.Request) bool {
return true
},
}
@ -86,10 +86,11 @@ func main() {
server := &http.Server{
Addr: ":" + port,
TLSConfig: &tls.Config{ClientAuth: tls.RequestClientCert},
Handler: mux,
}
if len(ca) > 0 {
if ca != "" {
server.TLSConfig = setupMutualTLS(ca)
}
@ -159,7 +160,7 @@ func echoHandler(w http.ResponseWriter, r *http.Request) {
func printBinary(s []byte) {
fmt.Printf("Received b:")
for n := 0; n < len(s); n++ {
for n := range s {
fmt.Printf("%d,", s[n])
}
fmt.Printf("\n")
@ -211,7 +212,7 @@ func whoamiHandler(w http.ResponseWriter, r *http.Request) {
queryParams := r.URL.Query()
wait := queryParams.Get("wait")
if len(wait) > 0 {
if wait != "" {
duration, err := time.ParseDuration(wait)
if err == nil {
time.Sleep(duration)
@ -230,6 +231,13 @@ func whoamiHandler(w http.ResponseWriter, r *http.Request) {
}
_, _ = fmt.Fprintln(w, "RemoteAddr:", r.RemoteAddr)
if r.TLS != nil {
for i, cert := range r.TLS.PeerCertificates {
_, _ = fmt.Fprintf(w, "Certificate[%d] Subject: %v\n", i, cert.Subject)
}
}
if err := r.Write(w); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return

View File

@ -19,7 +19,6 @@ func Test_contentReader_Read(t *testing.T) {
}
for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
@ -56,7 +55,6 @@ func Test_contentReader_ReadSeek(t *testing.T) {
}
for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()

4
go.mod
View File

@ -1,5 +1,5 @@
module github.com/traefik/whoami
go 1.20
go 1.23
require github.com/gorilla/websocket v1.4.2
require github.com/gorilla/websocket v1.5.3

4
go.sum
View File

@ -1,2 +1,2 @@
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=