Skip to content

Commit

Permalink
authentication is ready
Browse files Browse the repository at this point in the history
  • Loading branch information
kanellov committed Feb 9, 2016
1 parent 1c28c58 commit f9f928f
Show file tree
Hide file tree
Showing 25 changed files with 637 additions and 210 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"slim/slim": "^3.0",
"slim/twig-view": "^2.0",
"zendframework/zend-authentication": "^2.0",
"zendframework/zend-crypt": "^2.0",
"zendframework/zend-eventmanager": "^3.0",
"zendframework/zend-ldap": "^2.0",
"zendframework/zend-permissions-acl": "^2.0"
Expand Down
104 changes: 102 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions config/app.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
'modules' => [
'module/authentication/bootstrap.php',
'module/authorization/bootstrap.php',
'module/sch_ldap/bootstrap.php',
// 'module/sch_ldap/bootstrap.php',
'module/sch_sso/bootstrap.php',
'module/sch_auto_create/bootstrap.php',
// 'module/sch_auto_create/bootstrap.php',
'module/application/bootstrap.php',
],
'cache_config' => 'data/cache/config/settings.php',
Expand Down
14 changes: 0 additions & 14 deletions config/local.php

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
<?php
/**
* gredu_labs.
*
* gredu_labs
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
*
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/

namespace GrEduLabs\Application\Authentication;

class RedbeanListener
{
public function __invoke(callable $stop, $identity, $credential)
{
if (!$identity || !$credential) {
return false;
}

$stop();
}
}
return [
'authentication' => [
'bcrypt' => [
'salt' => '',
'cost' => 14,
],
],
];
3 changes: 0 additions & 3 deletions config/settings/ldap.local.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,4 @@ return [
'tryUsernameSplit' => true,
'networkTimeout' => null,
],
'sso' => [
'allowed' => '&(physicaldeliveryofficename=ΕΠΙΣΗΜΟΣ ΛΟΓΑΡΙΑΣΜΟΣ)(umdobject=account)',
],
];
13 changes: 0 additions & 13 deletions config/settings/nav.global.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,5 @@
// ],

],
'main-right' => [
'login' => [
'label' => 'Σύνδεση',
'route' => 'user.login',
'icon' => 'unlock',
],
'logout' => [
'label' => 'Αποσύνδεση',
'route' => 'user.logout',
'id' => 'nav-logout',
'icon' => 'lock',
],
],
],
];
43 changes: 30 additions & 13 deletions config/settings/sso.local.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,35 @@
*/

