Skip to content
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

Symfony 3: updates to @famoser's fork #25

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea
vendor
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
What is Shibboleth again?
==================
Sibboleth is a tool installed on the server, depending on the setup you can activate it with the .htaccess configuration as provided below or you may need to ask your server administration. If activated correctly it allows for your user to login at the provider used by your server, and afterwards adds additional header containing the authentication information on __each__ request, to be used by your application. You can test if all works nicely by simply dumping the headers: `dump($request->headers)`.
The Shibboleth bundle aims to integrate this authentication fully into symfony; it adds firewalls and user managers to archive this. This fork simply makes the project compatible with symfony 3, and tries not to change existing behaviour. If an additional firewall is overkill for you, you might want to skip the installation of this Bundle, and rather set up listeners on kernel events which handle the authentification.

ShibbolethBundle
================

This bundle adds a shibboleth authentication provider for your Symfony2 project.
This bundle adds a shibboleth authentication provider for your Symfony3 project.

Requirements
------------
* [PHP](http://php.net) 5.3.3 and up.
* [Symfony 2.2+][http://symfony.com]
* [Symfony 3.0+][http://symfony.com]

Installation
------------
Expand Down
2 changes: 1 addition & 1 deletion Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<service id="security.authentication.listener.shibboleth"
class="KULeuven\ShibbolethBundle\Security\ShibbolethListener" public="false">
<tag name="monolog.logger" channel="security" />
<argument type="service" id="security.context"/>
<argument type="service" id="security.token_storage"/>
<argument type="service" id="security.authentication.manager" />
<argument type="service" id="shibboleth" />
<argument /> <!-- Provider-shared Key -->
Expand Down
9 changes: 6 additions & 3 deletions Security/ShibbolethListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
namespace KULeuven\ShibbolethBundle\Security;

use KULeuven\ShibbolethBundle\Service\Shibboleth;
use Symfony\Component\Security\Core\SecurityContextInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Http\Firewall\ListenerInterface;
Expand All @@ -40,6 +40,7 @@

class ShibbolethListener implements ListenerInterface
{
/* @var TokenStorageInterface $securityContext */
private $securityContext;
private $authenticationManager;
private $providerKey;
Expand All @@ -50,7 +51,7 @@ class ShibbolethListener implements ListenerInterface
private $shibboleth;

public function __construct(
SecurityContextInterface $securityContext,
TokenStorageInterface $securityContext,
AuthenticationManagerInterface $authenticationManager,
Shibboleth $shibboleth,
$providerKey = null,
Expand All @@ -74,6 +75,7 @@ public function __construct(

public function handle(GetResponseEvent $event)
{
/** @var Request $request */
$request = $event->getRequest();

if (!$this->shibboleth->isAuthenticated($request)) {
Expand All @@ -85,6 +87,7 @@ public function handle(GetResponseEvent $event)
}

$username = $this->shibboleth->getUser($request);
$username = substr($username, 0, strpos($username, '@'));

if (null !== $this->logger) {
$this->logger->debug(sprintf('Shibboleth service returned user: %s', $username));
Expand Down
10 changes: 8 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "kuleuven/shibboleth-bundle",
"name": "famoser/shibboleth-bundle",
"description": "Symfony2 authentication provider for Shibboleth",
"keywords": ["authentication","security","shibboleth"],
"type": "symfony-bundle",
Expand All @@ -10,9 +10,15 @@
},
{
"name": "Bert Van Gelder"
},
{
"name": "Florian Moser"
}
],
"autoload": {
"psr-4": { "KULeuven\\ShibbolethBundle\\": "" }
},
"require": {
"symfony/symfony": "^3.1"
}
}
}
Loading