mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-10 23:57:34 +02:00
authorize: add sid to JWT claims (#2420)
* authorize: add sid to JWT claims * fix import ordering
This commit is contained in:
parent
97af64df60
commit
a64e5b5fa1
2 changed files with 13 additions and 2 deletions
|
@ -14,6 +14,7 @@ import (
|
|||
|
||||
"github.com/pomerium/pomerium/config"
|
||||
"github.com/pomerium/pomerium/pkg/cryptutil"
|
||||
"github.com/pomerium/pomerium/pkg/grpc/session"
|
||||
)
|
||||
|
||||
func TestHeadersEvaluator(t *testing.T) {
|
||||
|
@ -41,10 +42,16 @@ func TestHeadersEvaluator(t *testing.T) {
|
|||
|
||||
t.Run("jwt", func(t *testing.T) {
|
||||
output, err := eval(t,
|
||||
[]proto.Message{},
|
||||
[]proto.Message{
|
||||
&session.Session{Id: "s1", ImpersonateSessionId: proto.String("s2")},
|
||||
&session.Session{Id: "s2"},
|
||||
},
|
||||
&HeadersRequest{
|
||||
FromAudience: "from.example.com",
|
||||
ToAudience: "to.example.com",
|
||||
Session: RequestSession{
|
||||
ID: "s1",
|
||||
},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
|
@ -56,8 +63,8 @@ func TestHeadersEvaluator(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
|
||||
assert.Equal(t, claims["exp"], math.Round(claims["exp"].(float64)))
|
||||
|
||||
assert.LessOrEqual(t, claims["exp"], float64(time.Now().Add(time.Minute*6).Unix()),
|
||||
"JWT should expire within 5 minutes, but got: %v", claims["exp"])
|
||||
assert.Equal(t, "s1", claims["sid"], "should set session id to input session id")
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue