Skip to content

Commit 20423f7

Browse files
authored
Add allowed_response_headers (hashicorp#6115)
1 parent 69d3fdd commit 20423f7

31 files changed

+728
-423
lines changed

api/sys_mounts.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ type MountConfigInput struct {
151151
AuditNonHMACResponseKeys []string `json:"audit_non_hmac_response_keys,omitempty" mapstructure:"audit_non_hmac_response_keys"`
152152
ListingVisibility string `json:"listing_visibility,omitempty" mapstructure:"listing_visibility"`
153153
PassthroughRequestHeaders []string `json:"passthrough_request_headers,omitempty" mapstructure:"passthrough_request_headers"`
154+
AllowedResponseHeaders []string `json:"allowed_response_headers,omitempty" mapstructure:"allowed_response_headers"`
154155
TokenType string `json:"token_type,omitempty" mapstructure:"token_type"`
155156

156157
// Deprecated: This field will always be blank for newer server responses.
@@ -175,6 +176,7 @@ type MountConfigOutput struct {
175176
AuditNonHMACResponseKeys []string `json:"audit_non_hmac_response_keys,omitempty" mapstructure:"audit_non_hmac_response_keys"`
176177
ListingVisibility string `json:"listing_visibility,omitempty" mapstructure:"listing_visibility"`
177178
PassthroughRequestHeaders []string `json:"passthrough_request_headers,omitempty" mapstructure:"passthrough_request_headers"`
179+
AllowedResponseHeaders []string `json:"allowed_response_headers,omitempty" mapstructure:"allowed_response_headers"`
178180
TokenType string `json:"token_type,omitempty" mapstructure:"token_type"`
179181

180182
// Deprecated: This field will always be blank for newer server responses.

audit/format.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ func (f *AuditFormatter) FormatResponse(ctx context.Context, w io.Writer, config
373373
Data: resp.Data,
374374
Redirect: resp.Redirect,
375375
WrapInfo: respWrapInfo,
376+
Headers: resp.Headers,
376377
},
377378
}
378379

@@ -427,6 +428,7 @@ type AuditResponse struct {
427428
Data map[string]interface{} `json:"data,omitempty"`
428429
Redirect string `json:"redirect,omitempty"`
429430
WrapInfo *AuditResponseWrapInfo `json:"wrap_info,omitempty"`
431+
Headers map[string][]string `json:"headers"`
430432
}
431433

432434
type AuditAuth struct {

builtin/logical/database/dbplugin/database.pb.go

Lines changed: 55 additions & 59 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

command/auth_enable.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ type AuthEnableCommand struct {
2626
flagAuditNonHMACRequestKeys []string
2727
flagAuditNonHMACResponseKeys []string
2828
flagListingVisibility string
29-
flagPassthroughRequestHeaders []string
3029
flagPluginName string
30+
flagPassthroughRequestHeaders []string
31+
flagAllowedResponseHeaders []string
3132
flagOptions map[string]string
3233
flagLocal bool
3334
flagSealWrap bool
@@ -134,7 +135,14 @@ func (c *AuthEnableCommand) Flags() *FlagSets {
134135
Name: flagNamePassthroughRequestHeaders,
135136
Target: &c.flagPassthroughRequestHeaders,
136137
Usage: "Comma-separated string or list of request header values that " +
137-
"will be sent to the backend",
138+
"will be sent to the plugin",
139+
})
140+
141+
f.StringSliceVar(&StringSliceVar{
142+
Name: flagNameAllowedResponseHeaders,
143+
Target: &c.flagAllowedResponseHeaders,
144+
Usage: "Comma-separated string or list of response header values that " +
145+
"plugins will be allowed to set",
138146
})
139147

140148
f.StringVar(&StringVar{
@@ -272,6 +280,10 @@ func (c *AuthEnableCommand) Run(args []string) int {
272280
authOpts.Config.PassthroughRequestHeaders = c.flagPassthroughRequestHeaders
273281
}
274282

283+
if fl.Name == flagNameAllowedResponseHeaders {
284+
authOpts.Config.AllowedResponseHeaders = c.flagAllowedResponseHeaders
285+
}
286+
275287
if fl.Name == flagNameTokenType {
276288
authOpts.Config.TokenType = c.flagTokenType
277289
}

command/commands.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ const (
7676
flagNameListingVisibility = "listing-visibility"
7777
// flagNamePassthroughRequestHeaders is the flag name used to set passthrough request headers to the backend
7878
flagNamePassthroughRequestHeaders = "passthrough-request-headers"
79+
// flagNameAllowedResponseHeaders is used to set allowed response headers from a plugin
80+
flagNameAllowedResponseHeaders = "allowed-response-headers"
7981
// flagNameTokenType is the flag name used to force a specific token type
8082
flagNameTokenType = "token-type"
8183
)

command/secrets_enable.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ type SecretsEnableCommand struct {
2727
flagAuditNonHMACResponseKeys []string
2828
flagListingVisibility string
2929
flagPassthroughRequestHeaders []string
30+
flagAllowedResponseHeaders []string
3031
flagForceNoCache bool
3132
flagPluginName string
3233
flagOptions map[string]string
@@ -141,7 +142,14 @@ func (c *SecretsEnableCommand) Flags() *FlagSets {
141142
Name: flagNamePassthroughRequestHeaders,
142143
Target: &c.flagPassthroughRequestHeaders,
143144
Usage: "Comma-separated string or list of request header values that " +
144-
"will be sent to the backend",
145+
"will be sent to the plugins",
146+
})
147+
148+
f.StringSliceVar(&StringSliceVar{
149+
Name: flagNameAllowedResponseHeaders,
150+
Target: &c.flagAllowedResponseHeaders,
151+
Usage: "Comma-separated string or list of response header values that " +
152+
"plugins will be allowed to set",
145153
})
146154

147155
f.BoolVar(&BoolVar{
@@ -284,6 +292,10 @@ func (c *SecretsEnableCommand) Run(args []string) int {
284292
if fl.Name == flagNamePassthroughRequestHeaders {
285293
mountInput.Config.PassthroughRequestHeaders = c.flagPassthroughRequestHeaders
286294
}
295+
296+
if fl.Name == flagNameAllowedResponseHeaders {
297+
mountInput.Config.AllowedResponseHeaders = c.flagAllowedResponseHeaders
298+
}
287299
})
288300

289301
if err := client.Sys().Mount(mountPath, mountInput); err != nil {

helper/forwarding/types.pb.go

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

helper/identity/mfa/types.pb.go

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

helper/identity/types.pb.go

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

helper/storagepacker/types.pb.go

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)