This repository was archived by the owner on Jun 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Remove response injection & update interfaces #5
Open
awartoft
wants to merge
6
commits into
Bacon:master
Choose a base branch
from
awartoft:feature/exchange-interface-and-response
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 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
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
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
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
26 changes: 0 additions & 26 deletions
26
src/BaconAuthentication/Plugin/EventAwarePluginInterface.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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,6 @@ | |
| use Zend\Http\PhpEnvironment\Request as HttpRequest; | ||
| use Zend\Http\Response as HttpResponse; | ||
| use Zend\Stdlib\RequestInterface; | ||
| use Zend\Stdlib\ResponseInterface; | ||
| use Zend\Stdlib\Parameters; | ||
|
|
||
| /** | ||
|
|
@@ -43,10 +42,9 @@ public function setRealm($realm) | |
| * | ||
| * @see ExtractionPluginInterface::extractCredentials() | ||
| * @param RequestInterface $request | ||
| * @param ResponseInterface $response | ||
| * @return null|Parameters | ||
| */ | ||
| public function extractCredentials(RequestInterface $request, ResponseInterface $response) | ||
| public function extractCredentials(RequestInterface $request) | ||
| { | ||
| if (!$request instanceof HttpRequest) { | ||
| return null; | ||
|
|
@@ -70,21 +68,18 @@ public function extractCredentials(RequestInterface $request, ResponseInterface | |
| * | ||
| * @see ChallengePluginInterface::challenge() | ||
| * @param RequestInterface $request | ||
| * @param ResponseInterface $response | ||
| * @return bool | ||
| */ | ||
| public function challenge(RequestInterface $request, ResponseInterface $response) | ||
| public function challenge(RequestInterface $request) | ||
| { | ||
| if (!$response instanceof HttpResponse) { | ||
| if (!$request instanceof HttpRequest) { | ||
| return false; | ||
|
Member
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. Either return null or a Response, not false. Also update interface and docblocks. |
||
| } | ||
|
|
||
| $response->getHeaders()->addHeaderLine( | ||
| 'WWW-Authenticate', | ||
| 'Basic realm="' . addslashes($this->realm) . '"' | ||
| ); | ||
| $response = new HttpResponse(); | ||
| $response->setStatusCode(401); | ||
| $response->getHeaders()->addHeaderLine('WWW-Authenticate', 'Basic realm="' . addslashes($this->realm) . '"'); | ||
|
|
||
| return true; | ||
| return $response; | ||
| } | ||
| } | ||
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 |
|---|---|---|
|
|
@@ -12,16 +12,15 @@ | |
| use BaconAuthentication\AuthenticationEvent; | ||
| use BaconAuthentication\Result\Result; | ||
| use Zend\EventManager\EventManagerInterface; | ||
| use Zend\EventManager\ListenerAggregateInterface; | ||
| use Zend\Session\ManagerInterface; | ||
| use Zend\Session\Container as SessionContainer; | ||
| use Zend\Stdlib\RequestInterface; | ||
|
|
||
| /** | ||
| * Plugin responsible for tracking the identity between multiple HTTP requests. | ||
| */ | ||
| class Session implements | ||
| EventAwarePluginInterface, | ||
| ResetPluginInterface | ||
| class Session implements ListenerAggregateInterface, ResetPluginInterface | ||
| { | ||
| /** | ||
| * Default session namespace. | ||
|
|
@@ -33,6 +32,11 @@ class Session implements | |
| */ | ||
| protected $session; | ||
|
|
||
| /** | ||
| * @var array | ||
| */ | ||
| protected $listeners = []; | ||
|
Author
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. Ops |
||
|
|
||
| /** | ||
| * @param string|null $namespace | ||
| * @param ManagerInterface $manager | ||
|
|
@@ -53,10 +57,25 @@ public function __construct($namespace = null, ManagerInterface $manager = null) | |
| * @param EventManagerInterface $events | ||
| * @return void | ||
| */ | ||
| public function attachToEvents(EventManagerInterface $events) | ||
| public function attach(EventManagerInterface $events) | ||
| { | ||
| $this->listeners[] = $events->attach( | ||
| AuthenticationEvent::EVENT_AUTHENTICATE_PRE, | ||
| array($this, 'checkSession') | ||
| ); | ||
|
|
||
| $this->listeners[] = $events->attach( | ||
| AuthenticationEvent::EVENT_AUTHENTICATE_POST, | ||
| array($this, 'storeIdentifier') | ||
| ); | ||
| } | ||
|
|
||
| public function detach(EventManagerInterface $events) | ||
| { | ||
| $events->attach(AuthenticationEvent::EVENT_AUTHENTICATE_PRE, array($this, 'checkSession')); | ||
| $events->attach(AuthenticationEvent::EVENT_AUTHENTICATE_POST, array($this, 'storeIdentifier')); | ||
| foreach ($this->listeners as $idx => $callback) { | ||
|
Member
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 write it out: |
||
| $events->detach($callback); | ||
| unset($this->listeners[$idx]); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
|
|
||
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
Oops, something went wrong.
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.
How can it be false?
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.
Because the pluggableAuthenticationService::challenge returns boolean
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.
Correct, but it shouldn't, see my other comment about that.