This is an automated email from the ASF dual-hosted git repository.
fokko pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-go.git
The following commit(s) were added to refs/heads/main by this push:
new 5db83a0 feat(catalog): Send X-Iceberg-Access-Delegation header to
signal support for vended credentials (#67)
5db83a0 is described below
commit 5db83a0d711481ef798c90ae1ad89076db743082
Author: Eduard Tudenhoefner <[email protected]>
AuthorDate: Fri Feb 16 17:32:13 2024 +0100
feat(catalog): Send X-Iceberg-Access-Delegation header to signal support
for vended credentials (#67)
Clients can optionally send this header to signal which delegated access
pattern it can support. At this point the iceberg-go client can only
support `vended-credentials` out-of-the-box, thus we can always send
this header.
Addtional details about this header can be found in the REST OpenAPI
spec:
https://github.com/apache/iceberg/blob/main/open-api/rest-catalog-open-api.yaml#L1459-L1483
---
catalog/rest.go | 1 +
catalog/rest_internal_test.go | 18 ++++++++++--------
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/catalog/rest.go b/catalog/rest.go
index 93030bd..ef9c332 100644
--- a/catalog/rest.go
+++ b/catalog/rest.go
@@ -471,6 +471,7 @@ func (r *RestCatalog) createSession(opts *options)
(*http.Client, error) {
session.defaultHeaders.Set("X-Client-Version", icebergRestSpecVersion)
session.defaultHeaders.Set("Content-Type", "application/json")
session.defaultHeaders.Set("User-Agent", "GoIceberg/"+iceberg.Version())
+ session.defaultHeaders.Set("X-Iceberg-Access-Delegation",
"vended-credentials")
if opts.enableSigv4 {
cfg, err := config.LoadDefaultConfig(context.Background())
diff --git a/catalog/rest_internal_test.go b/catalog/rest_internal_test.go
index 8a2966d..a03e2a5 100644
--- a/catalog/rest_internal_test.go
+++ b/catalog/rest_internal_test.go
@@ -66,10 +66,11 @@ func TestAuthHeader(t *testing.T) {
require.IsType(t, (*sessionTransport)(nil), cat.cl.Transport)
assert.Equal(t, http.Header{
- "Authorization": {"Bearer some_jwt_token"},
- "Content-Type": {"application/json"},
- "User-Agent": {"GoIceberg/(unknown version)"},
- "X-Client-Version": {icebergRestSpecVersion},
+ "Authorization": {"Bearer some_jwt_token"},
+ "Content-Type": {"application/json"},
+ "User-Agent": {"GoIceberg/(unknown version)"},
+ "X-Client-Version": {icebergRestSpecVersion},
+ "X-Iceberg-Access-Delegation": {"vended-credentials"},
}, cat.cl.Transport.(*sessionTransport).defaultHeaders)
}
@@ -113,9 +114,10 @@ func TestAuthUriHeader(t *testing.T) {
require.IsType(t, (*sessionTransport)(nil), cat.cl.Transport)
assert.Equal(t, http.Header{
- "Authorization": {"Bearer some_jwt_token"},
- "Content-Type": {"application/json"},
- "User-Agent": {"GoIceberg/(unknown version)"},
- "X-Client-Version": {icebergRestSpecVersion},
+ "Authorization": {"Bearer some_jwt_token"},
+ "Content-Type": {"application/json"},
+ "User-Agent": {"GoIceberg/(unknown version)"},
+ "X-Client-Version": {icebergRestSpecVersion},
+ "X-Iceberg-Access-Delegation": {"vended-credentials"},
}, cat.cl.Transport.(*sessionTransport).defaultHeaders)
}