Class 8Intro to Databases Authentication and Security Note: What we discuss in class today covers moderate to low security. Before you involve yourself.

Slides:



Advertisements
Similar presentations
LIS651 lecture 3 taming PHP Thomas Krichel
Advertisements

LIS651 lecture 3 taming PHP Thomas Krichel
LIS651 lecture 3 functions & sessions Thomas Krichel
Creating a Login Process Creating a users table and a login form that denies access to unauthorized users.
09/04/2015Unit 2 (b) Back-Office processes Unit 2 Assessment Criteria (b) 10 marks.
1.  Understanding about How to Working with Server Side Scripting using PHP Framework (CodeIgniter) 2.
Protecting Documents on the Web Friday Tech Briefing Timely Info for Power Users and Stanford's Technology Support Community Mark Branom ITSS Technology.
1 Chapter 5 – Handling HTML Controls in Web Pages spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science.
NMD202 Web Scripting Week5. What we will cover today PHPmyAdmin Debugging – using print_r Modifying Data PHP (cont.) 4D Methodology File and IO operations.
It’s always better live. MSDN Events Security Best Practices Part 2 of 2 Reducing Vulnerabilities using Visual Studio 2008.
Manipulating MySQL Databases with PHP. PHP and mySQL2 Objectives Connect to MySQL from PHP Learn how to handle MySQL errors Execute SQL statements with.
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
Chapter 9 Collecting Data with Forms. A form on a web page consists of form objects such as text boxes or radio buttons into which users type information.
Web Programming Week 10 Old Dominion University Department of Computer Science CS 418/518 Fall 2010 Martin Klein 11/02/10.
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
Lecture 6 – Form processing (Part 1) SFDV3011 – Advanced Web Development 1.
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Cookies & Sessions.
Website Security ISYS 475. Authentication Authentication is the process that determines the identity of a user.
Cookies Set a cookie – setcookie() Extract data from a cookie - $_COOKIE Augment user authentication script with a cookie.
An introduction to Apache. Different Types of Web Servers Apache is the default web server for may Unix servers. IIS is Microsoft’s default web server.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
NMED 3850 A Advanced Online Design January 26, 2010 V. Mahadevan.
Set 13: Web Servers (configuration and security) (Chapter 21) IT452 Advanced Web and Internet Systems.
User authentication, passwords
COMP3121 E-Commerce Technologies Richard Henson University of Worcester November 2011.
Online Translation Service Capstone Design Eunyoung Ku Jason Roberts Jennifer Pitts Gregory Woodburn Kim Tran.
12/3/2012ISC329 Isabelle Bichindaritz1 PHP and MySQL Advanced Features.
SYST Web Technologies SYST Web Technologies Databases & MySQL.
Week seven CIT 354 Internet II. 2 Objectives Database_Driven User Authentication Using Cookies Session Basics Summary Homework and Project 2.
E-COMMERCE JOBS This project (Project number: HU/01/B/F/PP ) is carried out with the financial support of the Commssion of the European Communities.
NMD202 Web Scripting Week3. What we will cover today Includes Exercises PHP Forms Exercises Server side validation Exercises.
Web Site Access Control with Apache Fort Collins, CO Copyright © XTR Systems, LLC Web Site Access Control Using the Apache Web Server Instructor: Joseph.
10/20/2015 ©2006 Scott Miller, University of Victoria 1 User Authentication Content Generation The Use of Cookies Content Pooling Rev 1.5.
PHP+MySQL Integration. Connecting to databases One of the most common tasks when working with dynamic webpages is connecting to a database which holds.
Apache Security Travis Jeffries. Introduction Authentication and Authorization Strict Access Methods Defending against Attacks Bad CGI Programs Apache.
Creating Databases CSS example. One-way encryption. Passwords. Security issues. Work session.. Homework: Making unique posting on encryption, passwords,
CHAPTER 9 PHP AND MYSQL. A POSSIBLE SITE CONFIGURATION Application Folder index.php includes (folder)header.phpfooter.phpstyle.cssmodel (folder)mysqli_connect.php.
Intro to DatabasesClass 4 SQL REVIEW To talk to the database, you have to use SQL SQL is used by many databases, not just MySQL. SQL stands for Structured.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP & MySQL.
Putting it all together Dynamic Data Base Access and Authentication Norman White Stern School of Business.
Sessions, Cookies, &.htaccess IT 210. Procedural Issues  Quiz #3 Today!  Homework #3 Due Friday at midnight UML for Lab 4  Withdraw Deadline is Wed,
PHP-based Authentication
NMD202 Web Scripting Week5. What we will cover today PHP & MySQL Displaying Dynamic Pages Exercises Modifying Data PHP Exercises Assignment 1.
PHP Secure Communications Web Technologies Computing Science Thompson Rivers University.
PHP and SQL Server: Connection IST2101. Typical web application interaction (php, jsp…) database drivers 2IST210.
Authentication Names and Passwords Names and Passwords Also can use Groups Also can use Groups Webmaster can “require” authentication Webmaster can “require”
Creating Databases One-way encryption. Passwords. Security issues. Data normalization. Integrity and Robustness. Homework: Finalize teams & projects. Making.
Database Access Control IST2101. Why Implementing User Authentication? Remove a lot of redundancies in duplicate inputs of database information – Your.
Web Technology – Web Server Setup : Chris Uriarte Meeting 4: Advanced Topics, Continued: Securing the Apache Server and Apache Performance Tuning Rutgers.
How to maintain state in a stateless web Shirley Cohen
Class 3Intro to Databases Class 4 Simple Example of a Database We’re going to build a simple example of a database, which will allow us to register users.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 1: Introduction to IS2803 Rob Gleasure
SlideSet #18: HTTP Authentication
Preventing MySQL Injection Sonja Parson COSC 5010 Security Presentation April 26, 2005.
PHP Form Processing * referenced from
CS520 Web Programming Declarative Security (I) Chengyu Sun California State University, Los Angeles.
Authentication & Authorisation Is the user allowed to access the site?
Web Security (cont.) 1. Referral issues r HTTP referer (originally referrer) – HTTP header that designates calling resource  Page on which a link is.
PHP Secure Communications
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Authentication & .htaccess
Chapter 8 Building the Transaction Database
Enhanced Web Site Design Stanford University Continuing Studies CS 22
Chapter 19 PHP Part III Credits: Parts of the slides are based on slides created by textbook authors, P.J. Deitel and H. M. Deitel by Prentice Hall ©
Web Systems Development (CSC-215)
PHP: Security issues FdSc Module 109 Server side scripting and
Electronic Payment Security Technologies
PHP Secure Communications
Presentation transcript:

