big update : session authentification guard, some exemaples and docs

This commit is contained in:
Emmanuel ROY 2021-02-17 13:39:05 +01:00
parent eb54203916
commit 5be76d38f6
30 changed files with 164 additions and 61 deletions

View file

@ -23,10 +23,6 @@ class Application
public function launch() public function launch()
{ {
//on declare la session lors du chargement du controlleur,
// ainsi on instancie la page précédente et le javascript et le css asynchrone
\MVC\Object\Session::createAndTestSession();
$controlleur = new Controlleur($this); $controlleur = new Controlleur($this);
//si la page n'est un controlleur d'action alors on affiche l'écran //si la page n'est un controlleur d'action alors on affiche l'écran
if (!$this->url->page['control']) { if (!$this->url->page['control']) {

View file

@ -0,0 +1,38 @@
<?php
namespace MVC\Classe;
class Asynchonous
{
private $_css;
private $_javascript;
public function __construct()
{
$this->_css = "";
$this->_javascript = "";
}
public function addCss($code)
{
$this->_css .= "\n";
$this->_css .= $code;
}
public function addJs($code)
{
$this->_javascript .= "\n";
$this->_javascript .= $code;
}
public function printCss()
{
echo $this->_css;
}
public function printJs()
{
echo $this->_javascript;
}
}

View file

@ -6,7 +6,7 @@ class Bdd
{ {
public $bdd; public $bdd;
public function __construct($bdd = 'default') public function __construct($bdd = 'bdd')
{ {
switch ($bdd) { switch ($bdd) {
case 'bdd1': case 'bdd1':

View file

@ -37,6 +37,15 @@ class Controlleur
require TRAITEMENT_PATH . DIRECTORY_SEPARATOR . $application->url->page['name'] . '.php'; require TRAITEMENT_PATH . DIRECTORY_SEPARATOR . $application->url->page['name'] . '.php';
} else { } else {
$this->modele = new Modele($application->url->page); $this->modele = new Modele($application->url->page);
if(isset($this->modele->page['authentification']) && $this->modele->page['authentification'] == 'yes'){
//on declare la session lors du chargement du controlleur,
// ainsi on instancie la page précédente et le javascript et le css asynchrone
\MVC\Object\Session::createAndTestSession();
}else{
\MVC\Object\Session::sessionStart();
\MVC\Object\History::setPagePrecedente();
\MVC\Object\Asynchronous::declare();
}
$this->vue = new Vue($this); $this->vue = new Vue($this);
} }
} }

View file

@ -192,8 +192,10 @@ class Url
$scheme = 'http'; $scheme = 'http';
} }
$base_url = $scheme . "://" . $url; $base_url = $scheme . "://" . $url;
$url = $base_url;
}else{ }else{
$base_url = PATH_URL; $base_url = PATH_URL;
$url = $base_url . BASE_SERVER_DIRECTORY;
} }
if ($isControlPatern) { if ($isControlPatern) {
$uri = self::controlLink_rewrite($page, $params); $uri = self::controlLink_rewrite($page, $params);
@ -202,6 +204,10 @@ class Url
} }
return ( $base_url . BASE_SERVER_DIRECTORY . $uri); return ( $url . $uri);
}
public static function getBaseDirectory(){
return '/' . BASE_SERVER_DIRECTORY;
} }
} }

View file

@ -7,7 +7,6 @@
define("BASE_SERVER_DIRECTORY", ""); define("BASE_SERVER_DIRECTORY", "");
// Optionnel! il n'est nécessaire que si vous l'utilisez dans les fichiers de traitement ou dans une commande console // Optionnel! il n'est nécessaire que si vous l'utilisez dans les fichiers de traitement ou dans une commande console
// si vous l'utilisez dans les fichiers de traitement -> il est plus simple d'utiliser l'Objet page précédente define('PATH_URL',"http://www.domain.org/");
define('PATH_URL',"http://www.domain.org");
define('ENV', "DEV"); define('ENV', "DEV");

View file

