Skip to content
World Wide Web Server edited this page Jul 4, 2012 · 37 revisions

A simple security system [work in progress].

[h3] Introduction [/h3]

The sentry system uses a configurable database table, which is configurable and only saves minimal information to the session. I use the Sentry class in conjunction with the Filters_system.

The Sentry system is made up of the following components:

  • SentryLib core library class in the system\library\Sentry.php - SentryLib core library handles the heavy lifting of performing the security functions.

  • The initializer in the system\init\init_sentry.php - The Sentry installation script installs the sentry class once and only once.

  • The configuration in the system\application\config\sentry.php - The configuration allows you to set various configuration options and tailor the sentry library to your system without a lot of reworking of code.

  • The sentry helper file in system\helper\sentry.php - Sentry helper wraps SentryLib calls to make them easier to use from views.

  • The Sentry controller class in the system\application\controllers\sentry.php - System controller class routes calls to the SentryLib library.

  • View in the system\application\views\sentry

[h3] Features [/h3]

Login/logout functionality. Registration, with security code image and activation. Forgotten password reset. Auto-login (not yet complete).

[h3] Installation [/h3]

I would recommend installing the NativeSession and Sentry libraries to the system\libraries folder so that is is available across applications. The init script can handle the sentry system being in either the application or system libraries folder. Both the NativeSession and Sentry libraries should be set as autoloaded core libraries.

The zip file contains the Sentry and the NativeSession library files. If you wish to use it with the Filter system, see the Filters_system wiki. It also includes a sample filter.

[h3] Code [/h3]

File:sentry.zip

[h3] Database [/h3]

This is a sample MySQL database table for use with the Sentry system.

[code] DROP TABLE IF EXISTS user; CREATE TABLE user ( id INTEGER NOT NULL AUTO_INCREMENT, user_name VARCHAR(45) NOT NULL, password VARCHAR(50) NOT NULL, email VARCHAR(120) NOT NULL, activated BOOLEAN NOT NULL DEFAULT false, activation_code VARCHAR(50) NULL, forgotten_password_code VARCHAR(50) NULL, last_visit DATETIME NULL DEFAULT NULL, created TIMESTAMP NOT NULL, modified TIMESTAMP NOT NULL, PRIMARY KEY (id) )Type=InnoDB; [/code]

Category:Libraries

Clone this wiki locally