mirror of
https://github.com/pomerium/pomerium.git
synced 2025-04-29 18:36:30 +02:00
envoy: add jwt-assertion (#727)
Signed-off-by: Bobby DeSimone <bobbydesimone@gmail.com>
This commit is contained in:
parent
1859f6d06b
commit
ca499ac9be
2 changed files with 41 additions and 0 deletions
|
@ -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"},
|
||||||
|
|
|
@ -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")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue