Skip to content

Commit

Permalink
basic auth realm param (#715)
Browse files Browse the repository at this point in the history
* test for quoted realm param value

* fix: quoted realm param value

* changelog entry
  • Loading branch information
johakoch authored and Johannes Koch committed Feb 13, 2023
1 parent 659cf60 commit be46a07
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
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.
* url scheme while using the [`tls` block](https://docs.couper.io/configuration/block/server_tls) ([#703](https://github.com/avenga/couper/issues/703))
* For [OIDC](https://docs.couper.io/configuration/block/oidc), trying to request userinfo from a non-existing (not required, though recommended) userinfo endpoint ([#709](https://github.com/avenga/couper/pull/709))
* Some `..._file` attributes missing for path absolutizing ([#713](https://github.com/avenga/couper/pull/713))
* `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

0 comments on commit be46a07

Please sign in to comment.