Skip to content

Commit

Permalink
Merge branch 'master' into config_auth_servers_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kontsevoy authored Oct 27, 2016
2 parents 59388ae + 14dd7ff commit d1ca86d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 7 additions & 0 deletions lib/services/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ type User interface {
Check() error
// Equals checks if user equals to another
Equals(other User) bool
// WebSessionInfo returns web session information
WebSessionInfo() User
}

// TeleportUser is an optional user entry in the database
Expand Down Expand Up @@ -91,6 +93,11 @@ func (u *TeleportUser) Equals(other User) bool {
return true
}

// WebSessionInfo returns web session information
func (u *TeleportUser) WebSessionInfo() User {
return u
}

// GetAllowedLogins returns user's allowed linux logins
func (u *TeleportUser) GetAllowedLogins() []string {
return u.AllowedLogins
Expand Down
5 changes: 3 additions & 2 deletions lib/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ func (r createSessionResponseRaw) response() (*CreateSessionResponse, error) {
if err != nil {
return nil, trace.Wrap(err)
}
return &CreateSessionResponse{Type: r.Type, Token: r.Token, ExpiresIn: r.ExpiresIn, User: user}, nil
return &CreateSessionResponse{Type: r.Type, Token: r.Token, ExpiresIn: r.ExpiresIn, User: user.WebSessionInfo()}, nil
}

func NewSessionResponse(ctx *SessionContext) (*CreateSessionResponse, error) {
Expand All @@ -449,7 +449,7 @@ func NewSessionResponse(ctx *SessionContext) (*CreateSessionResponse, error) {
return &CreateSessionResponse{
Type: roundtrip.AuthBearer,
Token: webSession.WS.BearerToken,
User: user,
User: user.WebSessionInfo(),
ExpiresIn: int(time.Now().Sub(webSession.WS.Expires) / time.Second),
}, nil
}
Expand Down Expand Up @@ -989,6 +989,7 @@ func (m *Handler) siteSessionStreamGet(w http.ResponseWriter, r *http.Request, p
// authenticate first:
_, err := m.AuthenticateRequest(w, r, true)
if err != nil {
log.Info(err)
// clear session just in case if the authentication request is not valid
ClearSession(w)
onError(err)
Expand Down

0 comments on commit d1ca86d

Please sign in to comment.