moving id to http/logical

This commit is contained in:
Laura Bennett 2016-07-25 15:24:10 -04:00
parent 9ef3d90349
commit 8d52a96df5
3 changed files with 8 additions and 15 deletions

View File

@ -8,6 +8,7 @@ import (
"strings"
"github.com/hashicorp/errwrap"
"github.com/hashicorp/go-uuid"
"github.com/hashicorp/vault/logical"
"github.com/hashicorp/vault/vault"
)
@ -64,8 +65,14 @@ func buildLogicalRequest(w http.ResponseWriter, r *http.Request) (*logical.Reque
}
}
var err error
// Generate a unique identifier for the request
requestid, err := uuid.GenerateUUID()
if err != nil {
return nil, http.StatusBadRequest, errwrap.Wrapf("failed to generate identifier for the request: {{err}}", err)
}
req := requestAuth(r, &logical.Request{
ID: requestid,
Operation: op,
Path: path,
Data: data,

View File

@ -708,12 +708,6 @@ func (c *Core) sealInitCommon(req *logical.Request) (retErr error) {
return retErr
}
// Create an identifier for the request
var err error
req.ID, err = uuid.GenerateUUID()
if err != nil {
return fmt.Errorf("failed to generate identifier for the request: path: %s err: %v", req.Path, err)
}
// Validate the token is a root token
acl, te, err := c.fetchACLandTokenEntry(req)
if err != nil {

View File

@ -2,14 +2,12 @@ package vault
import (
"encoding/json"
"fmt"
"sort"
"strings"
"time"
"github.com/armon/go-metrics"
"github.com/hashicorp/go-multierror"
"github.com/hashicorp/go-uuid"
"github.com/hashicorp/vault/helper/strutil"
"github.com/hashicorp/vault/logical"
)
@ -37,12 +35,6 @@ func (c *Core) HandleRequest(req *logical.Request) (resp *logical.Response, err
return logical.ErrorResponse("cannot write to a path ending in '/'"), nil
}
// Create an identifier for the request
req.ID, err = uuid.GenerateUUID()
if err != nil {
return nil, fmt.Errorf("failed to generate identifier for the request: path %s err %v", req.Path, err)
}
var auth *logical.Auth
if c.router.LoginPath(req.Path) {
resp, auth, err = c.handleLoginRequest(req)