Class 8Intro to Databases Authentication and Security Note: What we discuss in class today covers moderate to low security. Before you involve yourself in a project that requires high security – credit card info, social security numbers etc - take a class on database security. It’s becoming more common for sites to keep records of the transactions while offloading payment etc to sites like Paypal, which handle the secure side of the transaction. This approach minimizes risk and cost. That said, what we’re covering today will let you control user access.

Class 8Intro to Databases Authentication and Security HTTP authentication Using PHP scripts to manage user authentication and authorization Using PHP scripts to authenticate users against a database Building session based web database applications to authenticate users SSL – Secure Sockets Layer

Class 8Intro to Databases HTTP authentication HTTP authentication allows you to password protect a directory There are 3 steps 1- Create a access file, which describes which users can access a site. 2- Create a password file, which lists users names and passwords allowed. 3- upload files

Class 8Intro to Databases HTTP authentication 1- Create an access file, which describes which users can access a site. Open the text editor and save a new file called “.htaccess ” ---Basic Format AuthUserFile /full_path/.htpasswd AuthGroupFile /dev/null AuthName “Page Name" AuthType basic require user UserName ---Example AuthUserFile /home/denning/www/ezcontents1_4x/contentdocument/intro_to_db/cl_8/http_pass/.htpasswd AuthGroupFile /dev/null AuthName "Super Secret Page" AuthType basic require user valid-user full_path is the location of the.htpasswd file. This should be outside your normal directories. UserName is the name of users allowed to access the pages. Use valid-user if more than one person can access the directory. Use a specific username, in this case Test, if more only one person can access the directory. There is no group file, so we specify /dev/null (the standard Unix way to say "this file doesn't exist").

Class 8Intro to Databases HTTP authentication 2- Create a password file, which lists users names and passwords allowed. Open the text editor and save a new file called “.htpasswd ” Decide on user name and password name: Test password: Class Generate the password, using a tool that encrypts the password (see link form syllabus to ) ---Basic Format UserName:Password ---Example Test:180TuOLtbRWCU It's crucial that you press enter after each line (the last line should be an empty one, not a line with a password entry in it) and that you upload the file as 'text' or 'ascii'. Also, keep in mind that these lines are case- sensitive; you should enter a capital as a capital and a lower-case character as a lower-case character.

