mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 11:38:02 +00:00
Make API not depend on SDK (#18962)
This commit is contained in:
@@ -11,8 +11,6 @@ import (
|
||||
|
||||
"github.com/hashicorp/errwrap"
|
||||
"github.com/hashicorp/go-secure-stdlib/parseutil"
|
||||
"github.com/hashicorp/vault/sdk/helper/jsonutil"
|
||||
"github.com/hashicorp/vault/sdk/logical"
|
||||
)
|
||||
|
||||
// Secret is the structure returned for every secret within Vault.
|
||||
@@ -283,6 +281,22 @@ type SecretWrapInfo struct {
|
||||
WrappedAccessor string `json:"wrapped_accessor"`
|
||||
}
|
||||
|
||||
type MFAMethodID struct {
|
||||
Type string `json:"type,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
UsesPasscode bool `json:"uses_passcode,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
type MFAConstraintAny struct {
|
||||
Any []*MFAMethodID `json:"any,omitempty"`
|
||||
}
|
||||
|
||||
type MFARequirement struct {
|
||||
MFARequestID string `json:"mfa_request_id,omitempty"`
|
||||
MFAConstraints map[string]*MFAConstraintAny `json:"mfa_constraints,omitempty"`
|
||||
}
|
||||
|
||||
// SecretAuth is the structure containing auth information if we have it.
|
||||
type SecretAuth struct {
|
||||
ClientToken string `json:"client_token"`
|
||||
@@ -297,7 +311,7 @@ type SecretAuth struct {
|
||||
LeaseDuration int `json:"lease_duration"`
|
||||
Renewable bool `json:"renewable"`
|
||||
|
||||
MFARequirement *logical.MFARequirement `json:"mfa_requirement"`
|
||||
MFARequirement *MFARequirement `json:"mfa_requirement"`
|
||||
}
|
||||
|
||||
// ParseSecret is used to parse a secret value from JSON from an io.Reader.
|
||||
@@ -323,14 +337,18 @@ func ParseSecret(r io.Reader) (*Secret, error) {
|
||||
|
||||
// First decode the JSON into a map[string]interface{}
|
||||
var secret Secret
|
||||
if err := jsonutil.DecodeJSONFromReader(&buf, &secret); err != nil {
|
||||
dec := json.NewDecoder(&buf)
|
||||
dec.UseNumber()
|
||||
if err := dec.Decode(&secret); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// If the secret is null, add raw data to secret data if present
|
||||
if reflect.DeepEqual(secret, Secret{}) {
|
||||
data := make(map[string]interface{})
|
||||
if err := jsonutil.DecodeJSONFromReader(&teebuf, &data); err != nil {
|
||||
dec := json.NewDecoder(&teebuf)
|
||||
dec.UseNumber()
|
||||
if err := dec.Decode(&data); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
errRaw, errPresent := data["errors"]
|
||||
|
||||
Reference in New Issue
Block a user