return [
'phpcas' => [
'serverVersion' => 'S1',
'proxy' => false,
'serverHostname' => '',
'serverPort' => 443,
'serverUri' => '/cas',
'changeSessionId' => false,
'handleLogoutRequests' => true,
'allowedClients' => [],
'lang' => 'CAS_Languages_Greek',
'casServerCaCert' => '',
'casServerCnValidate' => '',
'noCasServerValidation' => true,

'sso' => [
'phpcas' => [
'serverVersion' => 'S1',
'proxy' => false,
'serverHostname' => '',
'serverPort' => 443,
'serverUri' => '/cas',
'changeSessionId' => false,
'handleLogoutRequests' => true,
'allowedClients' => [],
'lang' => 'CAS_Languages_Greek',
'casServerCaCert' => '',
'casServerCnValidate' => '',
'noCasServerValidation' => true,
],

'allowed' => [
[
'physicaldeliveryofficename' => '/^ΕΠΙΣΗΜΟΣ ΛΟΓΑΡΙΑΣΜΟΣ$/i',
'umdobject' => '/^account$/i',
],
],
],
'acl' => [
'guards' => [
'routes' => [
['/user/logout/sso', ['guest'], ['get']],
],
],
],
];
4 changes: 3 additions & 1 deletion config/settings/twig.global.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

return [
'view' => [
'template_path' => 'module/application/templates',
'template_path' => [
'module/application/templates',
],
'twig' => [
'cache' => 'data/cache/templates',
'debug' => false,
Expand Down
52 changes: 26 additions & 26 deletions module/application/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,36 +58,10 @@
return $logger;
};

$container['authenticate_redbean_listener'] = function ($c) {
return new GrEduLabs\Application\Authentication\RedbeanListener();
};

$container['csrf'] = function ($c) {
return new \Slim\Csrf\Guard();
};

$events = $container['events'];
$events('on', 'bootstrap', function () use ($container) {
session_name('GrEduLabs');
session_start();

// setup RedbeanPHP

RedBeanPHP\R::setup(
$container['settings']['db']['dsn'],
$container['settings']['db']['user'],
$container['settings']['db']['pass']
);

define('REDBEAN_MODEL_PREFIX', 'GrEduLabs\\Application\\Model\\');

}, 10000000);

$events('on', 'bootstrap', function () use ($container) {
$container['router']->getNamedRoute('user.login')->add('csrf');
});

$events('on', 'authenticate', $container['authenticate_redbean_listener']);

$container['GrEduLabs\\Application\\Action\\Index'] = function ($c) {
return new GrEduLabs\Application\Action\Index($c['view']);
Expand All @@ -109,6 +83,32 @@
return new GrEduLabs\Application\Action\School\Assets($c->get('view'));
};

$events = $container['events'];
$events('on', 'bootstrap', function () use ($container) {
session_name('GrEduLabs');
session_start();

// setup RedbeanPHP

RedBeanPHP\R::setup(
$container['settings']['db']['dsn'],
$container['settings']['db']['user'],
$container['settings']['db']['pass']
);

define('REDBEAN_MODEL_PREFIX', 'GrEduLabs\\Application\\Model\\');

}, 10000000);

$events('on', 'bootstrap', function () use ($container) {
try {
$container['router']->getNamedRoute('user.login')->add('csrf');
} catch (\RuntimeException $e) {
// eat it
}
});


$app->get('/', 'GrEduLabs\\Application\\Action\\Index')->setName('index');
$app->group('/school', function () {
$this->get('', 'GrEduLabs\\Application\\Action\\School\\Index')->setName('school');
Expand Down
8 changes: 6 additions & 2 deletions module/application/src/Twig/Extension/Navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,13 @@ public function setCurrentRole($role)
/**
*
*/
public function nav($root = null)
public function nav($root)
{
$navigation = (null !== $root) ? $this->navigation[$root] : $this->navigation;
if (!isset($this->navigation[$root]) || !is_array($this->navigation[$root])) {
return [];
}

$navigation = $this->navigation[$root];

$aclFilter = function ($page) {
if (!$this->acl) {
Expand Down
7 changes: 5 additions & 2 deletions module/application/templates/flash.twig
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{% for class, messages in flash() %}
<ul class="list-unstyled alert alert-{{ class }}" role="alert">
<ul class="list-unstyled alert alert-{{ class }} alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true"><i class="fa fa-close"></i></span>
</button>
{% for message in messages %}
<li>{{ message }}</li>
<li>{{ message|raw }}</li>
{% endfor %}
</ul>
{% endfor %}
3 changes: 0 additions & 3 deletions module/application/templates/index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,5 @@
<div class="jumbotron">
<h1>Σχολικά εργαστήρια</h1>
<p class="lead">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam vel volutpat diam, vitae consectetur libero. Sed et sem et nisi aliquet condimentum. Morbi id magna iaculis, dictum lectus vitae, suscipit nisl. Proin molestie dolor vitae pulvinar tristique. Integer egestas varius lorem id scelerisque. Praesent velit metus, egestas facilisis iaculis id, auctor nec mi. Suspendisse ultrices laoreet justo eget viverra.</p>
{% if not identity() %}
<p><a class="btn btn-lg btn-success" href="{{ path_for('user.login') }}" role="button">Σύνδεση</a></p>
{% endif %}
</div>
{% endblock %}
Loading

0 comments on commit f9f928f

Please sign in to comment.