mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 02:57:59 +00:00
Added a nil check for config and renamed org field internally.
This commit is contained in:
@@ -77,10 +77,10 @@ func (b *backend) pathConfigWrite(
|
|||||||
}
|
}
|
||||||
|
|
||||||
entry, err := logical.StorageEntryJSON("config", config{
|
entry, err := logical.StorageEntryJSON("config", config{
|
||||||
Org: organization,
|
Organization: organization,
|
||||||
BaseURL: baseURL,
|
BaseURL: baseURL,
|
||||||
TTL: ttl,
|
TTL: ttl,
|
||||||
MaxTTL: maxTTL,
|
MaxTTL: maxTTL,
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -99,6 +99,11 @@ func (b *backend) pathConfigRead(req *logical.Request, data *framework.FieldData
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if config == nil {
|
||||||
|
return nil, fmt.Errorf("configuration object not found")
|
||||||
|
}
|
||||||
|
|
||||||
config.TTL /= time.Second
|
config.TTL /= time.Second
|
||||||
config.MaxTTL /= time.Second
|
config.MaxTTL /= time.Second
|
||||||
|
|
||||||
@@ -126,8 +131,8 @@ func (b *backend) Config(s logical.Storage) (*config, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type config struct {
|
type config struct {
|
||||||
Org string `json:"organization" structs:"organization" mapstructure:"organization"`
|
Organization string `json:"organization" structs:"organization" mapstructure:"organization"`
|
||||||
BaseURL string `json:"base_url" structs:"base_url" mapstructure:"base_url"`
|
BaseURL string `json:"base_url" structs:"base_url" mapstructure:"base_url"`
|
||||||
TTL time.Duration `json:"ttl" structs:"ttl" mapstructure:"ttl"`
|
TTL time.Duration `json:"ttl" structs:"ttl" mapstructure:"ttl"`
|
||||||
MaxTTL time.Duration `json:"max_ttl" structs:"max_ttl" mapstructure:"max_ttl"`
|
MaxTTL time.Duration `json:"max_ttl" structs:"max_ttl" mapstructure:"max_ttl"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ func (b *backend) verifyCredentials(req *logical.Request, token string) (*verify
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
if config.Org == "" {
|
if config.Organization == "" {
|
||||||
return nil, logical.ErrorResponse(
|
return nil, logical.ErrorResponse(
|
||||||
"configure the github credential backend first"), nil
|
"configure the github credential backend first"), nil
|
||||||
}
|
}
|
||||||
@@ -152,7 +152,7 @@ func (b *backend) verifyCredentials(req *logical.Request, token string) (*verify
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, o := range allOrgs {
|
for _, o := range allOrgs {
|
||||||
if strings.ToLower(*o.Login) == strings.ToLower(config.Org) {
|
if strings.ToLower(*o.Login) == strings.ToLower(config.Organization) {
|
||||||
org = o
|
org = o
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user