Skip to content

Commit

Permalink
append token data also in introspection
Browse files Browse the repository at this point in the history
  • Loading branch information
256dpi committed Nov 26, 2019
1 parent f867126 commit 0588120
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions flame/authenticator.go
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,12 @@ func (a *Authenticator) introspectionEndpoint(env *environment) {
return
}

// get resource owner
var resourceOwner ResourceOwner
if data.ResourceOwnerID != nil {
resourceOwner = a.getFirstResourceOwner(env, client, *data.ResourceOwnerID)
}

// get validity
expired := data.ExpiresAt.Before(time.Now())

Expand All @@ -834,6 +840,7 @@ func (a *Authenticator) introspectionEndpoint(env *environment) {
res.ExpiresAt = data.ExpiresAt.Unix()
res.IssuedAt = token.ID().Timestamp().Unix()
res.Identifier = token.ID().Hex()
res.Extra = a.policy.TokenData(client, resourceOwner, token)
}
}

Expand Down
3 changes: 2 additions & 1 deletion flame/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ type Policy struct {
ApproveStrategy func(GenericToken, oauth2.Scope, Client, ResourceOwner) (oauth2.Scope, error)

// TokenData may return a map of data that should be included in the
// generated JWT tokens as the "dat" field.
// generated JWT tokens as the "dat" field as well as in the token
// introspection's response "extra" field.
TokenData func(Client, ResourceOwner, GenericToken) map[string]interface{}

// The token and code lifespans.
Expand Down

0 comments on commit 0588120

Please sign in to comment.