Update plugin deps to include context changes (#3765)
* Update plugin deps to include context changes * Fix tests
This commit is contained in:
parent
ecb2005dae
commit
64da50c27c
|
@ -1,6 +1,7 @@
|
|||
package rabbitmq
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
@ -130,7 +131,7 @@ func testAccStepReadCreds(t *testing.T, b logical.Backend, name string) logicalt
|
|||
t.Fatalf("unable to list vhosts with generated credentials: %s", err)
|
||||
}
|
||||
|
||||
resp, err = b.HandleRequest(&logical.Request{
|
||||
resp, err = b.HandleRequest(context.Background(), &logical.Request{
|
||||
Operation: logical.RevokeOperation,
|
||||
Secret: &logical.Secret{
|
||||
InternalData: map[string]interface{}{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package rabbitmq
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
@ -27,7 +28,7 @@ func TestBackend_config_lease_RU(t *testing.T) {
|
|||
Storage: config.StorageView,
|
||||
Data: configData,
|
||||
}
|
||||
resp, err = b.HandleRequest(configReq)
|
||||
resp, err = b.HandleRequest(context.Background(), configReq)
|
||||
if err != nil || (resp != nil && resp.IsError()) {
|
||||
t.Fatalf("bad: resp: %#v\nerr:%s", resp, err)
|
||||
}
|
||||
|
@ -36,7 +37,7 @@ func TestBackend_config_lease_RU(t *testing.T) {
|
|||
}
|
||||
|
||||
configReq.Operation = logical.ReadOperation
|
||||
resp, err = b.HandleRequest(configReq)
|
||||
resp, err = b.HandleRequest(context.Background(), configReq)
|
||||
if err != nil || (resp != nil && resp.IsError()) {
|
||||
t.Fatalf("bad: resp: %#v\nerr:%s", resp, err)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"os"
|
||||
|
@ -160,7 +161,7 @@ func TestGenerateRoot_OTP(t *testing.T) {
|
|||
req := logical.TestRequest(t, logical.ReadOperation, "lookup-self")
|
||||
req.ClientToken = token
|
||||
|
||||
resp, err := ts.HandleRequest(req)
|
||||
resp, err := ts.HandleRequest(context.Background(), req)
|
||||
if err != nil {
|
||||
t.Fatalf("error running token lookup-self: %v", err)
|
||||
}
|
||||
|
@ -272,7 +273,7 @@ func TestGenerateRoot_PGP(t *testing.T) {
|
|||
req := logical.TestRequest(t, logical.ReadOperation, "lookup-self")
|
||||
req.ClientToken = token
|
||||
|
||||
resp, err := ts.HandleRequest(req)
|
||||
resp, err := ts.HandleRequest(context.Background(), req)
|
||||
if err != nil {
|
||||
t.Fatalf("error running token lookup-self: %v", err)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"os"
|
||||
"sort"
|
||||
|
@ -267,7 +268,7 @@ func TestRekey_init_pgp(t *testing.T) {
|
|||
backupVals := &backupStruct{}
|
||||
|
||||
req := logical.TestRequest(t, logical.ReadOperation, "rekey/backup")
|
||||
resp, err := sysBackend.HandleRequest(req)
|
||||
resp, err := sysBackend.HandleRequest(context.Background(), req)
|
||||
if err != nil {
|
||||
t.Fatalf("error running backed-up unseal key fetch: %v", err)
|
||||
}
|
||||
|
@ -286,12 +287,12 @@ func TestRekey_init_pgp(t *testing.T) {
|
|||
|
||||
// Now delete and try again; the values should be inaccessible
|
||||
req = logical.TestRequest(t, logical.DeleteOperation, "rekey/backup")
|
||||
resp, err = sysBackend.HandleRequest(req)
|
||||
resp, err = sysBackend.HandleRequest(context.Background(), req)
|
||||
if err != nil {
|
||||
t.Fatalf("error running backed-up unseal key delete: %v", err)
|
||||
}
|
||||
req = logical.TestRequest(t, logical.ReadOperation, "rekey/backup")
|
||||
resp, err = sysBackend.HandleRequest(req)
|
||||
resp, err = sysBackend.HandleRequest(context.Background(), req)
|
||||
if err != nil {
|
||||
t.Fatalf("error running backed-up unseal key fetch: %v", err)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package mfa
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/logical"
|
||||
|
@ -43,8 +44,7 @@ func testPathLogin() *framework.Path {
|
|||
}
|
||||
}
|
||||
|
||||
func testPathLoginHandler(
|
||||
req *logical.Request, d *framework.FieldData) (*logical.Response, error) {
|
||||
func testPathLoginHandler(ctx context.Context, req *logical.Request, d *framework.FieldData) (*logical.Response, error) {
|
||||
username := d.Get("username").(string)
|
||||
|
||||
return &logical.Response{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package framework
|
||||
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
|
@ -42,7 +43,7 @@ func TestBackend_impl(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestBackendHandleRequest(t *testing.T) {
|
||||
callback := func(req *logical.Request, data *FieldData) (*logical.Response, error) {
|
||||
callback := func(ctx context.Context, req *logical.Request, data *FieldData) (*logical.Response, error) {
|
||||
return &logical.Response{
|
||||
Data: map[string]interface{}{
|
||||
"value": data.Get("value"),
|
||||
|
@ -64,7 +65,7 @@ func TestBackendHandleRequest(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
resp, err := b.HandleRequest(&logical.Request{
|
||||
resp, err := b.HandleRequest(context.Background(), &logical.Request{
|
||||
Operation: logical.ReadOperation,
|
||||
Path: "foo/bar",
|
||||
Data: map[string]interface{}{"value": "42"},
|
||||
|
@ -78,7 +79,7 @@ func TestBackendHandleRequest(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestBackendHandleRequest_badwrite(t *testing.T) {
|
||||
callback := func(req *logical.Request, data *FieldData) (*logical.Response, error) {
|
||||
callback := func(ctx context.Context, req *logical.Request, data *FieldData) (*logical.Response, error) {
|
||||
return &logical.Response{
|
||||
Data: map[string]interface{}{
|
||||
"value": data.Get("value").(bool),
|
||||
|
@ -100,7 +101,7 @@ func TestBackendHandleRequest_badwrite(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
_, err := b.HandleRequest(&logical.Request{
|
||||
_, err := b.HandleRequest(context.Background(), &logical.Request{
|
||||
Operation: logical.UpdateOperation,
|
||||
Path: "foo/bar",
|
||||
Data: map[string]interface{}{"value": "3false3"},
|
||||
|
@ -113,7 +114,7 @@ func TestBackendHandleRequest_badwrite(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestBackendHandleRequest_404(t *testing.T) {
|
||||
callback := func(req *logical.Request, data *FieldData) (*logical.Response, error) {
|
||||
callback := func(ctx context.Context, req *logical.Request, data *FieldData) (*logical.Response, error) {
|
||||
return &logical.Response{
|
||||
Data: map[string]interface{}{
|
||||
"value": data.Get("value"),
|
||||
|
@ -135,7 +136,7 @@ func TestBackendHandleRequest_404(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
_, err := b.HandleRequest(&logical.Request{
|
||||
_, err := b.HandleRequest(context.Background(), &logical.Request{
|
||||
Operation: logical.ReadOperation,
|
||||
Path: "foo/baz",
|
||||
Data: map[string]interface{}{"value": "84"},
|
||||
|
@ -159,7 +160,7 @@ func TestBackendHandleRequest_help(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
resp, err := b.HandleRequest(&logical.Request{
|
||||
resp, err := b.HandleRequest(context.Background(), &logical.Request{
|
||||
Operation: logical.HelpOperation,
|
||||
Path: "foo/bar",
|
||||
Data: map[string]interface{}{"value": "42"},
|
||||
|
@ -177,7 +178,7 @@ func TestBackendHandleRequest_helpRoot(t *testing.T) {
|
|||
Help: "42",
|
||||
}
|
||||
|
||||
resp, err := b.HandleRequest(&logical.Request{
|
||||
resp, err := b.HandleRequest(context.Background(), &logical.Request{
|
||||
Operation: logical.HelpOperation,
|
||||
Path: "",
|
||||
})
|
||||
|
@ -192,7 +193,7 @@ func TestBackendHandleRequest_helpRoot(t *testing.T) {
|
|||
func TestBackendHandleRequest_renewAuth(t *testing.T) {
|
||||
b := &Backend{}
|
||||
|
||||
resp, err := b.HandleRequest(logical.RenewAuthRequest("/foo", &logical.Auth{}, nil))
|
||||
resp, err := b.HandleRequest(context.Background(), logical.RenewAuthRequest("/foo", &logical.Auth{}, nil))
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
@ -203,7 +204,7 @@ func TestBackendHandleRequest_renewAuth(t *testing.T) {
|
|||
|
||||
func TestBackendHandleRequest_renewAuthCallback(t *testing.T) {
|
||||
var called uint32
|
||||
callback := func(*logical.Request, *FieldData) (*logical.Response, error) {
|
||||
callback := func(context.Context, *logical.Request, *FieldData) (*logical.Response, error) {
|
||||
atomic.AddUint32(&called, 1)
|
||||
return nil, nil
|
||||
}
|
||||
|
@ -212,7 +213,7 @@ func TestBackendHandleRequest_renewAuthCallback(t *testing.T) {
|
|||
AuthRenew: callback,
|
||||
}
|
||||
|
||||
_, err := b.HandleRequest(logical.RenewAuthRequest("/foo", &logical.Auth{}, nil))
|
||||
_, err := b.HandleRequest(context.Background(), logical.RenewAuthRequest("/foo", &logical.Auth{}, nil))
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
@ -222,7 +223,7 @@ func TestBackendHandleRequest_renewAuthCallback(t *testing.T) {
|
|||
}
|
||||
func TestBackendHandleRequest_renew(t *testing.T) {
|
||||
var called uint32
|
||||
callback := func(*logical.Request, *FieldData) (*logical.Response, error) {
|
||||
callback := func(context.Context, *logical.Request, *FieldData) (*logical.Response, error) {
|
||||
atomic.AddUint32(&called, 1)
|
||||
return nil, nil
|
||||
}
|
||||
|
@ -235,7 +236,7 @@ func TestBackendHandleRequest_renew(t *testing.T) {
|
|||
Secrets: []*Secret{secret},
|
||||
}
|
||||
|
||||
_, err := b.HandleRequest(logical.RenewRequest("/foo", secret.Response(nil, nil).Secret, nil))
|
||||
_, err := b.HandleRequest(context.Background(), logical.RenewRequest("/foo", secret.Response(nil, nil).Secret, nil))
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
@ -262,7 +263,7 @@ func TestBackendHandleRequest_renewExtend(t *testing.T) {
|
|||
req := logical.RenewRequest("/foo", secret.Response(nil, nil).Secret, nil)
|
||||
req.Secret.IssueTime = time.Now()
|
||||
req.Secret.Increment = 1 * time.Hour
|
||||
resp, err := b.HandleRequest(req)
|
||||
resp, err := b.HandleRequest(context.Background(), req)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
@ -277,7 +278,7 @@ func TestBackendHandleRequest_renewExtend(t *testing.T) {
|
|||
|
||||
func TestBackendHandleRequest_revoke(t *testing.T) {
|
||||
var called uint32
|
||||
callback := func(*logical.Request, *FieldData) (*logical.Response, error) {
|
||||
callback := func(context.Context, *logical.Request, *FieldData) (*logical.Response, error) {
|
||||
atomic.AddUint32(&called, 1)
|
||||
return nil, nil
|
||||
}
|
||||
|
@ -290,7 +291,7 @@ func TestBackendHandleRequest_revoke(t *testing.T) {
|
|||
Secrets: []*Secret{secret},
|
||||
}
|
||||
|
||||
_, err := b.HandleRequest(logical.RevokeRequest("/foo", secret.Response(nil, nil).Secret, nil))
|
||||
_, err := b.HandleRequest(context.Background(), logical.RevokeRequest("/foo", secret.Response(nil, nil).Secret, nil))
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
@ -321,7 +322,7 @@ func TestBackendHandleRequest_rollback(t *testing.T) {
|
|||
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
|
||||
_, err := b.HandleRequest(&logical.Request{
|
||||
_, err := b.HandleRequest(context.Background(), &logical.Request{
|
||||
Operation: logical.RollbackOperation,
|
||||
Path: "",
|
||||
Storage: storage,
|
||||
|
@ -354,7 +355,7 @@ func TestBackendHandleRequest_rollbackMinAge(t *testing.T) {
|
|||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
_, err := b.HandleRequest(&logical.Request{
|
||||
_, err := b.HandleRequest(context.Background(), &logical.Request{
|
||||
Operation: logical.RollbackOperation,
|
||||
Path: "",
|
||||
Storage: storage,
|
||||
|
@ -368,7 +369,7 @@ func TestBackendHandleRequest_rollbackMinAge(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestBackendHandleRequest_unsupportedOperation(t *testing.T) {
|
||||
callback := func(req *logical.Request, data *FieldData) (*logical.Response, error) {
|
||||
callback := func(ctx context.Context, req *logical.Request, data *FieldData) (*logical.Response, error) {
|
||||
return &logical.Response{
|
||||
Data: map[string]interface{}{
|
||||
"value": data.Get("value"),
|
||||
|
@ -390,7 +391,7 @@ func TestBackendHandleRequest_unsupportedOperation(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
_, err := b.HandleRequest(&logical.Request{
|
||||
_, err := b.HandleRequest(context.Background(), &logical.Request{
|
||||
Operation: logical.UpdateOperation,
|
||||
Path: "foo/bar",
|
||||
Data: map[string]interface{}{"value": "84"},
|
||||
|
@ -401,7 +402,7 @@ func TestBackendHandleRequest_unsupportedOperation(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestBackendHandleRequest_urlPriority(t *testing.T) {
|
||||
callback := func(req *logical.Request, data *FieldData) (*logical.Response, error) {
|
||||
callback := func(ctx context.Context, req *logical.Request, data *FieldData) (*logical.Response, error) {
|
||||
return &logical.Response{
|
||||
Data: map[string]interface{}{
|
||||
"value": data.Get("value"),
|
||||
|
@ -423,7 +424,7 @@ func TestBackendHandleRequest_urlPriority(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
resp, err := b.HandleRequest(&logical.Request{
|
||||
resp, err := b.HandleRequest(context.Background(), &logical.Request{
|
||||
Operation: logical.ReadOperation,
|
||||
Path: "foo/42",
|
||||
Data: map[string]interface{}{"value": "84"},
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package framework
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
@ -97,7 +98,7 @@ func TestLeaseExtend(t *testing.T) {
|
|||
}
|
||||
|
||||
callback := LeaseExtend(tc.BackendDefault, tc.BackendMax, testSysView)
|
||||
resp, err := callback(req, nil)
|
||||
resp, err := callback(context.Background(), req, nil)
|
||||
if (err != nil) != tc.Error {
|
||||
t.Fatalf("bad: %s\nerr: %s", name, err)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package framework
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/helper/salt"
|
||||
|
@ -13,7 +14,7 @@ func TestPathMap(t *testing.T) {
|
|||
var b logical.Backend = &Backend{Paths: p.Paths()}
|
||||
|
||||
// Write via HTTP
|
||||
_, err := b.HandleRequest(&logical.Request{
|
||||
_, err := b.HandleRequest(context.Background(), &logical.Request{
|
||||
Operation: logical.UpdateOperation,
|
||||
Path: "map/foo/a",
|
||||
Data: map[string]interface{}{
|
||||
|
@ -26,7 +27,7 @@ func TestPathMap(t *testing.T) {
|
|||
}
|
||||
|
||||
// Read via HTTP
|
||||
resp, err := b.HandleRequest(&logical.Request{
|
||||
resp, err := b.HandleRequest(context.Background(), &logical.Request{
|
||||
Operation: logical.ReadOperation,
|
||||
Path: "map/foo/a",
|
||||
Storage: storage,
|
||||
|
@ -66,7 +67,7 @@ func TestPathMap(t *testing.T) {
|
|||
}
|
||||
|
||||
// LIST via HTTP
|
||||
resp, err = b.HandleRequest(&logical.Request{
|
||||
resp, err = b.HandleRequest(context.Background(), &logical.Request{
|
||||
Operation: logical.ListOperation,
|
||||
Path: "map/foo/",
|
||||
Storage: storage,
|
||||
|
@ -80,7 +81,7 @@ func TestPathMap(t *testing.T) {
|
|||
}
|
||||
|
||||
// Delete via HTTP
|
||||
resp, err = b.HandleRequest(&logical.Request{
|
||||
resp, err = b.HandleRequest(context.Background(), &logical.Request{
|
||||
Operation: logical.DeleteOperation,
|
||||
Path: "map/foo/a",
|
||||
Storage: storage,
|
||||
|
@ -93,7 +94,7 @@ func TestPathMap(t *testing.T) {
|
|||
}
|
||||
|
||||
// Re-read via HTTP
|
||||
resp, err = b.HandleRequest(&logical.Request{
|
||||
resp, err = b.HandleRequest(context.Background(), &logical.Request{
|
||||
Operation: logical.ReadOperation,
|
||||
Path: "map/foo/a",
|
||||
Storage: storage,
|
||||
|
@ -149,7 +150,7 @@ func TestPathMap_Salted(t *testing.T) {
|
|||
var b logical.Backend = &Backend{Paths: p.Paths()}
|
||||
|
||||
// Write via HTTP
|
||||
_, err = b.HandleRequest(&logical.Request{
|
||||
_, err = b.HandleRequest(context.Background(), &logical.Request{
|
||||
Operation: logical.UpdateOperation,
|
||||
Path: "map/foo/a",
|
||||
Data: map[string]interface{}{
|
||||
|
@ -181,7 +182,7 @@ func TestPathMap_Salted(t *testing.T) {
|
|||
}
|
||||
|
||||
// Read via HTTP
|
||||
resp, err := b.HandleRequest(&logical.Request{
|
||||
resp, err := b.HandleRequest(context.Background(), &logical.Request{
|
||||
Operation: logical.ReadOperation,
|
||||
Path: "map/foo/a",
|
||||
Storage: storage,
|
||||
|
@ -221,7 +222,7 @@ func TestPathMap_Salted(t *testing.T) {
|
|||
}
|
||||
|
||||
// Delete via HTTP
|
||||
resp, err = b.HandleRequest(&logical.Request{
|
||||
resp, err = b.HandleRequest(context.Background(), &logical.Request{
|
||||
Operation: logical.DeleteOperation,
|
||||
Path: "map/foo/a",
|
||||
Storage: storage,
|
||||
|
@ -234,7 +235,7 @@ func TestPathMap_Salted(t *testing.T) {
|
|||
}
|
||||
|
||||
// Re-read via HTTP
|
||||
resp, err = b.HandleRequest(&logical.Request{
|
||||
resp, err = b.HandleRequest(context.Background(), &logical.Request{
|
||||
Operation: logical.ReadOperation,
|
||||
Path: "map/foo/a",
|
||||
Storage: storage,
|
||||
|
@ -265,7 +266,7 @@ func TestPathMap_Salted(t *testing.T) {
|
|||
t.Fatal("err: %v", err)
|
||||
}
|
||||
// A read should transparently upgrade
|
||||
resp, err = b.HandleRequest(&logical.Request{
|
||||
resp, err = b.HandleRequest(context.Background(), &logical.Request{
|
||||
Operation: logical.ReadOperation,
|
||||
Path: "map/foo/b",
|
||||
Storage: storage,
|
||||
|
@ -304,7 +305,7 @@ func TestPathMap_SaltFunc(t *testing.T) {
|
|||
var b logical.Backend = &Backend{Paths: p.Paths()}
|
||||
|
||||
// Write via HTTP
|
||||
_, err = b.HandleRequest(&logical.Request{
|
||||
_, err = b.HandleRequest(context.Background(), &logical.Request{
|
||||
Operation: logical.UpdateOperation,
|
||||
Path: "map/foo/a",
|
||||
Data: map[string]interface{}{
|
||||
|
@ -336,7 +337,7 @@ func TestPathMap_SaltFunc(t *testing.T) {
|
|||
}
|
||||
|
||||
// Read via HTTP
|
||||
resp, err := b.HandleRequest(&logical.Request{
|
||||
resp, err := b.HandleRequest(context.Background(), &logical.Request{
|
||||
Operation: logical.ReadOperation,
|
||||
Path: "map/foo/a",
|
||||
Storage: storage,
|
||||
|
@ -376,7 +377,7 @@ func TestPathMap_SaltFunc(t *testing.T) {
|
|||
}
|
||||
|
||||
// Delete via HTTP
|
||||
resp, err = b.HandleRequest(&logical.Request{
|
||||
resp, err = b.HandleRequest(context.Background(), &logical.Request{
|
||||
Operation: logical.DeleteOperation,
|
||||
Path: "map/foo/a",
|
||||
Storage: storage,
|
||||
|
@ -389,7 +390,7 @@ func TestPathMap_SaltFunc(t *testing.T) {
|
|||
}
|
||||
|
||||
// Re-read via HTTP
|
||||
resp, err = b.HandleRequest(&logical.Request{
|
||||
resp, err = b.HandleRequest(context.Background(), &logical.Request{
|
||||
Operation: logical.ReadOperation,
|
||||
Path: "map/foo/a",
|
||||
Storage: storage,
|
||||
|
@ -420,7 +421,7 @@ func TestPathMap_SaltFunc(t *testing.T) {
|
|||
t.Fatal("err: %v", err)
|
||||
}
|
||||
// A read should transparently upgrade
|
||||
resp, err = b.HandleRequest(&logical.Request{
|
||||
resp, err = b.HandleRequest(context.Background(), &logical.Request{
|
||||
Operation: logical.ReadOperation,
|
||||
Path: "map/foo/b",
|
||||
Storage: storage,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package framework
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/logical"
|
||||
|
@ -20,7 +21,7 @@ func TestPathStruct(t *testing.T) {
|
|||
var b logical.Backend = &Backend{Paths: p.Paths()}
|
||||
|
||||
// Write via HTTP
|
||||
_, err := b.HandleRequest(&logical.Request{
|
||||
_, err := b.HandleRequest(context.Background(), &logical.Request{
|
||||
Operation: logical.UpdateOperation,
|
||||
Path: "bar",
|
||||
Data: map[string]interface{}{
|
||||
|
@ -33,7 +34,7 @@ func TestPathStruct(t *testing.T) {
|
|||
}
|
||||
|
||||
// Read via HTTP
|
||||
resp, err := b.HandleRequest(&logical.Request{
|
||||
resp, err := b.HandleRequest(context.Background(), &logical.Request{
|
||||
Operation: logical.ReadOperation,
|
||||
Path: "bar",
|
||||
Storage: storage,
|
||||
|
@ -55,7 +56,7 @@ func TestPathStruct(t *testing.T) {
|
|||
}
|
||||
|
||||
// Delete via HTTP
|
||||
resp, err = b.HandleRequest(&logical.Request{
|
||||
resp, err = b.HandleRequest(context.Background(), &logical.Request{
|
||||
Operation: logical.DeleteOperation,
|
||||
Path: "bar",
|
||||
Data: nil,
|
||||
|
@ -69,7 +70,7 @@ func TestPathStruct(t *testing.T) {
|
|||
}
|
||||
|
||||
// Re-read via HTTP
|
||||
resp, err = b.HandleRequest(&logical.Request{
|
||||
resp, err = b.HandleRequest(context.Background(), &logical.Request{
|
||||
Operation: logical.ReadOperation,
|
||||
Path: "bar",
|
||||
Storage: storage,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package plugin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
@ -20,7 +21,7 @@ func TestBackendPlugin_HandleRequest(t *testing.T) {
|
|||
b, cleanup := testBackend(t)
|
||||
defer cleanup()
|
||||
|
||||
resp, err := b.HandleRequest(&logical.Request{
|
||||
resp, err := b.HandleRequest(context.Background(), &logical.Request{
|
||||
Operation: logical.CreateOperation,
|
||||
Path: "kv/foo",
|
||||
Data: map[string]interface{}{
|
||||
|
@ -76,7 +77,7 @@ func TestBackendPlugin_HandleExistenceCheck(t *testing.T) {
|
|||
b, cleanup := testBackend(t)
|
||||
defer cleanup()
|
||||
|
||||
checkFound, exists, err := b.HandleExistenceCheck(&logical.Request{
|
||||
checkFound, exists, err := b.HandleExistenceCheck(context.Background(), &logical.Request{
|
||||
Operation: logical.CreateOperation,
|
||||
Path: "kv/foo",
|
||||
Data: map[string]interface{}{"value": "bar"},
|
||||
|
@ -113,7 +114,7 @@ func TestBackendPlugin_InvalidateKey(t *testing.T) {
|
|||
b, cleanup := testBackend(t)
|
||||
defer cleanup()
|
||||
|
||||
resp, err := b.HandleRequest(&logical.Request{
|
||||
resp, err := b.HandleRequest(context.Background(), &logical.Request{
|
||||
Operation: logical.ReadOperation,
|
||||
Path: "internal",
|
||||
})
|
||||
|
@ -126,7 +127,7 @@ func TestBackendPlugin_InvalidateKey(t *testing.T) {
|
|||
|
||||
b.InvalidateKey("internal")
|
||||
|
||||
resp, err = b.HandleRequest(&logical.Request{
|
||||
resp, err = b.HandleRequest(context.Background(), &logical.Request{
|
||||
Operation: logical.ReadOperation,
|
||||
Path: "internal",
|
||||
})
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package vault
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
@ -39,7 +40,7 @@ func mockRollback(t *testing.T) (*RollbackManager, *NoopBackend) {
|
|||
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
|
||||
rb := NewRollbackManager(logger, mountsFunc, router)
|
||||
rb := NewRollbackManager(logger, mountsFunc, router, context.Background())
|
||||
rb.period = 10 * time.Millisecond
|
||||
return rb, backend
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package gcpauth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
|
@ -38,7 +39,7 @@ If not specified, will use the OAuth2 library default. Useful for testing.`,
|
|||
}
|
||||
}
|
||||
|
||||
func (b *GcpAuthBackend) pathConfigWrite(req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
func (b *GcpAuthBackend) pathConfigWrite(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
config, err := b.config(req.Storage)
|
||||
|
||||
if err != nil {
|
||||
|
@ -63,7 +64,7 @@ func (b *GcpAuthBackend) pathConfigWrite(req *logical.Request, data *framework.F
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
func (b *GcpAuthBackend) pathConfigRead(req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
func (b *GcpAuthBackend) pathConfigRead(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
config, err := b.config(req.Storage)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package gcpauth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
@ -49,7 +50,7 @@ GCE identity metadata token ('iam', 'gce' roles).`,
|
|||
}
|
||||
}
|
||||
|
||||
func (b *GcpAuthBackend) pathLogin(req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
func (b *GcpAuthBackend) pathLogin(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
loginInfo, err := b.parseAndValidateJwt(req, data)
|
||||
if err != nil {
|
||||
return logical.ErrorResponse(err.Error()), nil
|
||||
|
@ -66,7 +67,7 @@ func (b *GcpAuthBackend) pathLogin(req *logical.Request, data *framework.FieldDa
|
|||
}
|
||||
}
|
||||
|
||||
func (b *GcpAuthBackend) pathLoginRenew(req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
func (b *GcpAuthBackend) pathLoginRenew(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
// Check role exists and allowed policies are still the same.
|
||||
roleName := req.Auth.Metadata["role"]
|
||||
if roleName == "" {
|
||||
|
@ -100,7 +101,7 @@ func (b *GcpAuthBackend) pathLoginRenew(req *logical.Request, data *framework.Fi
|
|||
req.Auth.TTL = role.Period
|
||||
return &logical.Response{Auth: req.Auth}, nil
|
||||
} else {
|
||||
return framework.LeaseExtend(role.TTL, role.MaxTTL, b.System())(req, data)
|
||||
return framework.LeaseExtend(role.TTL, role.MaxTTL, b.System())(ctx, req, data)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
package gcpauth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/vault-plugin-auth-gcp/plugin/util"
|
||||
"github.com/hashicorp/vault/helper/policyutil"
|
||||
"github.com/hashicorp/vault/helper/strutil"
|
||||
"github.com/hashicorp/vault/logical"
|
||||
"github.com/hashicorp/vault/logical/framework"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -225,7 +227,7 @@ func pathsRole(b *GcpAuthBackend) []*framework.Path {
|
|||
return paths
|
||||
}
|
||||
|
||||
func (b *GcpAuthBackend) pathRoleExistenceCheck(req *logical.Request, data *framework.FieldData) (bool, error) {
|
||||
func (b *GcpAuthBackend) pathRoleExistenceCheck(ctx context.Context, req *logical.Request, data *framework.FieldData) (bool, error) {
|
||||
entry, err := b.role(req.Storage, data.Get("name").(string))
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
@ -233,7 +235,7 @@ func (b *GcpAuthBackend) pathRoleExistenceCheck(req *logical.Request, data *fram
|
|||
return entry != nil, nil
|
||||
}
|
||||
|
||||
func (b *GcpAuthBackend) pathRoleDelete(req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
func (b *GcpAuthBackend) pathRoleDelete(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
name := data.Get("name").(string)
|
||||
if name == "" {
|
||||
return logical.ErrorResponse(errEmptyRoleName), nil
|
||||
|
@ -245,7 +247,7 @@ func (b *GcpAuthBackend) pathRoleDelete(req *logical.Request, data *framework.Fi
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
func (b *GcpAuthBackend) pathRoleRead(req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
func (b *GcpAuthBackend) pathRoleRead(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
name := data.Get("name").(string)
|
||||
if name == "" {
|
||||
return logical.ErrorResponse(errEmptyRoleName), nil
|
||||
|
@ -289,7 +291,7 @@ func (b *GcpAuthBackend) pathRoleRead(req *logical.Request, data *framework.Fiel
|
|||
}, nil
|
||||
}
|
||||
|
||||
func (b *GcpAuthBackend) pathRoleCreateUpdate(req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
func (b *GcpAuthBackend) pathRoleCreateUpdate(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
name := strings.ToLower(data.Get("name").(string))
|
||||
if name == "" {
|
||||
return logical.ErrorResponse(errEmptyRoleName), nil
|
||||
|
@ -309,7 +311,7 @@ func (b *GcpAuthBackend) pathRoleCreateUpdate(req *logical.Request, data *framew
|
|||
return b.storeRole(req.Storage, name, role)
|
||||
}
|
||||
|
||||
func (b *GcpAuthBackend) pathRoleList(req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
func (b *GcpAuthBackend) pathRoleList(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
roles, err := req.Storage.List("role/")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -328,7 +330,7 @@ the authorization token for the instance can access.
|
|||
const pathListRolesHelpSyn = `Lists all the roles that are registered with Vault.`
|
||||
const pathListRolesHelpDesc = `Lists all roles under the GCP backends by name.`
|
||||
|
||||
func (b *GcpAuthBackend) pathRoleEditIamServiceAccounts(req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
func (b *GcpAuthBackend) pathRoleEditIamServiceAccounts(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
roleName := data.Get("name").(string)
|
||||
if roleName == "" {
|
||||
return logical.ErrorResponse(errEmptyRoleName), nil
|
||||
|
@ -378,7 +380,7 @@ func editStringValues(initial []string, toAdd []string, toRemove []string) []str
|
|||
return updated
|
||||
}
|
||||
|
||||
func (b *GcpAuthBackend) pathRoleEditGceLabels(req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
func (b *GcpAuthBackend) pathRoleEditGceLabels(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
roleName := data.Get("name").(string)
|
||||
if roleName == "" {
|
||||
return logical.ErrorResponse(errEmptyRoleName), nil
|
||||
|
|
|
@ -15,7 +15,12 @@
|
|||
|
||||
[[projects]]
|
||||
name = "github.com/SermoDigital/jose"
|
||||
packages = [".","crypto","jws","jwt"]
|
||||
packages = [
|
||||
".",
|
||||
"crypto",
|
||||
"jws",
|
||||
"jwt"
|
||||
]
|
||||
revision = "f6df55f235c24f236d11dbcf665249a59ac2021f"
|
||||
version = "1.1"
|
||||
|
||||
|
@ -27,9 +32,12 @@
|
|||
|
||||
[[projects]]
|
||||
name = "github.com/emicklei/go-restful"
|
||||
packages = [".","log"]
|
||||
revision = "68c9750c36bb8cb433f1b88c807b4b30df4acc40"
|
||||
version = "v2.2.1"
|
||||
packages = [
|
||||
".",
|
||||
"log"
|
||||
]
|
||||
revision = "5741799b275a3c4a5a9623a993576d7545cf7b5c"
|
||||
version = "v2.4.0"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/fatih/structs"
|
||||
|
@ -53,19 +61,22 @@
|
|||
branch = "master"
|
||||
name = "github.com/go-openapi/spec"
|
||||
packages = ["."]
|
||||
revision = "7abd5745472fff5eb3685386d5fb8bf38683154d"
|
||||
revision = "fa03337d7da5735229ee8f5e9d5d0b996014b7f8"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/go-openapi/swag"
|
||||
packages = ["."]
|
||||
revision = "f3f9494671f93fcff853e3c6e9e948b3eb71e590"
|
||||
revision = "84f4bee7c0a6db40e3166044c7983c1c32125429"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/gogo/protobuf"
|
||||
packages = ["proto","sortkeys"]
|
||||
revision = "100ba4e885062801d56799d78530b73b178a78f3"
|
||||
version = "v0.4"
|
||||
packages = [
|
||||
"proto",
|
||||
"sortkeys"
|
||||
]
|
||||
revision = "342cbe0a04158f6dcb03ca0079991a51a4248c02"
|
||||
version = "v0.5"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
|
@ -76,8 +87,14 @@
|
|||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/golang/protobuf"
|
||||
packages = ["proto","ptypes","ptypes/any","ptypes/duration","ptypes/timestamp"]
|
||||
revision = "17ce1425424ab154092bbb43af630bd647f3bb0d"
|
||||
packages = [
|
||||
"proto",
|
||||
"ptypes",
|
||||
"ptypes/any",
|
||||
"ptypes/duration",
|
||||
"ptypes/timestamp"
|
||||
]
|
||||
revision = "1e59b77b52bf8e4b449a57e6f79f21226d571845"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
|
@ -101,25 +118,25 @@
|
|||
branch = "master"
|
||||
name = "github.com/hashicorp/go-cleanhttp"
|
||||
packages = ["."]
|
||||
revision = "3573b8b52aa7b37b9358d966a898feb387f62437"
|
||||
revision = "d5fe4b57a186c716b0e00b8c301cbd9b4182694d"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/hashicorp/go-hclog"
|
||||
packages = ["."]
|
||||
revision = "8105cc0a3736cc153a2025f5d0d91b80045fc9ff"
|
||||
revision = "ca137eb4b4389c9bc6f1a6d887f056bf16c00510"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/hashicorp/go-multierror"
|
||||
packages = ["."]
|
||||
revision = "83588e72410abfbe4df460eeb6f30841ae47d4c4"
|
||||
revision = "b7773ae218740a7be65057fc60b366a49b538a44"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/hashicorp/go-plugin"
|
||||
packages = ["."]
|
||||
revision = "3e6d191694b5a3a2b99755f31b47fa209e4bcd09"
|
||||
revision = "e2fbc6864d18d3c37b6cde4297ec9fca266d28f1"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
|
@ -136,26 +153,58 @@
|
|||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/hashicorp/hcl"
|
||||
packages = [".","hcl/ast","hcl/parser","hcl/scanner","hcl/strconv","hcl/token","json/parser","json/scanner","json/token"]
|
||||
revision = "68e816d1c783414e79bc65b3994d9ab6b0a722ab"
|
||||
packages = [
|
||||
".",
|
||||
"hcl/ast",
|
||||
"hcl/parser",
|
||||
"hcl/scanner",
|
||||
"hcl/strconv",
|
||||
"hcl/token",
|
||||
"json/parser",
|
||||
"json/scanner",
|
||||
"json/token"
|
||||
]
|
||||
revision = "23c074d0eceb2b8a5bfdbb271ab780cde70f05a8"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/hashicorp/vault"
|
||||
packages = ["api","helper/certutil","helper/compressutil","helper/consts","helper/errutil","helper/jsonutil","helper/logformat","helper/mlock","helper/parseutil","helper/pluginutil","helper/policyutil","helper/salt","helper/strutil","helper/wrapping","logical","logical/framework","logical/plugin"]
|
||||
revision = "1c4baa56e9882449ed70c0021100336a3465ea58"
|
||||
packages = [
|
||||
"api",
|
||||
"helper/certutil",
|
||||
"helper/compressutil",
|
||||
"helper/consts",
|
||||
"helper/errutil",
|
||||
"helper/jsonutil",
|
||||
"helper/logformat",
|
||||
"helper/mlock",
|
||||
"helper/parseutil",
|
||||
"helper/pluginutil",
|
||||
"helper/policyutil",
|
||||
"helper/salt",
|
||||
"helper/strutil",
|
||||
"helper/wrapping",
|
||||
"logical",
|
||||
"logical/framework",
|
||||
"logical/plugin"
|
||||
]
|
||||
revision = "78adac0a24fbefa644fc775bae70b46482af0ea9"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/hashicorp/yamux"
|
||||
packages = ["."]
|
||||
revision = "d1caa6c97c9fc1cc9e83bbe34d0603f9ff0ce8bd"
|
||||
revision = "683f49123a33db61abfb241b7ac5e4af4dc54d55"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/mailru/easyjson"
|
||||
packages = ["buffer","jlexer","jwriter"]
|
||||
revision = "2a92e673c9a6302dd05c3a691ae1f24aef46457d"
|
||||
packages = [
|
||||
"buffer",
|
||||
"jlexer",
|
||||
"jwriter"
|
||||
]
|
||||
revision = "32fa128f234d041f196a9f3e0fea5ac9772c08e1"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/mattn/go-colorable"
|
||||
|
@ -166,8 +215,8 @@
|
|||
[[projects]]
|
||||
name = "github.com/mattn/go-isatty"
|
||||
packages = ["."]
|
||||
revision = "fc9e8d8ef48496124e79ae0df75490096eccf6fe"
|
||||
version = "v0.0.2"
|
||||
revision = "0360b2af4f38e8d38c7fce2a9f4e702702d73a39"
|
||||
version = "v0.0.3"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
|
@ -191,19 +240,25 @@
|
|||
branch = "master"
|
||||
name = "github.com/mitchellh/go-testing-interface"
|
||||
packages = ["."]
|
||||
revision = "7bf6f6eaf1bed2fd3c6c63114b18cb64facb9de2"
|
||||
revision = "a61a99592b77c9ba629d254a693acffaeb4b7e28"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/mitchellh/mapstructure"
|
||||
packages = ["."]
|
||||
revision = "d0303fe809921458f417bcf828397a65db30a7e4"
|
||||
revision = "06020f85339e21b2478f756a78e295255ffa4d6a"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/ryanuber/go-glob"
|
||||
packages = ["."]
|
||||
revision = "572520ed46dbddaed19ea3d9541bdd0494163693"
|
||||
version = "v0.1"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/sethgrid/pester"
|
||||
packages = ["."]
|
||||
revision = "a86a2d88f4dc3c7dbf3a6a6bbbfb095690b834b6"
|
||||
revision = "760f8913c0483b776294e1bee43f1d687527127b"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/spf13/pflag"
|
||||
|
@ -214,32 +269,81 @@
|
|||
[[projects]]
|
||||
branch = "master"
|
||||
name = "golang.org/x/net"
|
||||
packages = ["context","http2","http2/hpack","idna","internal/timeseries","lex/httplex","trace"]
|
||||
revision = "859d1a86bb617c0c20d154590c3c5d3fcb670b07"
|
||||
packages = [
|
||||
"context",
|
||||
"http2",
|
||||
"http2/hpack",
|
||||
"idna",
|
||||
"internal/timeseries",
|
||||
"lex/httplex",
|
||||
"trace"
|
||||
]
|
||||
revision = "434ec0c7fe3742c984919a691b2018a6e9694425"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "golang.org/x/sys"
|
||||
packages = ["unix"]
|
||||
revision = "062cd7e4e68206d8bab9b18396626e855c992658"
|
||||
revision = "1792d66dc88e503d3cb2400578221cdf1f7fe26f"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "golang.org/x/text"
|
||||
packages = ["collate","collate/build","internal/colltab","internal/gen","internal/tag","internal/triegen","internal/ucd","language","secure/bidirule","transform","unicode/bidi","unicode/cldr","unicode/norm","unicode/rangetable","width"]
|
||||
revision = "ab5ac5f9a8deb4855a60fab02bc61a4ec770bd49"
|
||||
packages = [
|
||||
"collate",
|
||||
"collate/build",
|
||||
"internal/colltab",
|
||||
"internal/gen",
|
||||
"internal/tag",
|
||||
"internal/triegen",
|
||||
"internal/ucd",
|
||||
"language",
|
||||
"secure/bidirule",
|
||||
"transform",
|
||||
"unicode/bidi",
|
||||
"unicode/cldr",
|
||||
"unicode/norm",
|
||||
"unicode/rangetable",
|
||||
"width"
|
||||
]
|
||||
revision = "e19ae1496984b1c655b8044a65c0300a3c878dd3"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "google.golang.org/genproto"
|
||||
packages = ["googleapis/rpc/status"]
|
||||
revision = "595979c8a7bf586b2d293fb42246bf91a0b893d9"
|
||||
revision = "a8101f21cf983e773d0c1133ebc5424792003214"
|
||||
|
||||
[[projects]]
|
||||
name = "google.golang.org/grpc"
|
||||
packages = [".","codes","connectivity","credentials","grpclb/grpc_lb_v1/messages","grpclog","health","health/grpc_health_v1","internal","keepalive","metadata","naming","peer","stats","status","tap","transport"]
|
||||
revision = "f92cdcd7dcdc69e81b2d7b338479a19a8723cfa3"
|
||||
version = "v1.6.0"
|
||||
packages = [
|
||||
".",
|
||||
"balancer",
|
||||
"balancer/base",
|
||||
"balancer/roundrobin",
|
||||
"codes",
|
||||
"connectivity",
|
||||
"credentials",
|
||||
"encoding",
|
||||
"grpclb/grpc_lb_v1/messages",
|
||||
"grpclog",
|
||||
"health",
|
||||
"health/grpc_health_v1",
|
||||
"internal",
|
||||
"keepalive",
|
||||
"metadata",
|
||||
"naming",
|
||||
"peer",
|
||||
"resolver",
|
||||
"resolver/dns",
|
||||
"resolver/passthrough",
|
||||
"stats",
|
||||
"status",
|
||||
"tap",
|
||||
"transport"
|
||||
]
|
||||
revision = "f3955b8e9e244dd4dd4bc4f7b7a23a8445400a76"
|
||||
version = "v1.9.0"
|
||||
|
||||
[[projects]]
|
||||
name = "gopkg.in/inf.v0"
|
||||
|
@ -251,25 +355,47 @@
|
|||
branch = "v2"
|
||||
name = "gopkg.in/yaml.v2"
|
||||
packages = ["."]
|
||||
revision = "eb3733d160e74a9c7e442f435eb3bea458e1d19f"
|
||||
revision = "1244d3ce02e3e1c16820ada0bae506b6c479f106"
|
||||
|
||||
[[projects]]
|
||||
branch = "release-1.8"
|
||||
name = "k8s.io/api"
|
||||
packages = ["authentication/v1"]
|
||||
revision = "6c6dac0277229b9e9578c5ca3f74a4345d35cdc2"
|
||||
revision = "389dfa299845bcf399c16af89987e8775718ea48"
|
||||
|
||||
[[projects]]
|
||||
branch = "release-1.8"
|
||||
name = "k8s.io/apimachinery"
|
||||
packages = ["pkg/api/errors","pkg/api/resource","pkg/apis/meta/v1","pkg/conversion","pkg/conversion/queryparams","pkg/fields","pkg/labels","pkg/runtime","pkg/runtime/schema","pkg/selection","pkg/types","pkg/util/errors","pkg/util/intstr","pkg/util/net","pkg/util/runtime","pkg/util/sets","pkg/util/validation","pkg/util/validation/field","pkg/util/wait","pkg/watch","third_party/forked/golang/reflect"]
|
||||
revision = "019ae5ada31de202164b118aee88ee2d14075c31"
|
||||
packages = [
|
||||
"pkg/api/errors",
|
||||
"pkg/api/resource",
|
||||
"pkg/apis/meta/v1",
|
||||
"pkg/conversion",
|
||||
"pkg/conversion/queryparams",
|
||||
"pkg/fields",
|
||||
"pkg/labels",
|
||||
"pkg/runtime",
|
||||
"pkg/runtime/schema",
|
||||
"pkg/selection",
|
||||
"pkg/types",
|
||||
"pkg/util/errors",
|
||||
"pkg/util/intstr",
|
||||
"pkg/util/net",
|
||||
"pkg/util/runtime",
|
||||
"pkg/util/sets",
|
||||
"pkg/util/validation",
|
||||
"pkg/util/validation/field",
|
||||
"pkg/util/wait",
|
||||
"pkg/watch",
|
||||
"third_party/forked/golang/reflect"
|
||||
]
|
||||
revision = "bc110fd540ab678abbf2bc71d9ce908eb9325ef6"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "k8s.io/kube-openapi"
|
||||
packages = ["pkg/common"]
|
||||
revision = "61b46af70dfed79c6d24530cd23b41440a7f22a5"
|
||||
revision = "b16ebc07f5cad97831f961e4b5a9cc1caed33b7e"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
|
|
|
@ -40,7 +40,7 @@ func Backend() *kubeAuthBackend {
|
|||
b := &kubeAuthBackend{}
|
||||
|
||||
b.Backend = &framework.Backend{
|
||||
AuthRenew: b.pathLoginRenew,
|
||||
AuthRenew: b.pathLoginRenew(),
|
||||
BackendType: logical.TypeCredential,
|
||||
Help: backendHelp,
|
||||
PathsSpecial: &logical.Paths{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package kubeauth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/ecdsa"
|
||||
"crypto/rsa"
|
||||
"crypto/x509"
|
||||
|
@ -55,7 +56,7 @@ extracted. Not every installation of Kuberentes exposes these keys.`,
|
|||
|
||||
// pathConfigWrite handles create and update commands to the config
|
||||
func (b *kubeAuthBackend) pathConfigRead() framework.OperationFunc {
|
||||
return func(req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
return func(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
if config, err := b.config(req.Storage); err != nil {
|
||||
return nil, err
|
||||
} else if config == nil {
|
||||
|
@ -78,7 +79,7 @@ func (b *kubeAuthBackend) pathConfigRead() framework.OperationFunc {
|
|||
|
||||
// pathConfigWrite handles create and update commands to the config
|
||||
func (b *kubeAuthBackend) pathConfigWrite() framework.OperationFunc {
|
||||
return func(req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
return func(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
host := data.Get("kubernetes_host").(string)
|
||||
if host == "" {
|
||||
return logical.ErrorResponse("no host provided"), nil
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package kubeauth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/ecdsa"
|
||||
"crypto/rsa"
|
||||
"errors"
|
||||
|
@ -55,7 +56,7 @@ func pathLogin(b *kubeAuthBackend) *framework.Path {
|
|||
|
||||
// pathLogin is used to authenticate to this backend
|
||||
func (b *kubeAuthBackend) pathLogin() framework.OperationFunc {
|
||||
return func(req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
return func(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
roleName := data.Get("role").(string)
|
||||
if len(roleName) == 0 {
|
||||
return logical.ErrorResponse("missing role"), nil
|
||||
|
@ -137,7 +138,7 @@ func (b *kubeAuthBackend) pathLogin() framework.OperationFunc {
|
|||
// aliasLookahead returns the alias object with the SA UID from the JWT
|
||||
// Claims.
|
||||
func (b *kubeAuthBackend) aliasLookahead() framework.OperationFunc {
|
||||
return func(req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
return func(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
jwtStr := data.Get("jwt").(string)
|
||||
if len(jwtStr) == 0 {
|
||||
return logical.ErrorResponse("missing jwt"), nil
|
||||
|
@ -309,34 +310,36 @@ func (s *serviceAccount) lookup(jwtStr string, tr tokenReviewer) error {
|
|||
}
|
||||
|
||||
// Invoked when the token issued by this backend is attempting a renewal.
|
||||
func (b *kubeAuthBackend) pathLoginRenew(req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
roleName := req.Auth.InternalData["role"].(string)
|
||||
if roleName == "" {
|
||||
return nil, fmt.Errorf("failed to fetch role_name during renewal")
|
||||
}
|
||||
func (b *kubeAuthBackend) pathLoginRenew() framework.OperationFunc {
|
||||
return func(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
roleName := req.Auth.InternalData["role"].(string)
|
||||
if roleName == "" {
|
||||
return nil, fmt.Errorf("failed to fetch role_name during renewal")
|
||||
}
|
||||
|
||||
b.l.RLock()
|
||||
defer b.l.RUnlock()
|
||||
b.l.RLock()
|
||||
defer b.l.RUnlock()
|
||||
|
||||
// Ensure that the Role still exists.
|
||||
role, err := b.role(req.Storage, roleName)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to validate role %s during renewal:%s", roleName, err)
|
||||
}
|
||||
if role == nil {
|
||||
return nil, fmt.Errorf("role %s does not exist during renewal", roleName)
|
||||
}
|
||||
// Ensure that the Role still exists.
|
||||
role, err := b.role(req.Storage, roleName)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to validate role %s during renewal:%s", roleName, err)
|
||||
}
|
||||
if role == nil {
|
||||
return nil, fmt.Errorf("role %s does not exist during renewal", roleName)
|
||||
}
|
||||
|
||||
// If 'Period' is set on the Role, the token should never expire.
|
||||
// Replenish the TTL with 'Period's value.
|
||||
if role.Period > time.Duration(0) {
|
||||
// If 'Period' was updated after the token was issued,
|
||||
// token will bear the updated 'Period' value as its TTL.
|
||||
req.Auth.TTL = role.Period
|
||||
return &logical.Response{Auth: req.Auth}, nil
|
||||
}
|
||||
// If 'Period' is set on the Role, the token should never expire.
|
||||
// Replenish the TTL with 'Period's value.
|
||||
if role.Period > time.Duration(0) {
|
||||
// If 'Period' was updated after the token was issued,
|
||||
// token will bear the updated 'Period' value as its TTL.
|
||||
req.Auth.TTL = role.Period
|
||||
return &logical.Response{Auth: req.Auth}, nil
|
||||
}
|
||||
|
||||
return framework.LeaseExtend(role.TTL, role.MaxTTL, b.System())(req, data)
|
||||
return framework.LeaseExtend(role.TTL, role.MaxTTL, b.System())(ctx, req, data)
|
||||
}
|
||||
}
|
||||
|
||||
const pathLoginHelpSyn = `Authenticates Kubernetes service accounts with Vault.`
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package kubeauth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
@ -66,7 +67,7 @@ duration specified by this value. At each renewal, the token's
|
|||
TTL will be set to the value of this parameter.`,
|
||||
},
|
||||
},
|
||||
ExistenceCheck: b.pathRoleExistenceCheck,
|
||||
ExistenceCheck: b.pathRoleExistenceCheck(),
|
||||
Callbacks: map[logical.Operation]framework.OperationFunc{
|
||||
logical.CreateOperation: b.pathRoleCreateUpdate(),
|
||||
logical.UpdateOperation: b.pathRoleCreateUpdate(),
|
||||
|
@ -80,20 +81,22 @@ TTL will be set to the value of this parameter.`,
|
|||
}
|
||||
|
||||
// pathRoleExistenceCheck returns whether the role with the given name exists or not.
|
||||
func (b *kubeAuthBackend) pathRoleExistenceCheck(req *logical.Request, data *framework.FieldData) (bool, error) {
|
||||
b.l.RLock()
|
||||
defer b.l.RUnlock()
|
||||
func (b *kubeAuthBackend) pathRoleExistenceCheck() framework.ExistenceFunc {
|
||||
return func(ctx context.Context, req *logical.Request, data *framework.FieldData) (bool, error) {
|
||||
b.l.RLock()
|
||||
defer b.l.RUnlock()
|
||||
|
||||
role, err := b.role(req.Storage, data.Get("name").(string))
|
||||
if err != nil {
|
||||
return false, err
|
||||
role, err := b.role(req.Storage, data.Get("name").(string))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return role != nil, nil
|
||||
}
|
||||
return role != nil, nil
|
||||
}
|
||||
|
||||
// pathRoleList is used to list all the Roles registered with the backend.
|
||||
func (b *kubeAuthBackend) pathRoleList() framework.OperationFunc {
|
||||
return func(req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
return func(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
b.l.RLock()
|
||||
defer b.l.RUnlock()
|
||||
|
||||
|
@ -107,7 +110,7 @@ func (b *kubeAuthBackend) pathRoleList() framework.OperationFunc {
|
|||
|
||||
// pathRoleRead grabs a read lock and reads the options set on the role from the storage
|
||||
func (b *kubeAuthBackend) pathRoleRead() framework.OperationFunc {
|
||||
return func(req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
return func(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
roleName := data.Get("name").(string)
|
||||
if roleName == "" {
|
||||
return logical.ErrorResponse("missing name"), nil
|
||||
|
@ -148,7 +151,7 @@ func (b *kubeAuthBackend) pathRoleRead() framework.OperationFunc {
|
|||
|
||||
// pathRoleDelete removes the role from storage
|
||||
func (b *kubeAuthBackend) pathRoleDelete() framework.OperationFunc {
|
||||
return func(req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
return func(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
roleName := data.Get("name").(string)
|
||||
if roleName == "" {
|
||||
return logical.ErrorResponse("missing role name"), nil
|
||||
|
@ -170,7 +173,7 @@ func (b *kubeAuthBackend) pathRoleDelete() framework.OperationFunc {
|
|||
// pathRoleCreateUpdate registers a new role with the backend or updates the options
|
||||
// of an existing role
|
||||
func (b *kubeAuthBackend) pathRoleCreateUpdate() framework.OperationFunc {
|
||||
return func(req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
return func(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
roleName := data.Get("name").(string)
|
||||
if roleName == "" {
|
||||
return logical.ErrorResponse("missing role name"), nil
|
||||
|
|
|
@ -1153,10 +1153,10 @@
|
|||
"revisionTime": "2017-10-22T02:00:50Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "sdZKlxQSisX2x4nCshF8wZYoFcs=",
|
||||
"checksumSHA1": "3XuxkFWZCrjakXvVWn5GMdZcMgE=",
|
||||
"path": "github.com/hashicorp/vault-plugin-auth-gcp/plugin",
|
||||
"revision": "f45fc9303c8075b5fb0ec5c8dda32e6dac5859ed",
|
||||
"revisionTime": "2017-12-21T13:29:36Z"
|
||||
"revision": "d6371c9426008300cb28fcaac2e303cf1991ac0f",
|
||||
"revisionTime": "2018-01-08T19:26:24Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "ffJQvzbQvmCG/PdaElGSfGnDgNM=",
|
||||
|
@ -1165,10 +1165,10 @@
|
|||
"revisionTime": "2017-12-21T13:29:36Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "B/pF8a80lWLgqfMZ4JYY2kKY0fs=",
|
||||
"checksumSHA1": "qztTbChbXCzE8wHJn3uw8eXP0qY=",
|
||||
"path": "github.com/hashicorp/vault-plugin-auth-kubernetes",
|
||||
"revision": "9d1bbbd0106e1e3c4ebe16cf104cfe855874133e",
|
||||
"revisionTime": "2017-11-15T23:43:07Z"
|
||||
"revision": "20d5b585bfc96abf8aa07bd10a834df415eb165f",
|
||||
"revisionTime": "2018-01-08T18:57:08Z"
|
||||
},
|
||||
{
|
||||
"path": "github.com/hashicorp/vault-plugin/auth-gcp/plugin",
|
||||
|
|
Loading…
Reference in New Issue