Compare commits
5 commits
3bf65aea4d
...
7b635a4f00
Author | SHA1 | Date | |
---|---|---|---|
7b635a4f00 | |||
f662837ffd | |||
5ab7b35cc3 | |||
fe19313c2f | |||
fe75984bc7 |
8 changed files with 94 additions and 8 deletions
1
example/data/sessions/.gitignore
vendored
Normal file
1
example/data/sessions/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
sess_*
|
|
@ -102,8 +102,12 @@ i18n:
|
|||
# Session
|
||||
#
|
||||
session:
|
||||
timeout: 1800 # Session timeout dur to inactivity (in seconds)
|
||||
max_duration: 43200 # Session max duration (in seconds, default : 12h)
|
||||
# Session timeout due to inactivity (in seconds)
|
||||
timeout: 1800
|
||||
# Session max duration (in seconds, default : 12h)
|
||||
max_duration: 43200
|
||||
# Directory path where to store PHP sessions data (optional, default: use system default)
|
||||
directory_path: "${data_directory}/sessions"
|
||||
|
||||
#
|
||||
# Database configuration
|
||||
|
@ -143,7 +147,7 @@ db:
|
|||
#
|
||||
auth:
|
||||
# Enabled authentication
|
||||
enabled: false
|
||||
enabled: true
|
||||
|
||||
# Methods to authenticate users
|
||||
methods:
|
||||
|
@ -153,12 +157,15 @@ auth:
|
|||
|
||||
# User backends
|
||||
backends:
|
||||
- ldap
|
||||
- db
|
||||
|
||||
#
|
||||
# Login form
|
||||
#
|
||||
login_form:
|
||||
# Include application navbar (default: true)
|
||||
include_navbar: true
|
||||
|
||||
# Display link for other authentication methods
|
||||
# Note: method as key and label as value
|
||||
display_other_methods:
|
||||
|
@ -219,6 +226,30 @@ auth:
|
|||
# CAS Fake authenticated user
|
||||
#fake_authenticated_user: 'myusername'
|
||||
|
||||
#
|
||||
# Database user backend
|
||||
#
|
||||
db:
|
||||
# DSN (required)
|
||||
dsn: "${db.dsn}"
|
||||
# Username (optional but could be required with some PDO drivers)
|
||||
user: "${db.user}"
|
||||
# Password (optional)
|
||||
password: "${db.password}"
|
||||
# PDO options (optional)
|
||||
options: "${db.options}"
|
||||
# Users table name (optional, default: users)
|
||||
users_table: "users"
|
||||
# Username field name (optional, default: username)
|
||||
username_field: "username"
|
||||
# Password field name (optional, default: password)
|
||||
password_field: "password"
|
||||
# Exposed users table fields in resulting EesyPHP\Auth\User object
|
||||
# (optional, defailt: name, mail)
|
||||
exposed_fields:
|
||||
- "name"
|
||||
- "mail"
|
||||
|
||||
#
|
||||
# LDAP user backend
|
||||
#
|
||||
|
|
|
@ -102,8 +102,12 @@ i18n:
|
|||
# Session
|
||||
#
|
||||
session:
|
||||
timeout: 1800 # Session timeout dur to inactivity (in seconds)
|
||||
max_duration: 43200 # Session max duration (in seconds, default : 12h)
|
||||
# Session timeout due to inactivity (in seconds)
|
||||
timeout: 1800
|
||||
# Session max duration (in seconds, default : 12h)
|
||||
max_duration: 43200
|
||||
# Directory path where to store PHP sessions data (optional, default: use system default)
|
||||
directory_path: "${data_directory}/sessions"
|
||||
|
||||
#
|
||||
# Database configuration
|
||||
|
@ -159,6 +163,9 @@ auth:
|
|||
# Login form
|
||||
#
|
||||
login_form:
|
||||
# Include application navbar (default: true)
|
||||
include_navbar: true
|
||||
|
||||
# Display link for other authentication methods
|
||||
# Note: method as key and label as value
|
||||
display_other_methods:
|
||||
|
@ -219,6 +226,30 @@ auth:
|
|||
# CAS Fake authenticated user
|
||||
#fake_authenticated_user: 'myusername'
|
||||
|
||||
#
|
||||
# Database user backend
|
||||
#
|
||||
db:
|
||||
# DSN (required)
|
||||
dsn: "${db.dsn}"
|
||||
# Username (optional but could be required with some PDO drivers)
|
||||
user: "${db.user}"
|
||||
# Password (optional)
|
||||
password: "${db.password}"
|
||||
# PDO options (optional)
|
||||
options: "${db.options}"
|
||||
# Users table name (optional, default: users)
|
||||
#users_table: "users"
|
||||
# Username field name (optional, default: username)
|
||||
#username_field: "username"
|
||||
# Password field name (optional, default: password)
|
||||
#password_field: "password"
|
||||
# Exposed users table fields in resulting EesyPHP\Auth\User object
|
||||
# (optional, defailt: name, mail)
|
||||
#exposed_fields:
|
||||
# - "name"
|
||||
# - "mail"
|
||||
|
||||
#
|
||||
# LDAP user backend
|
||||
#
|
||||
|
|
1
skel/data/sessions/.gitignore
vendored
Normal file
1
skel/data/sessions/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
sess_*
|
|
@ -84,6 +84,10 @@ class Db extends Backend {
|
|||
)
|
||||
);
|
||||
self :: $dsn = App::get('auth.db.dsn', null, 'string');
|
||||
if (!self :: $dsn) {
|
||||
Log :: warning('No database DSN configured, can not initialize this authentication backend');
|
||||
return false;
|
||||
}
|
||||
self :: $user = App::get('auth.db.user', null, 'string');
|
||||
self :: $password = App::get('auth.db.password', null, 'string');
|
||||
self :: $options = App::get('auth.db.options', null, 'array');
|
||||
|
@ -91,7 +95,7 @@ class Db extends Backend {
|
|||
self :: $username_field = App::get('auth.db.username_field', null, 'string');
|
||||
self :: $password_field = App::get('auth.db.password_field', null, 'string');
|
||||
self :: $exposed_fields = App::get('auth.db.exposed_fields', null, 'array');
|
||||
return boolval(self :: $dsn);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,6 +21,7 @@ class Form extends Method {
|
|||
'auth.login_form',
|
||||
array(
|
||||
'display_other_methods' => array(),
|
||||
'include_navbar' => true,
|
||||
)
|
||||
);
|
||||
Url :: add_url_handler('#^login$#', array('EesyPHP\\Auth\\Form', 'handle_login'), null, false);
|
||||
|
@ -69,6 +70,7 @@ class Form extends Method {
|
|||
else
|
||||
Tpl :: assign('next', (isset($_REQUEST['next'])?urldecode($_REQUEST['next']):''));
|
||||
Tpl :: assign('display_other_methods', $display_other_methods);
|
||||
Tpl :: assign('include_navbar', App::get('auth.login_form.include_navbar', null, 'bool'));
|
||||
Tpl :: display('login.tpl', I18n::_('Sign in'));
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ class Session {
|
|||
array(
|
||||
'max_duration' => 43200, // 12h
|
||||
'timeout' => null,
|
||||
'directory_path' => null,
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -38,6 +39,16 @@ class Session {
|
|||
Config :: ini_set('session.gc_maxlifetime', strval(self :: $max_duration));
|
||||
Config :: ini_set('session.cookie_lifetime', strval(self :: $max_duration));
|
||||
|
||||
// Set custom session directory (if configured)
|
||||
$directory_path = App::get('session.directory_path', null, 'string');
|
||||
if ($directory_path) {
|
||||
Log :: trace('Set session directory path as "%s"', $directory_path);
|
||||
if (!session_save_path($directory_path)) {
|
||||
Log :: warning('Fail to set session directory path as "%s"', $directory_path);
|
||||
}
|
||||
}
|
||||
Log :: debug('Use session directory "%s"', session_save_path());
|
||||
|
||||
// Start session
|
||||
session_start();
|
||||
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
{extends file='Tpl:empty.tpl'}
|
||||
{if !$include_navbar}
|
||||
{block name="navbar"}{/block}
|
||||
{/if}
|
||||
{block name="pagetitle"}{/block}
|
||||
{block name="content"}
|
||||
{block name="main"}
|
||||
<main class="form-signin w-100 m-auto text-center">
|
||||
<form action="login" method="POST">
|
||||
{if !$include_navbar}
|
||||
<img class="mb-4" src="{static_url path="images/logo.svg"}" alt="" width="100">
|
||||
{/if}
|
||||
<h1 class="h3 mb-3 fw-normal">{t domain=$CORE_TEXT_DOMAIN}Sign in{/t}</h1>
|
||||
|
||||
{include file='Tpl:errors.tpl'}
|
||||
|
|
Loading…
Reference in a new issue