Skip to content

Commit

Permalink
Add extra data from token introspection to session
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr authored and arekkas committed Nov 28, 2017
1 parent 73994b8 commit ce8f9f2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
3 changes: 3 additions & 0 deletions evaluator/evaluator_warden.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ func (d *WardenEvaluator) EvaluateAccessRequest(r *http.Request) (*Session, erro
User: introspection.Sub,
ClientID: introspection.ClientId,
Anonymous: false,
Extra: introspection.Ext,
}, nil
case rule.AuthenticatedMode:
if token == "" {
Expand Down Expand Up @@ -229,6 +230,7 @@ func (d *WardenEvaluator) EvaluateAccessRequest(r *http.Request) (*Session, erro
User: introspection.Sub,
ClientID: introspection.ClientId,
Anonymous: false,
Extra: introspection.Ext,
}, nil
case rule.PolicyMode:
if token == "" {
Expand Down Expand Up @@ -297,6 +299,7 @@ func (d *WardenEvaluator) EvaluateAccessRequest(r *http.Request) (*Session, erro
User: introspection.Subject,
ClientID: introspection.ClientId,
Anonymous: false,
Extra: introspection.AccessTokenExtra,
}, nil
default:
d.Logger.WithError(err).
Expand Down
12 changes: 7 additions & 5 deletions evaluator/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import (
)

type Session struct {
User string `json:"user"`
Anonymous bool `json:"anonymous"`
Disabled bool `json:"disabled"`
ClientID string `json:"clientId"`
Issuer string `json:"issuer"`
User string `json:"user"`
Anonymous bool `json:"anonymous"`
Disabled bool `json:"disabled"`
ClientID string `json:"clientId"`
Issuer string `json:"issuer"`
Extra interface{} `json:"extra"`
}

func (s *Session) ToClaims() jwt.MapClaims {
Expand All @@ -25,5 +26,6 @@ func (s *Session) ToClaims() jwt.MapClaims {
"anon": s.Anonymous,
"aud": s.ClientID,
"jti": uuid.New(),
"ext": s.Extra,
}
}

0 comments on commit ce8f9f2

Please sign in to comment.