envoy: add jwt-assertion (#727)

Signed-off-by: Bobby DeSimone <bobbydesimone@gmail.com>
This commit is contained in:
Bobby DeSimone 2020-05-19 08:34:49 -07:00 committed by GitHub
parent 1859f6d06b
commit ca499ac9be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 0 deletions

View file

@ -91,6 +91,14 @@ func (a *Authorize) Check(ctx context.Context, in *envoy_service_auth_v2.CheckRe
evt = evt.Str("session", string(sess)) evt = evt.Str("session", string(sess))
evt.Msg("authorize check") evt.Msg("authorize check")
requestHeaders = append(requestHeaders,
&envoy_api_v2_core.HeaderValueOption{
Header: &envoy_api_v2_core.HeaderValue{
Key: "x-pomerium-jwt-assertion",
Value: reply.SignedJwt,
},
})
if reply.Allow { if reply.Allow {
return &envoy_service_auth_v2.CheckResponse{ return &envoy_service_auth_v2.CheckResponse{
Status: &status.Status{Code: int32(codes.OK), Message: "OK"}, Status: &status.Status{Code: int32(codes.OK), Message: "OK"},

View file

@ -376,3 +376,36 @@ func TestSNIMismatch(t *testing.T) {
assert.Equal(t, http.StatusOK, res.StatusCode) assert.Equal(t, http.StatusOK, res.StatusCode)
} }
func TestAttestationJWT(t *testing.T) {
ctx := mainCtx
ctx, clearTimeout := context.WithTimeout(ctx, time.Second*30)
defer clearTimeout()
client := testcluster.NewHTTPClient()
req, err := http.NewRequestWithContext(ctx, "GET", "https://httpdetails.localhost.pomerium.io/", nil)
if err != nil {
t.Fatal(err)
}
res, err := client.Do(req)
if !assert.NoError(t, err, "unexpected http error") {
return
}
defer res.Body.Close()
var result struct {
Headers map[string]string `json:"headers"`
}
err = json.NewDecoder(res.Body).Decode(&result)
if !assert.NoError(t, err) {
return
}
assert.NotEmpty(t,
"X-Pomerium-Jwt-Assertion-Value",
result.Headers["X-Pomerium-Jwt-Assertion"],
"Expected JWT assertion")
}