3 Commits

Author SHA1 Message Date
7e57190724 Add output of client certificate 2025-02-17 15:12:04 +01:00
b49779da68 feat: add issue template 2025-01-21 10:08:04 +01:00
4c339e1ec6 chore(ci): upgrade go to v1.23 and linter 2025-01-21 10:02:04 +01:00
9 changed files with 124 additions and 27 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

@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
GO_VERSION: stable GO_VERSION: stable
GOLANGCI_LINT_VERSION: v1.58.0 GOLANGCI_LINT_VERSION: v1.63.4
CGO_ENABLED: 0 CGO_ENABLED: 0
steps: steps:

View File

@ -52,30 +52,18 @@ linters-settings:
linters: linters:
enable-all: true enable-all: true
disable: 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) - rowserrcheck # not relevant (SQL)
- sqlclosecheck # not relevant (SQL) - sqlclosecheck # not relevant (SQL)
- cyclop # duplicate of gocyclo - cyclop # duplicate of gocyclo
- dupl - dupl
- exhaustive - exhaustive
- exhaustruct - exhaustruct
- exportloopref
- forbidigo - forbidigo
- gochecknoglobals - gochecknoglobals
- gochecknoinits - gochecknoinits
- err113 - err113
- mnd - mnd
- gomnd
- gosec - gosec
- lll - lll
- nilnil - nilnil

14
app.go
View File

@ -85,8 +85,9 @@ func main() {
} }
server := &http.Server{ server := &http.Server{
Addr: ":" + port, Addr: ":" + port,
Handler: mux, TLSConfig: &tls.Config{ClientAuth: tls.RequestClientCert},
Handler: mux,
} }
if ca != "" { if ca != "" {
@ -159,7 +160,7 @@ func echoHandler(w http.ResponseWriter, r *http.Request) {
func printBinary(s []byte) { func printBinary(s []byte) {
fmt.Printf("Received b:") fmt.Printf("Received b:")
for n := 0; n < len(s); n++ { for n := range s {
fmt.Printf("%d,", s[n]) fmt.Printf("%d,", s[n])
} }
fmt.Printf("\n") fmt.Printf("\n")
@ -230,6 +231,13 @@ func whoamiHandler(w http.ResponseWriter, r *http.Request) {
} }
_, _ = fmt.Fprintln(w, "RemoteAddr:", r.RemoteAddr) _, _ = 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 { if err := r.Write(w); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
return return

View File

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

6
go.mod
View File

@ -1,7 +1,5 @@
module github.com/traefik/whoami module github.com/traefik/whoami
go 1.21 go 1.23
require github.com/gorilla/websocket v1.5.1 require github.com/gorilla/websocket v1.5.3
require golang.org/x/net v0.25.0 // indirect

6
go.sum
View File

@ -1,4 +1,2 @@
github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=