-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[2.2][Security] concurrent sessions #786
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
c0b33f8
added listener, strategy, registry, configuration for concurrent sess…
0f3d7c4
added SessionLogoutHandler to setup of ConcurrentSessionListener
e9bcd84
removed uneeded interface
9f4a52d
Merge branch 'master' of https://github.com/symfony/symfony
507befa
removed security.authentication.session_registry_storage service from…
5559ef8
removed unneeded methods
238606b
Merge branch 'master' of https://github.com/symfony/symfony
455197f
prepare Doctrine implementation of SessionRegistryStorage
a4eeae5
Merge branch 'master' of github.com:paschke/symfony
aadb2a7
default Doctrine implementation of SessionInformation
5b5edd8
Merge branch 'master' of https://github.com/symfony/symfony
33d83b4
removed SessionInformationIterator class
624b01f
forgot query condition
7032534
Merge branch 'master' of github.com:symfony/symfony
bc182f9
added DBAL default implementation of Symfony\Component\Security\Http\…
d0c826a
recreate SessionInformation if they were lost from the registry
c9f08a4
minor fixes
13813da
added listener, strategy, registry, configuration for concurrent sess…
8ef6923
added SessionLogoutHandler to setup of ConcurrentSessionListener
f4f0a8c
removed uneeded interface
e11a540
removed security.authentication.session_registry_storage service from…
a3d0a59
removed unneeded methods
c800408
prepare Doctrine implementation of SessionRegistryStorage
9c8bd21
default Doctrine implementation of SessionInformation
2efbf11
removed SessionInformationIterator class
3cb882c
forgot query condition
0aa9353
added DBAL default implementation of Symfony\Component\Security\Http\…
ff2122b
recreate SessionInformation if they were lost from the registry
efc783b
minor fixes
d302e37
Merge branch 'master' of http://github.com/paschke/symfony
bed28d2
moved DBAL implemention of SessionInformation to /Bridge
29e2f27
Merge branch 'master' of git://github.com/symfony/symfony
7a0f46a
use HttpUtils in ConcurrentSessionListener
ac7a1d6
removed @return void comments
b24a364
Merge branch 'master' of git://github.com/symfony/symfony
f7dfb3f
reacting to comments on PR 786
3cef9bb
reuse the instance level loader n src/Symfony/Bundle/SecurityBundle/D…
d567980
passing sessionStrategy into authenticationListenerFactories individu…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
removed SessionInformationIterator class
- Loading branch information
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,7 +60,7 @@ public function onAuthentication(Request $request, TokenInterface $token) | |
$sessions = $this->registry->getAllSessions($user); | ||
$maxSessions = $this->getMaximumSessionsForThisUser($user); | ||
|
||
if ($sessions->count() >= $maxSessions && $this->alwaysCreateSession !== true) { | ||
if (count($sessions) >= $maxSessions && $this->alwaysCreateSession !== true) { | ||
if ($this->exceptionIfMaximumExceeded) { | ||
throw new \RuntimeException(sprintf('Maximum of sessions (%s) exceeded', $maxSessions)); | ||
} | ||
|
@@ -107,18 +107,15 @@ public function setMaximumSessions($maximumSessions) | |
/** | ||
* Allows subclasses to customise behaviour when too many sessions are detected. | ||
* | ||
* @param SessionInformationIterator $sessions | ||
* @param array $sessions | ||
* @param integer $allowableSessions | ||
* @param SessionRegistry $registry | ||
* @return void | ||
*/ | ||
protected function allowableSessionsExceeded(SessionInformationIterator $sessions, $allowableSessions, SessionRegistry $registry) | ||
protected function allowableSessionsExceeded($sessions, $allowableSessions, SessionRegistry $registry) | ||
{ | ||
// remove oldest sessions from registry | ||
$count = 0; | ||
$sessions->sort(); | ||
|
||
for ($i = $allowableSessions - 1; $i < $sessions->count(); $i++) { | ||
for ($i = $allowableSessions - 1; $i < count($sessions); $i++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
$sessions[$i]->expireNow(); | ||
$registry->setSessionInformation($sessions[$i]); | ||
} | ||
|
157 changes: 0 additions & 157 deletions
157
src/Symfony/Component/Security/Http/Session/SessionInformationIterator.php
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should use an exception of the component here as the Security component always throws its own exception (extending the SPL ones)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
returning MaxSessionsExceededException