Skip to content
Snippets Groups Projects
Commit e2b27987 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Import initial.

parent a92b7a89
No related branches found
No related tags found
No related merge requests found
Showing
with 2749 additions and 0 deletions
UnicaenOauth
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/vendor/bshaffer/oauth2-server-php" />
<excludeFolder url="file://$MODULE_DIR$/vendor/composer" />
<excludeFolder url="file://$MODULE_DIR$/vendor/container-interop/container-interop" />
<excludeFolder url="file://$MODULE_DIR$/vendor/jasig/phpcas" />
<excludeFolder url="file://$MODULE_DIR$/vendor/psr/log" />
<excludeFolder url="file://$MODULE_DIR$/vendor/unicaen/unicaen-ldap" />
<excludeFolder url="file://$MODULE_DIR$/vendor/zendframework/zend-authentication" />
<excludeFolder url="file://$MODULE_DIR$/vendor/zendframework/zend-config" />
<excludeFolder url="file://$MODULE_DIR$/vendor/zendframework/zend-crypt" />
<excludeFolder url="file://$MODULE_DIR$/vendor/zendframework/zend-escaper" />
<excludeFolder url="file://$MODULE_DIR$/vendor/zendframework/zend-eventmanager" />
<excludeFolder url="file://$MODULE_DIR$/vendor/zendframework/zend-filter" />
<excludeFolder url="file://$MODULE_DIR$/vendor/zendframework/zend-form" />
<excludeFolder url="file://$MODULE_DIR$/vendor/zendframework/zend-http" />
<excludeFolder url="file://$MODULE_DIR$/vendor/zendframework/zend-hydrator" />
<excludeFolder url="file://$MODULE_DIR$/vendor/zendframework/zend-i18n" />
<excludeFolder url="file://$MODULE_DIR$/vendor/zendframework/zend-inputfilter" />
<excludeFolder url="file://$MODULE_DIR$/vendor/zendframework/zend-json" />
<excludeFolder url="file://$MODULE_DIR$/vendor/zendframework/zend-ldap" />
<excludeFolder url="file://$MODULE_DIR$/vendor/zendframework/zend-loader" />
<excludeFolder url="file://$MODULE_DIR$/vendor/zendframework/zend-log" />
<excludeFolder url="file://$MODULE_DIR$/vendor/zendframework/zend-math" />
<excludeFolder url="file://$MODULE_DIR$/vendor/zendframework/zend-modulemanager" />
<excludeFolder url="file://$MODULE_DIR$/vendor/zendframework/zend-mvc" />
<excludeFolder url="file://$MODULE_DIR$/vendor/zendframework/zend-serializer" />
<excludeFolder url="file://$MODULE_DIR$/vendor/zendframework/zend-servicemanager" />
<excludeFolder url="file://$MODULE_DIR$/vendor/zendframework/zend-stdlib" />
<excludeFolder url="file://$MODULE_DIR$/vendor/zendframework/zend-uri" />
<excludeFolder url="file://$MODULE_DIR$/vendor/zendframework/zend-validator" />
<excludeFolder url="file://$MODULE_DIR$/vendor/zendframework/zend-view" />
<excludeFolder url="file://$MODULE_DIR$/vendor/zfcampus/zf-api-problem" />
<excludeFolder url="file://$MODULE_DIR$/vendor/zfcampus/zf-content-negotiation" />
<excludeFolder url="file://$MODULE_DIR$/vendor/zfcampus/zf-oauth2" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library name="PHARS">
<CLASSES>
<root url="phar://$MODULE_DIR$/vendor/zendframework/zend-i18n/test/Translator/_files/translations.phar" />
<root url="phar://$MODULE_DIR$/vendor/zendframework/zend-loader/test/_files/PharModuleExplicit.phar" />
<root url="phar://$MODULE_DIR$/vendor/zendframework/zend-loader/test/_files/ApplicationModulePhar.phar" />
<root url="phar://$MODULE_DIR$/composer.phar" />
<root url="phar://$MODULE_DIR$/vendor/zendframework/zend-loader/test/_files/PharModulePharTar.phar.tar" />
<root url="phar://$MODULE_DIR$/vendor/zendframework/zend-view/test/_templates/view.phar" />
<root url="phar://$MODULE_DIR$/vendor/zendframework/zend-loader/test/_files/PharModulePharZip.phar.zip" />
<root url="phar://$MODULE_DIR$/vendor/zendframework/zend-loader/test/_files/PharModuleMap.phar" />
<root url="phar://$MODULE_DIR$/vendor/zendframework/zend-loader/test/_files/PharModulePharTarGz.phar.tar.gz" />
<root url="phar://$MODULE_DIR$/vendor/zendframework/zend-loader/test/_files/PharModule.phar" />
<root url="phar://$MODULE_DIR$/vendor/zendframework/zend-loader/test/_files/classmap.phar" />
</CLASSES>
<SOURCES>
<root url="phar://$MODULE_DIR$/vendor/zendframework/zend-i18n/test/Translator/_files/translations.phar" />
<root url="phar://$MODULE_DIR$/vendor/zendframework/zend-loader/test/_files/PharModuleExplicit.phar" />
<root url="phar://$MODULE_DIR$/vendor/zendframework/zend-loader/test/_files/ApplicationModulePhar.phar" />
<root url="phar://$MODULE_DIR$/composer.phar" />
<root url="phar://$MODULE_DIR$/vendor/zendframework/zend-loader/test/_files/PharModulePharTar.phar.tar" />
<root url="phar://$MODULE_DIR$/vendor/zendframework/zend-view/test/_templates/view.phar" />
<root url="phar://$MODULE_DIR$/vendor/zendframework/zend-loader/test/_files/PharModulePharZip.phar.zip" />
<root url="phar://$MODULE_DIR$/vendor/zendframework/zend-loader/test/_files/PharModuleMap.phar" />
<root url="phar://$MODULE_DIR$/vendor/zendframework/zend-loader/test/_files/PharModulePharTarGz.phar.tar.gz" />
<root url="phar://$MODULE_DIR$/vendor/zendframework/zend-loader/test/_files/PharModule.phar" />
<root url="phar://$MODULE_DIR$/vendor/zendframework/zend-loader/test/_files/classmap.phar" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="PHP">
<CLASSES>
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-modulemanager" />
<root url="file://$MODULE_DIR$/vendor/psr/log" />
<root url="file://$MODULE_DIR$/vendor/zfcampus/zf-api-problem" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-authentication" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-uri" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-eventmanager" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-crypt" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-math" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-json" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-escaper" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-hydrator" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-validator" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-form" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-servicemanager" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-serializer" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-inputfilter" />
<root url="file://$MODULE_DIR$/vendor/composer" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-http" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-loader" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-stdlib" />
<root url="file://$MODULE_DIR$/vendor/jasig/phpcas" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-view" />
<root url="file://$MODULE_DIR$/vendor/container-interop/container-interop" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-filter" />
<root url="file://$MODULE_DIR$/vendor/unicaen/unicaen-ldap" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-mvc" />
<root url="file://$MODULE_DIR$/vendor/zfcampus/zf-oauth2" />
<root url="file://$MODULE_DIR$/vendor/bshaffer/oauth2-server-php" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-ldap" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-log" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-config" />
<root url="file://$MODULE_DIR$/vendor/zfcampus/zf-content-negotiation" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-i18n" />
</CLASSES>
<SOURCES>
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-modulemanager" />
<root url="file://$MODULE_DIR$/vendor/psr/log" />
<root url="file://$MODULE_DIR$/vendor/zfcampus/zf-api-problem" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-authentication" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-uri" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-eventmanager" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-crypt" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-math" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-json" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-escaper" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-hydrator" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-validator" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-form" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-servicemanager" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-serializer" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-inputfilter" />
<root url="file://$MODULE_DIR$/vendor/composer" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-http" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-loader" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-stdlib" />
<root url="file://$MODULE_DIR$/vendor/jasig/phpcas" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-view" />
<root url="file://$MODULE_DIR$/vendor/container-interop/container-interop" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-filter" />
<root url="file://$MODULE_DIR$/vendor/unicaen/unicaen-ldap" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-mvc" />
<root url="file://$MODULE_DIR$/vendor/zfcampus/zf-oauth2" />
<root url="file://$MODULE_DIR$/vendor/bshaffer/oauth2-server-php" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-ldap" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-log" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-config" />
<root url="file://$MODULE_DIR$/vendor/zfcampus/zf-content-negotiation" />
<root url="file://$MODULE_DIR$/vendor/zendframework/zend-i18n" />
</SOURCES>
</library>
</orderEntry>
</component>
</module>
\ No newline at end of file
<component name="ProjectDictionaryState">
<dictionary name="gauthierb" />
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
</project>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<profile version="1.0" is_locked="false">
<option name="myName" value="Project Default" />
<option name="myLocal" value="false" />
<inspection_tool class="SpellCheckingInspection" enabled="true" level="TYPO" enabled_by_default="true">
<option name="processCode" value="false" />
<option name="processLiterals" value="false" />
<option name="processComments" value="false" />
</inspection_tool>
</profile>
</component>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<settings>
<option name="PROJECT_PROFILE" value="Project Default" />
<option name="USE_PROJECT_PROFILE" value="true" />
<version value="1.0" />
</settings>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/../UnicaenOAuth/.idea/UnicaenOAuth.iml" filepath="$PROJECT_DIR$/../UnicaenOAuth/.idea/UnicaenOAuth.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<component name="DependencyValidationManager">
<state>
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
</state>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="" />
</component>
</project>
\ No newline at end of file
This diff is collapsed.
<?php
namespace Auth;
class Module
{
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
);
}
}
{
"name": "unicaen/oauth",
"description": "Serveur OAuth2 authentifiant soit via LDAP, soit via CAS",
"minimum-stability": "dev",
"license": "proprietary",
"authors": [
{
"name": "Bertrand GAUTHIER",
"email": "email@example.com"
}
],
"repositories": [
{
"type": "vcs",
"url": "https://svn.unicaen.fr/svn/UnicaenLdap"
}
],
"require": {
"zendframework/zend-authentication": "~2.4",
"zfcampus/zf-oauth2": "1.3.1",
"unicaen/unicaen-ldap": "1.0.1",
"jasig/phpcas": "~1.3"
}
}
This diff is collapsed.
File added
<?php
namespace UnicaenOAuth;
return array(
'router' => array(
'routes' => array(
'login-cas' => array(
'type' => 'Literal',
'options' => array(
'route' => '/cas/login',
'defaults' => array(
'controller' => __NAMESPACE__ . '\Controller\Cas',
'action' => 'login',
),
),
),
),
),
'controllers' => array(
'factories' => array(
__NAMESPACE__ . '\Controller\Cas' => __NAMESPACE__ . '\Controller\CasControllerFactory',
),
),
'service_manager' => array(
'factories' => array(
'service.cas' => __NAMESPACE__ . '\Cas\CasServiceFactory',
'ZF\OAuth2\Adapter\PdoAdapter' => __NAMESPACE__ . '\OAuth2\Adapter\StorageAdapterFactory',
)
),
'view_manager' => array(
'template_path_stack' => array(
__DIR__ . '/../view',
),
),
);
\ No newline at end of file
<?php
return array(
'unicaen-oauth' => [
'cas' => [
'host' => 'host.domain.fr',
'port' => 443,
'version' => "2.0",
'uri' => "",
'debug' => false, // exemple: '/tmp/cas.log'
],
],
'unicaen-ldap' => array(
'host' => 'host.domain.fr',
'port' => 389,
'version' => 3,
'baseDn' => "ou=xxxxxxxxxxx,dc=domain,dc=fr",
'bindRequiresDn' => true,
'username' => "uid=xxxxxxxxx,ou=xxxxxxxxxx,dc=domain,dc=fr",
'password' => "xxxxxxxxxxxx",
'accountFilterFormat' => "(&(objectClass=posixAccount)(supannAliasLogin=%s))",
),
'zf-oauth2' => array(
'db' => array(
'dsn' => 'insert here the DSN for DB connection', // for example "mysql:dbname=oauth2_db;host=localhost"
'username' => 'insert here the DB username',
'password' => 'insert here the DB password',
),
'allow_implicit' => false, // default (set to true when you need to support browser-based or mobile apps)
'access_lifetime' => 3600, // default (set a value in seconds for access tokens lifetime)
'enforce_state' => true, // default
'storage' => 'ZF\OAuth2\Adapter\PdoAdapter', // service name for the OAuth2 storage adapter
),
);
\ No newline at end of file
<?php
namespace UnicaenOAuth\Cas;
use Zend\ServiceManager\ServiceLocatorAwareInterface;
use Zend\ServiceManager\ServiceLocatorAwareTrait;
use phpCAS;
class CasService implements ServiceLocatorAwareInterface
{
use ServiceLocatorAwareTrait;
private $config;
public function __construct(array $config)
{
$this->config = $config;
}
public function login()
{
$this->initCasClient();
// force CAS authentication
phpCAS::forceAuthentication();
// at this step, the user has been authenticated by the CAS server
// and the user's login name can be read with phpCAS::getUser().
$username = phpCas::getUser();
// $payload = createPayload($username);
// $token = JWT::encode($payload, getPrivateKey(), 'HS256');
return $username;
}
public function checkAuthentication()
{
$this->initCasClient();
return phpCAS::checkAuthentication();
}
public function logout()
{
$this->initCasClient();
phpCAS::logout();
exit;
}
private function initCasClient()
{
// Enable debugging
phpCAS::setDebug($this->config['debug']);
// Enable verbose error messages. Disable in production!
//phpCAS::setVerbose(true);
// Initialize phpCAS
phpCAS::client($this->config['version'], $this->config['host'], $this->config['port'], $this->config['uri']);
// For production use set the CA certificate that is the issuer of the cert
// on the CAS server and uncomment the line below
// phpCAS::setCasServerCACert($cas_server_ca_cert_path);
// For quick testing you can disable SSL validation of the CAS server.
// THIS SETTING IS NOT RECOMMENDED FOR PRODUCTION.
// VALIDATING THE CAS SERVER IS CRUCIAL TO THE SECURITY OF THE CAS PROTOCOL!
phpCAS::setNoCasServerValidation();
return $this;
}
}
\ No newline at end of file
<?php
namespace UnicaenOAuth\Cas;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
class CasServiceFactory implements FactoryInterface
{
public function createService(ServiceLocatorInterface $serviceLocator)
{
$config = $serviceLocator->get('config');
return new CasService($config['auth']['cas']);
}
}
\ No newline at end of file
<?php
namespace UnicaenOAuth\Cas;
trait CasServiceTrait
{
/**
* @var CasService
*/
private $casService;
/**
* @param CasService $casService
* @return $this
*/
public function setServiceCas(CasService $casService)
{
$this->casService = $casService;
return $this;
}
/**
* @return CasService
*/
public function getServiceCas()
{
return $this->casService;
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment