Role Based Access Control. Using PHP Sessions



Similar documents
USING MYWEBSQL FIGURE 1: FIRST AUTHENTICATION LAYER (ENTER YOUR REGULAR SIMMONS USERNAME AND PASSWORD)

Online Multimedia Winter semester 2015/16

Virtual Code Authentication User s Guide. June 25, 2015

How to Setup Auto Recording for MyPBX U100/200/300

INTRODUCTION: SQL SERVER ACCESS / LOGIN ACCOUNT INFO:

Welcome (slide 1) Welcome to the Florida Department of Education Single Sign-On tutorial for federated user login and navigation.

Safewhere*Identify 3.4. Release Notes

PRiSM Security. Configuration and considerations

Enhanced Login Security Frequently Asked Questions

MULTI-FACTOR AUTHENTICATION SET-UP

MULTI-FACTOR AUTHENTICATION SET-UP

DIPLOMA IN WEBDEVELOPMENT

Secure Global Desktop (SGD)

Online shopping store

Binding an OS X computer to Active Directory at NEIU (Existing User)

HowTo. Planning table online

Web Meetings through VPN. Note: Conductor means person leading the meeting. Table of Contents. Instant Web Meetings with VPN (Conductor)...

In this topic we will cover the security functionality provided with SAP Business One.

Application Security Testing. Generic Test Strategy

Breaking Web Applications in Shared Hosting Environments. Nick Nikiforakis Katholieke Universiteit Leuven

Lenovo Partner Access - Overview

Mapping ITS s File Server Folder to Mosaic Windows to Publish a Website

How To Use Syntheticys User Management On A Pc Or Mac Or Macbook Powerbook (For Mac) On A Computer Or Mac (For Pc Or Pc) On Your Computer Or Ipa (For Ipa) On An Pc Or Ipad

How do I Install and Configure MS Remote Desktop for the Haas Terminal Server on my Mac?

Contactegration for The Raiser s Edge

Database Management Systems [COP5725] Project Deliverable 2. SaferDC. Submitted By: Group 1

PowerLink for Blackboard Vista and Campus Edition Install Guide

Enrollment Process for Android Devices

OneLogin Integration User Guide

How do I Install and Configure MS Remote Desktop for the Haas Terminal Server on my Mac?

How to Use Remote Access Using Internet Explorer

MySQL Manager. User Guide. July 2012

M&T Web InfoPLU$ GETTING STARTED GUIDE

Web Application Development Using UML

NetSupport DNA Configuration of Microsoft SQL Server Express

Administrator's Guide

How to Re-Direct Mobile Visitors to Your Library s Mobile App

MySQL Quick Start Guide

Remote Access: Internet Explorer

WEB-BASED CLAIMS REPORTING AN OVERVIEW OF THE ONLINE FIRST NOTICE OF LOSS TOOL

UNI Login. Authentication

Table of Contents. Changing Your Password in Windows NT p. 1. Changing Your Password in Alpha Connection.. pp. 1-3

Troubleshooting problems with the PDMWorks Enterprise database server

9. Database Management Utility

MySQL Quick Start Guide

UNIX PINE Setup process to access Exchange Mail Account

Policies and Procedures for creating and maintaining a site

EMR Link Server Interface Installation

Active Directory Validation - User Guide

Use Enterprise SSO as the Credential Server for Protected Sites

E-Commerce: Designing And Creating An Online Store

Upgrade Guide BES12. Version 12.1

Secure Messaging Server Console... 2

Virtual Code Authentication User Guide for Administrators

Self-service password management user guide

NetBeat NAC Version 9.2 Build 4 Release Notes

Service Desk R11.2 Upgrade Procedure - Resetting USD passwords and unlocking accounts in etrust Web Admin

Configuring SQL Server Lock (Block) Monitoring With Sentry-go Quick & Plus! monitors

Knowledge Base Article: Article 218 Revision 2 How to connect BAI to a Remote SQL Server Database?

Creating IBM Cognos Controller Databases using Microsoft SQL Server

Visual COBOL ASP.NET Shopping Cart Demonstration

Thick Client Application Security

A detailed walk through a CAS authentication

SINGLE SIGN-ON FOR MTWEB

SAML Security Option White Paper

User Guide. NAS Compression Setup

Web Authentication Application Note

Central Administration QuickStart Guide

NetSupport DNA Configuration of Microsoft SQL Server Express

Client SSL Integration Guide

IIS, FTP Server and Windows

mylittleadmin for MS SQL Server Quick Start Guide

OFFICE OF KNOWLEDGE, INFORMATION, AND DATA SERVICES (KIDS) DIVISION OF ENTERPRISE DATA

User Migration Tool. Note. Staging Guide for Cisco Unified ICM/Contact Center Enterprise & Hosted Release 9.0(1) 1

MIGRATING TO AVALANCHE 5.0 WITH MS SQL SERVER

Monitor Print Popup for Mac. Product Manual.

PHP Language Binding Guide For The Connection Cloud Web Services

Table of Contents. RFMS SQL Backup

Advanced Tornado TWENTYONE Advanced Tornado Accessing MySQL from Python LAB

