Skip to content

Commit

Permalink
Regenerate the sessionID after login.
Browse files Browse the repository at this point in the history
This is to prevent attacks where someone starts a session on a public
computer, notes the session ID, then when another user logs in (with
the same sessionID), the first user is able to hijack the session.

This way each login results in a new session ID, so anyone snooping
the old ID is out of luck.
  • Loading branch information
jasononeil committed Jul 21, 2015
1 parent de3d84e commit 9e4b082
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/ufront/auth/EasyAuth.hx
Expand Up @@ -102,6 +102,7 @@ using tink.CoreApi;
if ( u!=null ) {
_currentUser = u;
context.session.set(sessionVariableName, (u!=null) ? u.id : null);
context.session.regenerateID();
}
else throw 'Could not set the current user to $user, because that user is not a ufront.auth.model.User';
}
Expand Down Expand Up @@ -133,6 +134,7 @@ using tink.CoreApi;
switch ( r ) {
case Success(user):
context.session.set( sessionVariableName, user.id );
context.session.regenerateID();
case Failure(_):
}
});
Expand All @@ -147,6 +149,7 @@ using tink.CoreApi;
switch result {
case Success(user):
context.session.set( sessionVariableName, user.id );
context.session.regenerateID();
case Failure(_):
}

Expand Down

0 comments on commit 9e4b082

Please sign in to comment.