Skip to content

Commit

Permalink
Make sys/wrapping/lookup unauthenticated. (#3084)
Browse files Browse the repository at this point in the history
We still perform validation on the token, so if the call makes it
through to this endpoint it's got a valid token (either explicitly
specified in data or as the request token). But this allows
introspection for sanity/safety checking without revoking the token in
the process.
  • Loading branch information
jefferai authored Jul 31, 2017
1 parent b1cc7f6 commit d313e40
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 8 additions & 2 deletions vault/logical_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func NewSystemBackend(core *Core) *SystemBackend {
},

Unauthenticated: []string{
"wrapping/lookup",
"wrapping/pubkey",
"replication/status",
},
Expand Down Expand Up @@ -725,6 +726,7 @@ func NewSystemBackend(core *Core) *SystemBackend {

Callbacks: map[logical.Operation]framework.OperationFunc{
logical.UpdateOperation: b.handleWrappingLookup,
logical.ReadOperation: b.handleWrappingLookup,
},

HelpSynopsis: strings.TrimSpace(sysHelp["wraplookup"][0]),
Expand Down Expand Up @@ -2171,10 +2173,14 @@ func (b *SystemBackend) handleWrappingUnwrap(

func (b *SystemBackend) handleWrappingLookup(
req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
// This ordering of lookups has been validated already in the wrapping
// validation func, we're just doing this for a safety check
token := data.Get("token").(string)

if token == "" {
return logical.ErrorResponse("missing \"token\" value in input"), logical.ErrInvalidRequest
token = req.ClientToken
if token == "" {
return logical.ErrorResponse("missing \"token\" value in input"), logical.ErrInvalidRequest
}
}

cubbyReq := &logical.Request{
Expand Down
4 changes: 1 addition & 3 deletions vault/policy_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ const (
responseWrappingPolicyName = "response-wrapping"

// responseWrappingPolicy is the policy that ensures cubbyhole response
// wrapping can always succeed. Note that sys/wrapping/lookup isn't
// contained here because using it would revoke the token anyways, so there
// isn't much point.
// wrapping can always succeed.
responseWrappingPolicy = `
path "cubbyhole/response" {
capabilities = ["create", "read"]
Expand Down

0 comments on commit d313e40

Please sign in to comment.