mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-06 10:21:05 +02:00
authorize: add jti to JWT payload (#1328)
This commit is contained in:
parent
fbd8c8f294
commit
51bdf9baae
2 changed files with 7 additions and 0 deletions
|
@ -206,6 +206,7 @@ func (e *Evaluator) JWTPayload(req *Request) map[string]interface{} {
|
||||||
payload["aud"] = u.Hostname()
|
payload["aud"] = u.Hostname()
|
||||||
}
|
}
|
||||||
if s, ok := req.DataBrokerData.Get("type.googleapis.com/session.Session", req.Session.ID).(*session.Session); ok {
|
if s, ok := req.DataBrokerData.Get("type.googleapis.com/session.Session", req.Session.ID).(*session.Session); ok {
|
||||||
|
payload["jti"] = s.GetId()
|
||||||
if tm, err := ptypes.Timestamp(s.GetIdToken().GetExpiresAt()); err == nil {
|
if tm, err := ptypes.Timestamp(s.GetIdToken().GetExpiresAt()); err == nil {
|
||||||
payload["exp"] = tm.Unix()
|
payload["exp"] = tm.Unix()
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,6 +153,7 @@ func TestEvaluator_JWTPayload(t *testing.T) {
|
||||||
DataBrokerData: DataBrokerData{
|
DataBrokerData: DataBrokerData{
|
||||||
"type.googleapis.com/session.Session": map[string]interface{}{
|
"type.googleapis.com/session.Session": map[string]interface{}{
|
||||||
"SESSION_ID": &session.Session{
|
"SESSION_ID": &session.Session{
|
||||||
|
Id: "SESSION_ID",
|
||||||
IdToken: &session.IDToken{
|
IdToken: &session.IDToken{
|
||||||
ExpiresAt: nowPb,
|
ExpiresAt: nowPb,
|
||||||
IssuedAt: nowPb,
|
IssuedAt: nowPb,
|
||||||
|
@ -167,6 +168,7 @@ func TestEvaluator_JWTPayload(t *testing.T) {
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"iss": "authn.example.com",
|
"iss": "authn.example.com",
|
||||||
|
"jti": "SESSION_ID",
|
||||||
"aud": "example.com",
|
"aud": "example.com",
|
||||||
"exp": now.Unix(),
|
"exp": now.Unix(),
|
||||||
"iat": now.Unix(),
|
"iat": now.Unix(),
|
||||||
|
@ -178,6 +180,7 @@ func TestEvaluator_JWTPayload(t *testing.T) {
|
||||||
DataBrokerData: DataBrokerData{
|
DataBrokerData: DataBrokerData{
|
||||||
"type.googleapis.com/session.Session": map[string]interface{}{
|
"type.googleapis.com/session.Session": map[string]interface{}{
|
||||||
"SESSION_ID": &session.Session{
|
"SESSION_ID": &session.Session{
|
||||||
|
Id: "SESSION_ID",
|
||||||
UserId: "USER_ID",
|
UserId: "USER_ID",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -196,6 +199,7 @@ func TestEvaluator_JWTPayload(t *testing.T) {
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"iss": "authn.example.com",
|
"iss": "authn.example.com",
|
||||||
|
"jti": "SESSION_ID",
|
||||||
"aud": "example.com",
|
"aud": "example.com",
|
||||||
"sub": "USER_ID",
|
"sub": "USER_ID",
|
||||||
"user": "USER_ID",
|
"user": "USER_ID",
|
||||||
|
@ -208,6 +212,7 @@ func TestEvaluator_JWTPayload(t *testing.T) {
|
||||||
DataBrokerData: DataBrokerData{
|
DataBrokerData: DataBrokerData{
|
||||||
"type.googleapis.com/session.Session": map[string]interface{}{
|
"type.googleapis.com/session.Session": map[string]interface{}{
|
||||||
"SESSION_ID": &session.Session{
|
"SESSION_ID": &session.Session{
|
||||||
|
Id: "SESSION_ID",
|
||||||
UserId: "USER_ID",
|
UserId: "USER_ID",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -237,6 +242,7 @@ func TestEvaluator_JWTPayload(t *testing.T) {
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"iss": "authn.example.com",
|
"iss": "authn.example.com",
|
||||||
|
"jti": "SESSION_ID",
|
||||||
"aud": "example.com",
|
"aud": "example.com",
|
||||||
"groups": []string{"group1", "group2", "admin", "test"},
|
"groups": []string{"group1", "group2", "admin", "test"},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue