zalando / skipper

An HTTP router and reverse proxy for service composition, including use cases like Kubernetes Ingress
https://opensource.zalando.com/skipper/
Other
3.07k stars 346 forks source link

AWS sigv4 auth filter #2911

Closed szuecs closed 1 month ago

szuecs commented 6 months ago

Sometimes you want to proxy to an aws service and aws uses sigv4 to do authnz. It would be great to be able to sign with sigv4 the request with https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/aws/signer/v4#HTTPSigner to be able to call AWS services from the proxy itself.

Maybe leverage a similar kind of roundtripper which depends also on aws sdk https://github.com/prometheus/common/blob/main/sigv4/sigv4.go

Anurag252 commented 6 months ago

Hey @szuecs I can take a look at this one. My thoughts around this

I believe we need to consider that

szuecs commented 6 months ago

@Anurag252 I am not sure if I want to have the AWS sdk as dependency, rather not. I think it seems to be open enough to build this without AWS SDK, but I am not sure.

Anurag252 commented 6 months ago

@Anurag252 I am not sure if I want to have the AWS sdk as dependency, rather not. I think it seems to be open enough to build this without AWS SDK, but I am not sure.

@szuecs makes sense to me. I can try and implement this . What are your thoughts around reading the whole body in filter ( as described in point 2 of considerations) ?

szuecs commented 6 months ago

@Anurag252 I am not sure if I want to have the AWS sdk as dependency, rather not. I think it seems to be open enough to build this without AWS SDK, but I am not sure.

@szuecs makes sense to me. I can try and implement this . What are your thoughts around reading the whole body in filter ( as described in point 2 of considerations) ?

Sounds like we have to do it. Not sure if it makes sense to have 2 kind of filters, 1 that requires body and the other which does not.

Similar to https://opensource.zalando.com/skipper/reference/filters/#opaauthorizerequest and https://opensource.zalando.com/skipper/reference/filters/#opaauthorizerequestwithbody

What do you think?

Anurag252 commented 6 months ago

@Anurag252 I am not sure if I want to have the AWS sdk as dependency, rather not. I think it seems to be open enough to build this without AWS SDK, but I am not sure.

@szuecs makes sense to me. I can try and implement this . What are your thoughts around reading the whole body in filter ( as described in point 2 of considerations) ?

Sounds like we have to do it. Not sure if it makes sense to have 2 kind of filters, 1 that requires body and the other which does not.

Similar to https://opensource.zalando.com/skipper/reference/filters/#opaauthorizerequest and https://opensource.zalando.com/skipper/reference/filters/#opaauthorizerequestwithbody

What do you think?

Okay then I can probably take a param in CreateFilter which would denote the maximum body size (like opaAuthorizeRequestWithBody ) that could be read and keep default as 8kb (? or any other size) .

I could not think of a reason when having two filters would be better, but I maybe missing out some case 🤔 .
Even with no body present documentation mentions including empty body in signature generation like so Hex(SHA256Hash(""))

szuecs commented 6 months ago

Okay then I can probably take a param in CreateFilter which would denote the maximum body size (like opaAuthorizeRequestWithBody ) that could be read and keep default as 8kb (? or any other size) .

I could not think of a reason when having two filters would be better, but I maybe missing out some case 🤔 . Even with no body present documentation mentions including empty body in signature generation like so Hex(SHA256Hash(""))

Then I would ignore it and handle it inside the filter. For example you can use ContentLength to detect a request without body. So basically:

var data string
if ContentLength != 0 {
   data = ...read body and make it string..
}
..Hex(SHA256Hash(data)) ..
Anurag252 commented 6 months ago

Okay then I can probably take a param in CreateFilter which would denote the maximum body size (like opaAuthorizeRequestWithBody ) that could be read and keep default as 8kb (? or any other size) . I could not think of a reason when having two filters would be better, but I maybe missing out some case 🤔 . Even with no body present documentation mentions including empty body in signature generation like so Hex(SHA256Hash(""))

Then I would ignore it and handle it inside the filter. For example you can use ContentLength to detect a request without body. So basically:

var data string
if ContentLength != 0 {
   data = ...read body and make it string..
}
..Hex(SHA256Hash(data)) ..

makes sense. I will try to submit a PR 👍