Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

basic auth realm param #715

Merged
merged 3 commits into from
Feb 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Unreleased changes are available as `avenga/couper:edge` container.

* **Fixed**
* Erroneously sending an empty [`Server-Timing` header](https://docs.couper.io/configuration/command-line#oberservation-options) ([#700](https://github.com/avenga/couper/pull/700))
* `WWW-Authenticate` header `realm` param value for [`basic_auth`](https://docs.couper.io/configuration/block/basic_auth) ([#715](https://github.com/avenga/couper/pull/715))

---

Expand Down
4 changes: 3 additions & 1 deletion config/ac_basic_auth.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package config

import (
"fmt"

"github.com/hashicorp/hcl/v2"
"github.com/hashicorp/hcl/v2/gohcl"
"github.com/hashicorp/hcl/v2/hclsyntax"
Expand Down Expand Up @@ -54,7 +56,7 @@ func (b *BasicAuth) Schema(inline bool) *hcl.BodySchema {
func (b *BasicAuth) DefaultErrorHandler() *ErrorHandler {
wwwAuthenticateValue := "Basic"
if b.Realm != "" {
wwwAuthenticateValue += " realm=" + b.Realm
wwwAuthenticateValue += fmt.Sprintf(" realm=%q", b.Realm)
}
return &ErrorHandler{
Kinds: []string{"basic_auth"},
Expand Down
4 changes: 2 additions & 2 deletions server/http_error_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ func TestAccessControl_ErrorHandler_BasicAuth_Default(t *testing.T) {
return
}

if www := res.Header.Get("www-authenticate"); www != "Basic realm=protected" {
t.Errorf("Expected header: www-authenticate with value: %s, got: %s", "Basic realm=protected", www)
if www := res.Header.Get("www-authenticate"); www != `Basic realm="protected"` {
t.Errorf("Expected header: www-authenticate with value: %s, got: %s", `Basic realm="protected"`, www)
}
}

Expand Down