Class 8Intro to Databases HTTP authentication 3- upload files.htpasswd should go to a secure location on your website.htaccess should go in the directory you want to protect NOTE: the “full path” in.htaccess needs to match the location of.htpasswd

Class 8Intro to Databases HTTP authentication Multiple users 1- modify.htpasswd user1 :NgFQ1vnnW/tJk user2 :mWaquohh.OY3w user3 :EMt8amgnyuYD2 Using groups 1- create a file called “.htgroup” (similar to.htpasswd) my-users: user1 user2 user3 modify the.htaccess file in the directory to look like this: AuthUserFile /home/john/.htpasswd AuthGroupFile /home/john/.htgroup AuthName “Johns page” AuthType Basic require group my-users

Class 8Intro to Databases Using PHP scripts to manage user authentication and authorization PHP can access the name and password variables submitted through HTTP authentication "); print(“Hi this is the index "); print("You are: $PHP_AUTH_USER "); print("using password: $PHP_AUTH_PW "); print(" "); ?>

Class 8Intro to Databases Using PHP scripts to authenticate users against a database 1- Creating the table User name must be unique

Class 8Intro to Databases Using PHP scripts to authenticate users against a database 1- Make “password” a key 2- Result

Class 8Intro to Databases Protecting password in the database 1- Built in PHP functions crypt (PHP 3, PHP 4 ) crypt -- One-way string encryption (hashing) Description string crypt ( string str [, string salt]) crypt() will return an encrypted string using the standard Unix DES-based encryption algorithm or alternative algorithms that may be available on the system. Arguments are a string to be encrypted and an optional salt string to base the encryption on. See the Unix man page for your crypt function for more information. If the salt argument is not provided, one will be randomly generated by PHP.

Class 8Intro to Databases Protecting password in the database 1- Logical Flow Testing if the user is logged in "); print("main page of site - authenticated user only"); print(" "); } ?>

Class 8Intro to Databases Protecting password in the database 1- Logical Flow Testing if the user is logged in "); if($action=="register"){ register_new_user($u_username, $u_password); //say hello print ("Welcome to the site"); }elseif($action=="new_user"){ register_form(); }elseif($action=="login"){ $valid_user=login_user($u_username, $u_password); if(!$valid_user){ // show login with error $error="Sorry, that user name and password aren't found"; login_form($error); }else{ //say hello print ("Hi - we're glad you came back"); } }else{ $error=""; login_form($error); } print(" "); ?>

Class 8Intro to Databases Protecting password in the database 1- Creating a new user function register_form(){ print(" Please register Name: Password: "); }

Class 8Intro to Databases Protecting password in the database 1- Creating a new user 2 function register_new_user($u_username, $u_password){ GLOBAL $hostname, $dbUsername, $dbPassword, $dbName, $usersTable; // CRYPT OUR PASSWORD $salt=substr($u_username, 0, 2); $crypted_password=crypt($u_password, $salt); /// INSERT RECORD // open connection to host $link =MYSQL_CONNECT($hostname, $dbUsername, $dbPassword) OR die("error 1 - DB connection failed"); // connect to specific database mysql_select_db($dbName)OR die("error 2 - failure to connect to DB"); // formulate our question $query="INSERT INTO $usersTable (user_name, password) values ('$u_username', '$crypted_password')"; // ask the question $result =mysql_query($query)OR die("error 3 - query failed"); }

Class 8Intro to Databases Protecting password in the database 1- Authenticating an Existing User function login_form($error){ print(" Please Login $error Name: Password: New Users register here "); }

Class 8Intro to Databases Protecting password in the database 1- Authenticating an Existing User 2 function login_user($u_username, $u_password){ GLOBAL $hostname, $dbUsername, $dbPassword, $dbName, $usersTable; // make sure username and password are filled in if(!isset($u_username)||!isset($u_username)){ return false; } // recreate the encrypted password stored on the database $salt=substr($u_username, 0, 2); $crypted_password=crypt($u_password, $salt); // see if we can find the user in the database // open connection to host $link =MYSQL_CONNECT($hostname, $dbUsername, $dbPassword) OR die("error 1 - DB connection failed"); // connect to specific database mysql_select_db($dbName)OR die("error 2 - failure to connect to DB"); // formulate our question $query="SELECT password FROM $usersTable WHERE user_name='$u_username' AND password='$crypted_password'"; // ask the question $result =mysql_query($query)OR die("error 3 - query failed"); // if there's exactly one row we've found the user if(mysql_num_rows($result) !=1){ return false; }else{ return true; } }