@ -8,7 +8,7 @@ class DocConduit extends Conduit
// Route('/docs') // Route('/docs')
public function index() public function index()
{ {
\MVC\Object\Session::createAndTestSession();
$files = array(); $files = array();
if ($handle = opendir(DATA_PATH . '/docs')) { if ($handle = opendir(DATA_PATH . '/docs')) {
@ -36,7 +36,7 @@ class DocConduit extends Conduit
// Route('/docs/file/{file}') // Route('/docs/file/{file}')
public function readfile() public function readfile()
{ {
\MVC\Object\Session::createAndTestSession();
$markdown = file_get_contents(DATA_PATH . '/docs/' . $this->file); $markdown = file_get_contents(DATA_PATH . '/docs/' . $this->file);
$my_html = MarkdownExtra::defaultTransform($markdown); $my_html = MarkdownExtra::defaultTransform($markdown);

View file

@ -8,6 +8,7 @@ class FooConduit extends Conduit
// Route('/foo') // Route('/foo')
public function index() public function index()
{ {
\MVC\Object\Session::createAndTestSession();
echo "blob of foo"; echo "blob of foo";
return $this->render('foo', array('page_title' => 'Foo', 'description' => 'FooConduit')); return $this->render('foo', array('page_title' => 'Foo', 'description' => 'FooConduit'));
} }
@ -15,6 +16,7 @@ class FooConduit extends Conduit
// Route('/foo/{id}') // Route('/foo/{id}')
public function load() public function load()
{ {
\MVC\Object\Session::createAndTestSession();
echo "load of foo"; echo "load of foo";
return $this->render('foo', array('page_title' => 'Foo', 'description' => 'FooConduit', 'id' => $this->id)); return $this->render('foo', array('page_title' => 'Foo', 'description' => 'FooConduit', 'id' => $this->id));
} }

View file

@ -8,6 +8,7 @@ class IndexConduit extends Conduit
// Route('/') // Route('/')
public function homepage() public function homepage()
{ {
\MVC\Object\Session::createAndTestSession();
echo "IndexControlleur"; echo "IndexControlleur";
return $this->render('index', array("templating_a"=>'blade',"templating_b"=>'twig',"templating_c"=>'edge')); return $this->render('index', array("templating_a"=>'blade',"templating_b"=>'twig',"templating_c"=>'edge'));
} }

View file

@ -1,6 +1,10 @@
name : admin name : admin
page_title : Administration de l'application page_title : Administration de l'application
description : Administration de l'application description : Administration de l'application
engine : blade
params : params engine : blade
authentification : yes
ariane : {acceuil}
arianelink : {index}

View file

@ -1,5 +1,10 @@
name : beers name : beers
page_title : module_title page_title : module_title
description : module_description description : module_description
params : module_params
engine : blade
authentification : yes
ariane : {acceuil}
arianelink : {index}

View file

@ -1,5 +1,9 @@
name : cgu name : cgu
page_title: Conditions Générale d'Utilisation de l'application page_title: Conditions Générale d'Utilisation de l'application
description : abracadabla description : abracadabla
engine : blade engine : blade
params : params authentification : yes
ariane : {acceuil}
arianelink : {index}

View file

@ -1,5 +1,10 @@
name : donate name : donate
page_title : Be a sponsor page_title : Be a sponsor
description : Page permettant de devenir un sponsor du framework SAND description : Page permettant de devenir un sponsor du framework SAND
params : module_params
engine : blade
authentification : yes
ariane : {acceuil}
arianelink : {index}

View file

@ -1,5 +1,10 @@
name : error-access-denied name : error-access-denied
page_title : Page 403 (Accès restreint) de l'application page_title : Page 403 (Accès restreint) de l'application
description : Page 403 (Accès restreint) de l'application description : Page 403 (Accès restreint) de l'application
params : module_params
engine : blade
authentification : no
ariane : {acceuil}
arianelink : {index}

View file

@ -1,4 +1,9 @@
name : error name : error
page_title: Page 404 (Page Non Trouvé) de l'application page_title: Page 404 (Page Non Trouvé) de l'application
description : Page 404 (Page Non Trouvé) de l'application description : Page 404 (Page Non Trouvé) de l'application
params : params
engine : blade
authentification : no
ariane : {acceuil}
arianelink : {index}

View file

@ -1,5 +1,10 @@
name : gitlist name : gitlist
page_title : Dépot Git page_title : Dépot Git
description : Le dépot de travail du framework description : Le dépot de travail du framework
engine: blade
engine : blade
authentification : yes
ariane : {acceuil, dépot git du framework}
arianelink : {index, gitlist}

View file

@ -1,7 +1,10 @@
name : index name : index
page_title : Accueil de l'application page_title : Accueil de l'application
description : zatou stra bracadabla description : zatou stra bracadabla
engine : blade engine : blade
authentification : yes
ariane : {acceuil} ariane : {acceuil}
arianelink : {index} arianelink : {index}

View file

@ -1,5 +1,9 @@
name : policy name : policy
page_title: Politique de Confidentialité de l'application page_title: Politique de Confidentialité de l'application
description : abracadabla description : abracadabla
engine : blade engine : blade
params : params authentification : yes
ariane : {acceuil}
arianelink : {index}

View file

@ -64,7 +64,7 @@
<div id="breadcrumbs" class="fullwidth"> <div id="breadcrumbs" class="fullwidth">
<div class="container"> <div class="container">
<nav aria-label="breadcrumb"> <nav aria-label="breadcrumb">
<ol class="breadcrumb"> <ol class="breadcrumb-sand">
@foreach($ariane as $value) @foreach($ariane as $value)
@if($value == end($ariane)) @if($value == end($ariane))
<li class="breadcrumb-item active" aria-current="page">{{$value}}</li> <li class="breadcrumb-item active" aria-current="page">{{$value}}</li>

View file

@ -45,6 +45,8 @@
<script src="{{ \MVC\Classe\Url::asset_rewrite('assets/bootstrap-5.0.0-beta1-dist/js/bootstrap.min.js')}}"></script> <script src="{{ \MVC\Classe\Url::asset_rewrite('assets/bootstrap-5.0.0-beta1-dist/js/bootstrap.min.js')}}"></script>
<script src="{{ \MVC\Classe\Url::asset_rewrite('assets/js/custom.js')}}"></script> <script src="{{ \MVC\Classe\Url::asset_rewrite('assets/js/custom.js')}}"></script>
<script>
/* /*
SCRIPT JS permettant de ne valider qu'une seule fois un formulaire SCRIPT JS permettant de ne valider qu'une seule fois un formulaire
ATTENTION tous les formulaires sont affecté ATTENTION tous les formulaires sont affecté
@ -52,7 +54,7 @@
la class do-resubmit sur le formulaire afin de permettre la class do-resubmit sur le formulaire afin de permettre
l'activation supplémentaire du bouton. l'activation supplémentaire du bouton.
*/ */
<script>
window.onload = function() { window.onload = function() {
let PreventAllforms = document.querySelectorAll("form"); let PreventAllforms = document.querySelectorAll("form");
Array.prototype.slice.call(PreventAllforms) Array.prototype.slice.call(PreventAllforms)

View file

@ -1,7 +1,6 @@
<link rel="stylesheet" type="text/css" href="{{ app.request.basepath }}/themes/{{ theme }}/css/style.css"> <link rel="stylesheet" type="text/css" href="{{ app.request.basepath }}/themes/{{ theme }}/css/style.css">
<link rel="stylesheet" type="text/css" href="{{ app.request.basepath }}/themes/{{ theme }}/css/gitgraph.css"> <link rel="stylesheet" type="text/css" href="{{ app.request.basepath }}/themes/{{ theme }}/css/gitgraph.css">
<link rel="shortcut icon" type="image/png" href="{{ app.request.basepath }}/themes/{{ theme }}/img/favicon.png"
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script type="application/javascript" src="{{ app.request.basepath }}/themes/{{ theme }}/js/html5.js"></script> <script type="application/javascript" src="{{ app.request.basepath }}/themes/{{ theme }}/js/html5.js"></script>
<![endif]--> <![endif]-->

View file

@ -35,7 +35,7 @@ class Session
public static function authentification() public static function authentification()
{ {
self::sessionStart(); self::sessionStart();
$_SESSION['user_login'] = 'root'; $_SESSION['user_login'] = 'anonymous';
$_SESSION['acl_admin'] = 0; $_SESSION['acl_admin'] = 0;
} }
@ -46,7 +46,7 @@ class Session
require_once CONFIG_PATH . DIRECTORY_SEPARATOR . 'cas-authentification-config.php'; require_once CONFIG_PATH . DIRECTORY_SEPARATOR . 'cas-authentification-config.php';
// Enable debugging // Enable debugging
\phpCAS::setLogger(); \phpCAS::setDebug(LOG_PATH.'/cas.log');
// Enable verbose error messages. Disable in production! // Enable verbose error messages. Disable in production!
\phpCAS::setVerbose(true); \phpCAS::setVerbose(true);

View file

@ -7,7 +7,7 @@ class XssToken
public static function getNew($title,$message,$type) public static function getNew($title,$message,$type)
{ {
$_SESSION['xss_token'] = generateUniqueToken('xss',25); $_SESSION['xss_token'] = self::generateUniqueToken('xss',25);
} }
public static function remove(){ public static function remove(){

View file

@ -2,6 +2,8 @@
header("Content-Type: text/plain"); header("Content-Type: text/plain");
\MVC\Object\Session::createAndTestSession();
$bdd = new Bdd(); $bdd = new Bdd();
$dns = \MVC\Domain\Dns::getDNS($bdd, $url_params['ip']); $dns = \MVC\Domain\Dns::getDNS($bdd, $url_params['ip']);
$alias = array(); $alias = array();

View file

@ -1,5 +1,7 @@
<?php <?php
\MVC\Object\Session::createAndTestSession();
$path = PATH_URL; $path = PATH_URL;
$bdd = new \MVC\Classe\Bdd(); $bdd = new \MVC\Classe\Bdd();

View file

@ -1,7 +1,6 @@
name : %%MODULE%% name : %%MODULE%%
page_title : module_title page_title : module_title
description : module_description description : module_description
engine : blade
ariane : {%%MODULE%%} ariane : {%%MODULE%%}
arianelink : {%%MODULE%%} arianelink : {%%MODULE%%}

View file

@ -2,6 +2,7 @@ name : %%PAGE%%
page_title : module_title page_title : module_title
description : module_description description : module_description
engine : %%ENGINE%% engine : %%ENGINE%%
authentification : no
ariane : {acceuil, %%PAGE%%} ariane : {acceuil, %%PAGE%%}
arianelink : {index, %%PAGE%%} arianelink : {index, %%PAGE%%}

View file

@ -12,7 +12,7 @@ C'est un choix applicatif qu'il faut faire au moment de la contruction de l'appl
Vous devez instancier le fichier `application/include/controlleurs/{Name}HttpReponse.php` Vous devez instancier le fichier `application/include/controlleurs/{Name}HttpReponse.php`
qui est une classe peut implémenter `MVC\Classe\Implement\RestReponse` ou `MVC\Classe\Implement\HttpReponse` sachant que la différence se situe au niveau des méthodes qu'il doit instancier. qui est une classe peut implémenter `MVC\Classe\Implement\RestReponse` ou `MVC\Classe\Implement\HttpReponse` sachant que la différence se situe au niveau des méthodes qu'il doit instancier.
*Voici un exemple avec `RestResponse` ##Voici un exemple avec `RestResponse`
```php ```php
<?php <?php
@ -58,7 +58,7 @@ class NameHttpReponse extends RestReponse
} }
``` ```
*voici un exemple avec `HttpResponse` ##voici un exemple avec `HttpResponse`
```php ```php
<?php <?php

View file

@ -90,6 +90,13 @@ dl, ol, ul {
background-color: whitesmoke; background-color: whitesmoke;
font-size: 0.7rem; font-size: 0.7rem;
} }
.breadcrumb-sand {
display: flex;
flex-wrap: wrap;
padding: 0 0;
margin-bottom: 1rem;
list-style: none;
}
/** Page content spacing **/ /** Page content spacing **/
#page-content{ #page-content{
padding-top: 2rem; padding-top: 2rem;

View file

@ -381,15 +381,15 @@ a:hover {
} }
p { p {
margin: 0 0 9px; /*margin: 0 0 9px;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 13px; font-size: 13px;
line-height: 18px line-height: 18px*/
} }
p small { p small {
font-size: 11px; /*font-size: 11px;
color: #999 color: #999*/
} }
.lead { .lead {
@ -400,65 +400,65 @@ p small {
} }
h1, h2, h3, h4, h5, h6 { h1, h2, h3, h4, h5, h6 {
margin: 0; /*margin: 0;
font-family: inherit; font-family: inherit;
font-weight: bold; font-weight: bold;
color: inherit; color: inherit;
text-rendering: optimizelegibility text-rendering: optimizelegibility*/
} }
h1 small, h2 small, h3 small, h4 small, h5 small, h6 small { h1 small, h2 small, h3 small, h4 small, h5 small, h6 small {
font-weight: normal; /*font-weight: normal;
color: #999 color: #999*/
} }
h1 { h1 {
font-size: 30px; /*font-size: 30px;
line-height: 36px line-height: 36px*/
} }
h1 small { h1 small {
font-size: 18px /*font-size: 18px*/
} }
h2 { h2 {
font-size: 24px; /*font-size: 24px;
line-height: 36px line-height: 36px*/
} }
h2 small { h2 small {
font-size: 18px /*font-size: 18px*/
} }
h3 { h3 {
font-size: 18px; /*font-size: 18px;
line-height: 27px line-height: 27px*/
} }
h3 small { h3 small {
font-size: 14px /*font-size: 14px*/
} }
h4, h5, h6 { h4, h5, h6 {
line-height: 18px /*line-height: 18px*/
} }
h4 { h4 {
font-size: 14px /*font-size: 14px*/
} }
h4 small { h4 small {
font-size: 12px /*font-size: 12px*/
} }
h5 { h5 {
font-size: 12px /*font-size: 12px*/
} }
h6 { h6 {
font-size: 11px; /*font-size: 11px;
color: #999; color: #999;
text-transform: uppercase text-transform: uppercase*/
} }
.page-header { .page-header {
@ -477,7 +477,7 @@ ul, ol {
} }
ul ul, ul ol, ol ol, ol ul { ul ul, ul ol, ol ol, ol ul {
margin-bottom: 0 /*margin-bottom: 0*/
} }
ul { ul {
@ -1934,7 +1934,7 @@ table .span24 {
height: 14px; height: 14px;
*margin-right: .3em; *margin-right: .3em;
line-height: 14px; line-height: 14px;
vertical-align: text-top; /*vertical-align: text-top;*/
background-image: url("../img/glyphicons-halflings.png"); background-image: url("../img/glyphicons-halflings.png");
background-position: 14px 14px; background-position: 14px 14px;
background-repeat: no-repeat background-repeat: no-repeat