Skip to content

Commit

Permalink
core: resolve issues with token introspection and sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Nov 17, 2016
1 parent 81a3229 commit 895d169
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions handler/oauth2/strategy_jwt_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ func (s *JWTSession) GetSubject() string {
}

func (s *JWTSession) Clone() fosite.Session {
if s == nil {
return nil
}

var clone JWTSession
var mod bytes.Buffer
enc := gob.NewEncoder(&mod)
Expand Down
4 changes: 4 additions & 0 deletions handler/openid/strategy_jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ func NewDefaultSession() *DefaultSession {
}

func (s *DefaultSession) Clone() fosite.Session {
if s == nil {
return nil
}

var clone DefaultSession
var mod bytes.Buffer
enc := gob.NewEncoder(&mod)
Expand Down
2 changes: 1 addition & 1 deletion introspection_request_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (f *Fosite) NewIntrospectionRequest(ctx context.Context, r *http.Request, s
return nil, errors.Wrap(ErrRequestUnauthorized, "Bearer and introspection token are identical")
}

if _, err := f.IntrospectToken(ctx, clientToken, AccessToken, session); err != nil {
if _, err := f.IntrospectToken(ctx, clientToken, AccessToken, session.Clone()); err != nil {
return nil, errors.Wrap(ErrRequestUnauthorized, "HTTP Authorization header missing, malformed or credentials used are invalid")
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion introspection_request_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func TestNewIntrospectionRequest(t *testing.T) {
},
} {
c.setup()
res, err := f.NewIntrospectionRequest(nil, httpreq, nil)
res, err := f.NewIntrospectionRequest(nil, httpreq, &DefaultSession{})
assert.True(t, errors.Cause(err) == c.expectErr, "(%d) %s\n%s\n%s", k, c.description, err, c.expectErr)
if res != nil {
assert.Equal(t, c.isActive, res.IsActive())
Expand Down
4 changes: 4 additions & 0 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ func (s *DefaultSession) GetSubject() string {
}

func (s *DefaultSession) Clone() Session {
if s == nil {
return nil
}

var clone DefaultSession
var mod bytes.Buffer
enc := gob.NewEncoder(&mod)
Expand Down

0 comments on commit 895d169

Please sign in to comment.