Repository navigation
[encryption]: Add skipEncodings to avoid double-encrypting payloads #201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,7 +114,11 @@ func New(ctx context.Context, cfg *config.Config, opts ...Option) (*Dataplane, e | |
| // Every upstream applies the same chain: the vault and the encryption switch | ||
| // are global, so nothing here varies per upstream. Building it once is also | ||
| // what lets the codec server apply the identical chain. | ||
| codecOpts := proxy.CodecOptions{Encrypt: cfg.Encryption.Enabled, EncodeFailures: cfg.Encryption.Failures} | ||
| codecOpts := proxy.CodecOptions{ | ||
| Encrypt: cfg.Encryption.Enabled, | ||
| EncodeFailures: cfg.Encryption.Failures, | ||
| SkipEncodings: cfg.Encryption.SkipEncodings, | ||
| } | ||
|
|
||
| // Only assign the vault once it is known to be there. o.vault is a concrete | ||
| // pointer and the field is an interface, so assigning unconditionally would | ||
|
|
@@ -144,6 +148,11 @@ func New(ctx context.Context, cfg *config.Config, opts ...Option) (*Dataplane, e | |
| ) | ||
| } | ||
|
|
||
| // With no keys there is no encryption codec, so the list has nothing to skip. | ||
| if len(cfg.Encryption.SkipEncodings) > 0 && o.vault == nil { | ||
| o.logger.Warn("encryption.skipEncodings is set but no encryption keys are configured, so it has no effect") | ||
| } | ||
|
|
||
|
Comment on lines
+151
to
+155
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. im fine with this but there is an argument for just failing invalid/non-effect configs
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. So far, I've been failing cases where behaviour would be invalid (e.g., enabling encryption without a default key policy) and warning about things that are ineffectual or don't break an invariant (e.g., apiTranslations defined with no Cloud upstream). I absolutely don't feel super strongly about this, so if you'd prefer an error case here, say the word. |
||
| dp := &Dataplane{ | ||
| ctx: ctx, | ||
| hostPort: cfg.Listen.HostPort, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
Maybe note in the commend that this is a header?
It looks like a header, but might as well be very explicit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They're actually fields (Payload.Metadata["encoding"]) set by PayloadCodecs.