Skip to content

Commit

Permalink
fix custom server return URL decoding
Browse files Browse the repository at this point in the history
Previously the form escaped the return URL twice,
preventing it from working.
  • Loading branch information
paskal authored and umputun committed Jan 15, 2023
1 parent c3360c6 commit e13746b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions _example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
## build and try

- run `go run main.go`
- open route: http://127.0.0.1:8080/open
- web application - http://127.0.0.1:8080/web
- open route: http://localhost:8080/open
- web application - http://localhost:8080/web

## parameters

Expand Down
2 changes: 1 addition & 1 deletion provider/custom_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (c *CustomServer) handleAuthorize(w http.ResponseWriter, r *http.Request) {
return
}

formData := struct{ Query string }{Query: r.URL.RawQuery}
formData := struct{ Query template.URL }{Query: template.URL(r.URL.RawQuery)} //nolint:gosec // query is safe

if err := userLoginTmpl.Execute(w, formData); err != nil {
c.Logf("[WARN] can't write, %s", err)
Expand Down
2 changes: 1 addition & 1 deletion provider/dev_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (d *DevAuthServer) Run(ctx context.Context) { // nolint (gocyclo)

// first time it will be called without username and will ask for one
if !d.Automatic && (r.ParseForm() != nil || r.Form.Get("username") == "") {
formData := struct{ Query template.URL }{Query: template.URL(r.URL.RawQuery)} //nolint:gosec // query is safes
formData := struct{ Query template.URL }{Query: template.URL(r.URL.RawQuery)} //nolint:gosec // query is safe
if err = userFormTmpl.Execute(w, formData); err != nil {
d.Logf("[WARN] can't write, %s", err)
}
Expand Down

0 comments on commit e13746b

Please sign in to comment.