USER MANUAL DOCUMENT SHARING SYSTEM FOR AIMS. VERSION 1.0 (03-Dec-2014) Prepared By

WebEx Scheduling A Meeting using the Quick Scheduler

Business Banking Customer Login Experience for Enhanced Login Security

CONNECT-TO-CHOP USER GUIDE

Reporting works by connecting reporting tools directly to the database and retrieving stored information from the database.

Understanding Sql Injection

AAI for Mobile Apps How mobile Apps can use SAML Authentication and Attributes. Lukas Hämmerle

PHP Authentication Schemes

Achieving PCI COMPLIANCE with the 2020 Audit & Control Suite.

MultiSite Manager. User Guide

How To Run Anolicense Server On A Windows 7.5 (For Free) Or 8 (For Ubuntu) Or For Free (For Microsoft) (For Linux) (Or For Free) ( For

Marcum LLP MFT Guide

SCADA Security. Enabling Integrated Windows Authentication For CitectSCADA Web Client. Applies To: CitectSCADA 6.xx and 7.xx VijeoCitect 6.xx and 7.

Note: With v3.2, the DocuSign Fetch application was renamed DocuSign Retrieve.

SQL EXPRESS INSTALLATION...

Merchant Warehouse Credit Card Integration Gym Assistant August 2009

Webmail Using the Hush Encryption Engine

Human Computer Interaction Final Project Tutorial. Hardware Inventory Management System (HIMS) By M. Michael Nourai

Hallpass Instructions for Connecting to Mac with a Mac

Transcription:

Role Based Access Control Using PHP Sessions

Session Developed in PHP to store client data on the web server, but keep a single session ID on the client machine (cookie) The session ID : identifies the user uniquely for the duration of the user s visit to your site PHP sessions are automatically set as a cookie in the user s browser that contains the session ID Your pages can check the session ID and do something with it.

Working with Session IDs To look for an existing session ID or create a new one: session_start(); Set a variable with session data: $_SESSION[ password ] = iamawesome ; Remove a variable from the current session: Unset($_SESSION[ password ]); End the session and delete all registered variables $_SESSION = array(); Session_destroy();

Access Control Require username and password authentication for some or all of your site Require a valid login for relevant (protected) pages Use PHP to prompt the user and check the login credentials in their session as appropriate

User Data Where? User authentication requires user data to be saved on the server User name, password, email, etc. Use PHP to prompt the user and check the login credentials on the server to set variables. At each protected page, check variables to confirm that the user is authorized

Roles Some pages may be protected from certain groups of users, but not others Assign a role to a user s login credentials. If the role allows access, the user can access the protected page for that role. Allows varying levels of protection Site administrators Content editors

The Controller The controller can have gatekeeper PHP code to only allow actions if the user is logged in. Place this gatekeeper code at the beginning of the controller to lock down the controller. Artist s index.php restricts artists Album s index.php restricts albums This example uses a function to check session: if (!userisloggedin()) { include../login.html.php ; //go to login page exit(); }

userisloggedin() Create this function in a new file that must be included before the function can be used: access.inc.php This function checks if the user is logged in function userisloggedin() { if (isset($_post[ action ]) and $_POST[ action ] == login ) { 1. check for $_POST[ email ] and $_POST[ email ] from login form 2. Scramble password with md5 3. Query the database and match submitted data to database data (use another custom function so you can reuse this) 4. Login the user with a session variable. This can be checked again later once it is set because it is saved for the entire session. Example: $_SESSION[ loggedin ] = TRUE Note: You can store the login and password info instead in session variables so you can re-check them against the database during the session for added security.

The Controller The controller can have gatekeeper PHP code to only allow actions if the user is assigned to the appropriate role. Place this gatekeeper code at the beginning of the controller to lock down the controller. Artist s index.php restricts artists Album s index.php restricts albums This example uses a function to check role: if (!userhasrole( Site Administrator )) { $error = Only Site Administrators Allowed ; Include../accessdenied.html.php ; exit(); }

userhasrole($role) Query database for user roles If user is not assigned to the appropriate role, produce error and return FALSE, otherwise return TRUE

New Pages for Access Control login.html.php //login form accessdenied.html.php //error message access.inc.php //contains authorizing functions

User and Role Data User data: primary key, login, password, email, etc Role data: primary key, description. Examples: Content Editor Account Administrator Site Administrator

Many-To-Many Relationship Users can have many roles. Roles will have many users Create transition table: userrole userid + roleid = composite primary key

userhasrole($role) Query database for user roles If user is not assigned to the appropriate role, produce error and return FALSE, otherwise return TRUE Three tables: user, role, userrole: $sql = SELECT COUNT(*) FROM user INNER JOIN userrole ON user.user_id = userrole.user_id INNER JOIN role ON userrole.role_id = role.role_id WHERE user.email = :email AND role.role_id = :role_id;

userhasrole($role) $s = $pdo->prepare($sql) then bind and execute $row = $s->fetch(); //fetch results of sql If($row[0] > 0) //if result set is empty then no match { return TRUE;} //user has role else {return FALSE;} //user doesn t have role