Skip to content
This repository was archived by the owner on Nov 24, 2021. It is now read-only.

Commit afc7abe

Browse files
authored
Merge pull request #19 from sambott/www-authenticate
www-authenticate response
2 parents 217ada4 + efea9a0 commit afc7abe

File tree

1,454 files changed

+179720
-141874
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,454 files changed

+179720
-141874
lines changed

Gopkg.lock

Lines changed: 303 additions & 80 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,13 @@
22
name = "github.com/fatih/structs"
33
version = "1.0.0"
44

5-
[[constraint]]
6-
name = "github.com/go-ldap/ldap"
7-
revision = "0776dae456c9f852c74287dfa8475c16401ac9a9"
8-
95
[[constraint]]
106
branch = "master"
117
name = "github.com/hashicorp/go-multierror"
128

139
[[constraint]]
1410
name = "github.com/hashicorp/vault"
15-
version = "0.10.0"
11+
version = "1.1.1"
1612

1713
[prune]
1814
go-tests = true

path_config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ func pathConfig(b *backend) *framework.Path {
3030
},
3131
},
3232
Callbacks: map[logical.Operation]framework.OperationFunc{
33-
logical.CreateOperation: b.pathConfigWrite,
3433
logical.UpdateOperation: b.pathConfigWrite,
34+
logical.CreateOperation: b.pathConfigWrite,
3535
logical.ReadOperation: b.pathConfigRead,
3636
},
3737

path_config_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func TestConfig_ReadWrite(t *testing.T) {
4141
}
4242

4343
req := &logical.Request{
44-
Operation: logical.CreateOperation,
44+
Operation: logical.UpdateOperation,
4545
Path: configPath,
4646
Storage: storage,
4747
Data: data,
@@ -95,7 +95,7 @@ func TestConfig_RejectsBadWrites(t *testing.T) {
9595
func testConfigWriteError(t *testing.T, b logical.Backend, storage logical.Storage,
9696
data map[string]interface{}, e string) {
9797
req := &logical.Request{
98-
Operation: logical.CreateOperation,
98+
Operation: logical.UpdateOperation,
9999
Path: configPath,
100100
Storage: storage,
101101
Data: data,

path_login.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func pathLogin(b *backend) *framework.Path {
2727
},
2828
},
2929
Callbacks: map[logical.Operation]framework.OperationFunc{
30+
logical.ReadOperation: b.pathLoginGet,
3031
logical.UpdateOperation: b.pathLogin,
3132
},
3233
}
@@ -67,6 +68,15 @@ func spnegoKrb5Authenticate(kt keytab.Keytab, sa string, authorization []byte, r
6768
return ok, &creds, err
6869
}
6970

71+
func (b *backend) pathLoginGet(ctx context.Context, req *logical.Request, d *framework.FieldData) (*logical.Response, error) {
72+
return &logical.Response{
73+
Auth: &logical.Auth{},
74+
Headers: map[string][]string{
75+
"www-authenticate": {"Negotiate"},
76+
},
77+
}, logical.CodedError(401, "authentication required")
78+
}
79+
7080
func (b *backend) pathLogin(ctx context.Context, req *logical.Request, d *framework.FieldData) (*logical.Response, error) {
7181
config, err := b.config(ctx, req.Storage)
7282
if err != nil {
@@ -110,7 +120,7 @@ func (b *backend) pathLogin(ctx context.Context, req *logical.Request, d *framew
110120

111121
s := strings.SplitN(authorizationString, " ", 2)
112122
if len(s) != 2 || s[0] != "Negotiate" {
113-
return logical.ErrorResponse("Missing or invalid authorization"), nil
123+
return b.pathLoginGet(ctx, req, d)
114124
}
115125
authorization, err := base64.StdEncoding.DecodeString(s[1])
116126
if err != nil {

path_login_test.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func setupTestBackend(t *testing.T) (logical.Backend, logical.Storage) {
2020
}
2121

2222
req := &logical.Request{
23-
Operation: logical.CreateOperation,
23+
Operation: logical.UpdateOperation,
2424
Path: configPath,
2525
Storage: storage,
2626
Data: data,
@@ -66,11 +66,20 @@ func TestLogin(t *testing.T) {
6666
}
6767

6868
resp, err = b.HandleRequest(context.Background(), req)
69-
if err != nil || resp == nil {
69+
if err == nil || resp == nil || resp.IsError() {
7070
t.Fatalf("err: %s resp: %#v\n", err, resp)
7171
}
72-
if !resp.IsError() && !strings.HasPrefix(resp.Error().Error(), "Missing or invalid authorization") {
73-
t.Fatalf("err: %s resp: %#v\n", err, resp)
72+
73+
if e, ok := err.(logical.HTTPCodedError); !ok || e.Code() != 401 {
74+
t.Fatalf("no 401 thrown. err: %s resp: %#v\n", err, resp)
75+
}
76+
77+
if headerVal, ok := resp.Headers["www-authenticate"]; ok {
78+
if strings.Compare(headerVal[0], "Negotiate") != 0 {
79+
t.Fatalf("www-authenticate not set to Negotiate. err: %s resp: %#v\n", err, resp)
80+
}
81+
} else {
82+
t.Fatalf("no www-authenticate header. err: %s resp: %#v\n", err, resp)
7483
}
7584
}
7685

vendor/github.com/Azure/go-ansiterm/LICENSE

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/Azure/go-ansiterm/README.md

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/Azure/go-ansiterm/constants.go

Lines changed: 188 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/Azure/go-ansiterm/context.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)