This repository was archived by the owner on Nov 9, 2017. It is now read-only.
forked from kriswallsmith/TwitterBundle
-
Notifications
You must be signed in to change notification settings - Fork 38
fix firewall to answer all login entry points #35
Open
bitgandtter
wants to merge
5
commits into
FriendsOfSymfony:master
Choose a base branch
from
bitgandtter:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
92deac9
fixing firewall only response to the entry point if there is a query …
bitgandtter ef362c0
upgrading to 2.1
bitgandtter 5b53140
upgrading to 2.1
bitgandtter 5310037
applying changes from pull request comments
bitgandtter 6d658d9
applying changes from pull request comments
bitgandtter 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,9 @@ public function setUseTwitterAnywhere($bool) | |
|
||
protected function attemptAuthentication(Request $request) | ||
{ | ||
if($request->getSession()->get("oauth_token", null) && $request->get("oauth_token", null) && | ||
$request->getSession()->get("oauth_token", null) === $request->get("oauth_token", null)) | ||
{ | ||
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. please use an early return instead. |
||
if ($this->useTwitterAnywhere) { | ||
if (null === $identity = $request->cookies->get('twitter_anywhere_identity')) { | ||
throw new AuthenticationException(sprintf('Identity cookie "twitter_anywhere_identity" was not sent.')); | ||
|
@@ -43,5 +46,6 @@ protected function attemptAuthentication(Request $request) | |
} | ||
|
||
return $this->authenticationManager->authenticate(new TwitterUserToken($request->query->get('oauth_token'), $request->query->get('oauth_verifier'))); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the FOSTwitterBundle package. | ||
* | ||
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace FOS\TwitterBundle\Security\Firewall; | ||
|
||
use FOS\TwitterBundle\Security\Authentication\Token\TwitterAnywhereToken; | ||
use Symfony\Component\Security\Core\Exception\AuthenticationException; | ||
use FOS\TwitterBundle\Security\Authentication\Token\TwitterUserToken; | ||
use Symfony\Component\Security\Http\Firewall\AbstractAuthenticationListener; | ||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
/** | ||
* Twitter authentication listener. | ||
*/ | ||
class TwitterListener extends AbstractAuthenticationListener | ||
{ | ||
private $useTwitterAnywhere = false; | ||
|
||
public function setUseTwitterAnywhere($bool) | ||
{ | ||
$this->useTwitterAnywhere = (Boolean) $bool; | ||
} | ||
|
||
protected function attemptAuthentication(Request $request) | ||
{ | ||
if($request->getSession()->get("oauth_token") || $request->get("oauth_token") || | ||
$request->getSession()->get("oauth_token") != $request->get("oauth_token")) | ||
return false; | ||
|
||
if ($this->useTwitterAnywhere) { | ||
if (null === $identity = $request->cookies->get('twitter_anywhere_identity')) { | ||
throw new AuthenticationException(sprintf('Identity cookie "twitter_anywhere_identity" was not sent.')); | ||
} | ||
if (false === $pos = strpos($identity, ':')) { | ||
throw new AuthenticationException(sprintf('The submitted identity "%s" is invalid.', $identity)); | ||
} | ||
|
||
return $this->authenticationManager->authenticate(TwitterAnywhereToken::createUnauthenticated(substr($identity, 0, $pos), substr($identity, $pos + 1))); | ||
} | ||
|
||
return $this->authenticationManager->authenticate(new TwitterUserToken($request->query->get('oauth_token'), $request->query->get('oauth_verifier'))); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -21,4 +21,4 @@ | |
"psr-0": { "FOS\\TwitterBundle": "" } | ||
}, | ||
"target-dir": "FOS/TwitterBundle" | ||
} | ||
} |
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.
null
is the default so you can simply omit it