-
Notifications
You must be signed in to change notification settings - Fork 351
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
Adds HeaderSHA256
predicate
#1905
Conversation
96bd1c4
to
bb9d8ec
Compare
Hash values only hide secrets from parties that have access to the source of Skipper routes. | ||
Authentication strength depends on the strength of the secret value so e.g. | ||
`HeaderSHA256("X-Secret", "2bb80d537b1da3e38bd30361aa855686bde0eacd7162fef6a25fe97bf527a25b")` | ||
is not stronger than just `Header("X-Secret", "secret")`. |
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.
discuss: add salt?
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.
Added guide on how to generate secure header value.
I think salt is not required if secret value is random, its length is at least 32 bytes (SHA-256 output size) and there is no need to hide the possible reuse of the same secret value in several routes.
In general proper salt value has its own requirements so the idea is to get rid of it if possible to minimize number of parameters that users need to specify and understand.
What's the use case? |
Match routes with known header value without revealing the actual value to the parties that have access to the routes source (source code, ingress definitions, allowed to query
The benchmark shows that it takes 340 ns to match header hash.
If that happens we will introduce
This predicate allows users to implement Basic Authentication as well as shown in the docs without revealing the username:password pair. |
### HeaderSHA256 | ||
|
||
Matches if SHA-256 hash of the header value (secret) equals to any of the configured hash values. | ||
Several hash values could be used to match multiple secrets e.g. during secret rotation. |
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.
The same could be achieved using two routes with two different HeaderSHA256
but it is more convenient to use single predicate with multiple secrets to avoid route duplication, e.g. in zalando.org/skipper-predicate
ingress annotation.
4a43994
to
d533822
Compare
58e9404
to
b2c4473
Compare
👍 |
b2c4473
to
cc0fc2b
Compare
`HeaderSHA256` predicate matches SHA-256 hash of the configured header value. ``` go test ./predicates/auth/ -run NONE -bench BenchmarkHeaderSHA256Match -benchmem goos: linux goarch: amd64 pkg: github.com/zalando/skipper/predicates/auth cpu: Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz BenchmarkHeaderSHA256Match-8 4675351 237.2 ns/op 0 B/op 0 allocs/op ``` Signed-off-by: Alexander Yastrebov <[email protected]>
cc0fc2b
to
e4a3167
Compare
👍 |
1 similar comment
👍 |
HeaderSHA256
predicate matches SHA-256 hash of the configured header value.Signed-off-by: Alexander Yastrebov [email protected]