SlideShare a Scribd company logo
2
Most read
8
Most read
10
Most read
Authenticating Your Users
BY
SANA MATEEN
HTTPAuthentication Concepts
• The HTTP protocol offers a fairly effective means for user authentication, with a typical
authentication scenario proceeding like this:
1. The client requests a restricted resource.
2. The server responds to this request with a 401 (Unauthorized access) response message.
3. The browser recognizes the 401 response and produces a pop-up authentication
prompt . All modern browsers are capable of understanding HTTP authentication
and offering appropriate capabilities, including Internet Explorer, Netscape
Navigator, Mozilla Firefox, and Opera.
4. The user-supplied credentials (typically a username and password) are sent back to the
server for validation. If the user supplies correct credentials, access is granted; otherwise
it’s denied.
5. If the user is validated, the browser stores the authentication information within its
cache. This cache information remains within the browser until the cache is cleared,
or until another 401 server response is sent to the browser.
Limitation
• Although HTTP authentication effectively controls access to restricted resources, it
does not secure the channel in which the authentication credentials travel.
• That is, it is possible for a well-positioned attacker to sniff, or monitor, all traffic
taking place between a server and a client, and within this traffic are the
unencrypted username and password.
• To eliminate the possibility of compromise through such a method, you need to
implement a secure communications channel, typically accomplished using Secure
Sockets Layer (SSL).
• SSL support is available for all mainstream web servers, including Apache and
Microsoft Internet Information Server (IIS).
Using Apache’s .htaccess Feature
• Blanket access control
• The simplest form of access control is to authorize certain users for either read-only
access to a repository or read/write access to a repository.
• You’ll take advantage of this feature by creating a file named .htaccess and storing
it within the directory you’d like to protect. Therefore, if you’d like to restrict
access to an entire website, place this file within your site’s root directory.
• In its simplest format, the .htaccess file’s contents look like this:
• AuthUserFile /path/to/.htpasswd
• AuthType Basic
• AuthName "My Files"
• Require valid-user
• Replace /path/to with the path that points to another requisite file named .htpasswd.
• This file contains the username and password which the user must supply in order
to access the restricted content.
• However, as a reference, the typical .htpasswd file looks like this:
• admin:TcmvAdAHiM7UY
• client:f.i9PC3.AtcXE
• Each line contains a username and password pair, with the password encrypted to
prevent prying eyes from potentially obtaining the entire identity.
• When the user supplies a password, Apache will encrypt the provided password
using the same algorithm originally used to encrypt the password stored in the
.htpasswd file, comparing the two for equality.
Authentication methods
Authenticating Your Users with PHP
• PHP’s Authentication Variables
• PHP uses two predefined variables to authenticate a user:
$_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW']. These
variables store the username and password values, respectively.
• While authenticating is as simple as comparing the expected username and
password to these variables
• Both variables must be verified at the start of every restricted page. You can easily
accomplish this by authenticating the user prior to performing any other action on
the restricted page, which typically means placing the authentication code in a
separate file and then including that file in the restricted page using the require()
function.
• These variables do not function properly with the CGI version of PHP.
• Useful Functions Two standard functions are commonly used when handling
authentication via PHP: header() and isset(). Both are introduced in this section.
Sending HTTP Headers with header()
• The header() function sends a raw HTTP header to the browser. The header
parameter specifies the header information sent to the browser. Its prototype follows:
• void header(string header [, boolean replace [, int http_response_code]])
• The optional replace parameter determines whether this information should replace or
accompany a previously sent header. Finally, the optional http_response_code parameter
defines a specific response code that will accompany the header information.
• Applied to user authentication, this function is useful for sending the WWW
authentication header to the browser, causing the pop-up authentication prompt to be
displayed.
• It is also useful for sending the 401 header message to the user if incorrect
authentication credentials are submitted.
Determining if a Variable is Set with isset()
• The isset() function determines whether a variable has been assigned a value. Its
prototype follows:
• boolean isset(mixed var [, mixed var [,...]])
• It returns TRUE if the variable contains a value and FALSE if it does not.
• As applied to user authentication, the isset() function is useful for determining
whether the $_SERVER['PHP_AUTH_USER'] and
$_SERVER['PHP_AUTH_PW'] variables are properly set.
Hard-Coded Authentication
• The simplest way to restrict resource access is by hard-coding the username and
password directly into the script.
• In the example shown in next slide, if $_SERVER['PHP_AUTH_USER'] and
$_SERVER['PHP_AUTH_PW'] are equal to client and secret, respectively, the code
block will not execute, and anything ensuing that block will execute.
• Otherwise, the user is prompted for the username and password until either the
proper information is provided or a 401 Unauthorized message is displayed due to
multiple authentication failures.
• Drawbacks:
• Foremost, all users requiring access to that resource must use the same
authentication pair
• Second, changing the username or password can be done only by entering the
code and making the manual adjustment. The next two methodologies remove
these issues.
Authentication methods

More Related Content

PDF
Authentication techniques
PPTX
Network programming in java - PPT
PPTX
Public Key Cryptosystem
PPTX
Web authentication & authorization
PPTX
HTTP request and response
PPTX
Subnetting Presentation
DOCX
Ports and protocols
PPTX
Transmission Control Protocol (TCP)
Authentication techniques
Network programming in java - PPT
Public Key Cryptosystem
Web authentication & authorization
HTTP request and response
Subnetting Presentation
Ports and protocols
Transmission Control Protocol (TCP)

What's hot (20)

PPT
Firewall
PPTX
Http protocol
PPTX
Socket programming in Java (PPTX)
PPTX
Hypertext transfer protocol (http)
PPT
HTTP Basics
PPTX
Network layer - design Issues
PPTX
Secure Socket Layer (SSL)
PPSX
HTTP Presentation
PPTX
A2 - broken authentication and session management(OWASP thailand chapter Apri...
PPTX
Address resolution protocol (ARP)
PDF
SSH - Secure Shell
PPTX
x.509-Directory Authentication Service
PPSX
Subnetting
PPT
Domain name system
PPT
Ip addressing
PPSX
Sessions and cookies
PDF
PPT
Pretty good privacy
PPTX
HyperText Transfer Protocol (HTTP)
PPTX
802.1x
Firewall
Http protocol
Socket programming in Java (PPTX)
Hypertext transfer protocol (http)
HTTP Basics
Network layer - design Issues
Secure Socket Layer (SSL)
HTTP Presentation
A2 - broken authentication and session management(OWASP thailand chapter Apri...
Address resolution protocol (ARP)
SSH - Secure Shell
x.509-Directory Authentication Service
Subnetting
Domain name system
Ip addressing
Sessions and cookies
Pretty good privacy
HyperText Transfer Protocol (HTTP)
802.1x
Ad

Similar to Authentication methods (20)

PPT
Apache Web Server Setup 4
PPT
Htaccess info
PDF
Apache2 BootCamp : Restricting Access
PPTX
Securing your web apps now
PDF
Http and security
PPTX
Secure programming with php
PDF
PHP Making Web Forms
PDF
Session4-Authentication
PPTX
Secure coding | XSS Attacks on current Web Applications
PPTX
Cm2 secure code_training_1day_data_protection
PDF
CNIT 129S - Ch 6a: Attacking Authentication
PPTX
Session management
PDF
Securing the Apache web server
PDF
Securing the Apache web server
ODP
LAMP security practices
PDF
Ch 6: Attacking Authentication
PPT
Presentation (PPT)
PDF
Security in php
PDF
Web security and OWASP
PPTX
Chapter 1.Web Techniques_Notes.pptx
Apache Web Server Setup 4
Htaccess info
Apache2 BootCamp : Restricting Access
Securing your web apps now
Http and security
Secure programming with php
PHP Making Web Forms
Session4-Authentication
Secure coding | XSS Attacks on current Web Applications
Cm2 secure code_training_1day_data_protection
CNIT 129S - Ch 6a: Attacking Authentication
Session management
Securing the Apache web server
Securing the Apache web server
LAMP security practices
Ch 6: Attacking Authentication
Presentation (PPT)
Security in php
Web security and OWASP
Chapter 1.Web Techniques_Notes.pptx
Ad

More from sana mateen (20)

PPTX
PPTX
PHP Variables and scopes
PPTX
Php intro
PPTX
Php and web forms
PPTX
PPTX
Files in php
PPTX
File upload php
PPTX
Regex posix
PPTX
Encryption in php
PPTX
Xml schema
PPTX
Xml dtd
PPTX
Xml dom
PPTX
PPTX
Intro xml
PPTX
Dom parser
PPTX
Unit 1-subroutines in perl
PPTX
Unit 1-uses for scripting languages,web scripting
PPTX
Unit 1-strings,patterns and regular expressions
PPTX
Unit 1-scalar expressions and control structures
PPTX
Unit 1-perl names values and variables
PHP Variables and scopes
Php intro
Php and web forms
Files in php
File upload php
Regex posix
Encryption in php
Xml schema
Xml dtd
Xml dom
Intro xml
Dom parser
Unit 1-subroutines in perl
Unit 1-uses for scripting languages,web scripting
Unit 1-strings,patterns and regular expressions
Unit 1-scalar expressions and control structures
Unit 1-perl names values and variables

Recently uploaded (20)

PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Sports Quiz easy sports quiz sports quiz
PDF
Classroom Observation Tools for Teachers
PDF
Basic Mud Logging Guide for educational purpose
PDF
Insiders guide to clinical Medicine.pdf
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPTX
Cell Structure & Organelles in detailed.
PPTX
Pharma ospi slides which help in ospi learning
PDF
VCE English Exam - Section C Student Revision Booklet
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
human mycosis Human fungal infections are called human mycosis..pptx
Microbial diseases, their pathogenesis and prophylaxis
Final Presentation General Medicine 03-08-2024.pptx
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Microbial disease of the cardiovascular and lymphatic systems
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
TR - Agricultural Crops Production NC III.pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Sports Quiz easy sports quiz sports quiz
Classroom Observation Tools for Teachers
Basic Mud Logging Guide for educational purpose
Insiders guide to clinical Medicine.pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Cell Structure & Organelles in detailed.
Pharma ospi slides which help in ospi learning
VCE English Exam - Section C Student Revision Booklet

Authentication methods

  • 2. HTTPAuthentication Concepts • The HTTP protocol offers a fairly effective means for user authentication, with a typical authentication scenario proceeding like this: 1. The client requests a restricted resource. 2. The server responds to this request with a 401 (Unauthorized access) response message. 3. The browser recognizes the 401 response and produces a pop-up authentication prompt . All modern browsers are capable of understanding HTTP authentication and offering appropriate capabilities, including Internet Explorer, Netscape Navigator, Mozilla Firefox, and Opera. 4. The user-supplied credentials (typically a username and password) are sent back to the server for validation. If the user supplies correct credentials, access is granted; otherwise it’s denied. 5. If the user is validated, the browser stores the authentication information within its cache. This cache information remains within the browser until the cache is cleared, or until another 401 server response is sent to the browser.
  • 3. Limitation • Although HTTP authentication effectively controls access to restricted resources, it does not secure the channel in which the authentication credentials travel. • That is, it is possible for a well-positioned attacker to sniff, or monitor, all traffic taking place between a server and a client, and within this traffic are the unencrypted username and password. • To eliminate the possibility of compromise through such a method, you need to implement a secure communications channel, typically accomplished using Secure Sockets Layer (SSL). • SSL support is available for all mainstream web servers, including Apache and Microsoft Internet Information Server (IIS).
  • 4. Using Apache’s .htaccess Feature • Blanket access control • The simplest form of access control is to authorize certain users for either read-only access to a repository or read/write access to a repository. • You’ll take advantage of this feature by creating a file named .htaccess and storing it within the directory you’d like to protect. Therefore, if you’d like to restrict access to an entire website, place this file within your site’s root directory. • In its simplest format, the .htaccess file’s contents look like this: • AuthUserFile /path/to/.htpasswd • AuthType Basic • AuthName "My Files" • Require valid-user • Replace /path/to with the path that points to another requisite file named .htpasswd. • This file contains the username and password which the user must supply in order to access the restricted content. • However, as a reference, the typical .htpasswd file looks like this: • admin:TcmvAdAHiM7UY • client:f.i9PC3.AtcXE • Each line contains a username and password pair, with the password encrypted to prevent prying eyes from potentially obtaining the entire identity. • When the user supplies a password, Apache will encrypt the provided password using the same algorithm originally used to encrypt the password stored in the .htpasswd file, comparing the two for equality.
  • 6. Authenticating Your Users with PHP • PHP’s Authentication Variables • PHP uses two predefined variables to authenticate a user: $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW']. These variables store the username and password values, respectively. • While authenticating is as simple as comparing the expected username and password to these variables • Both variables must be verified at the start of every restricted page. You can easily accomplish this by authenticating the user prior to performing any other action on the restricted page, which typically means placing the authentication code in a separate file and then including that file in the restricted page using the require() function. • These variables do not function properly with the CGI version of PHP. • Useful Functions Two standard functions are commonly used when handling authentication via PHP: header() and isset(). Both are introduced in this section.
  • 7. Sending HTTP Headers with header() • The header() function sends a raw HTTP header to the browser. The header parameter specifies the header information sent to the browser. Its prototype follows: • void header(string header [, boolean replace [, int http_response_code]]) • The optional replace parameter determines whether this information should replace or accompany a previously sent header. Finally, the optional http_response_code parameter defines a specific response code that will accompany the header information. • Applied to user authentication, this function is useful for sending the WWW authentication header to the browser, causing the pop-up authentication prompt to be displayed. • It is also useful for sending the 401 header message to the user if incorrect authentication credentials are submitted.
  • 8. Determining if a Variable is Set with isset() • The isset() function determines whether a variable has been assigned a value. Its prototype follows: • boolean isset(mixed var [, mixed var [,...]]) • It returns TRUE if the variable contains a value and FALSE if it does not. • As applied to user authentication, the isset() function is useful for determining whether the $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW'] variables are properly set.
  • 9. Hard-Coded Authentication • The simplest way to restrict resource access is by hard-coding the username and password directly into the script. • In the example shown in next slide, if $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW'] are equal to client and secret, respectively, the code block will not execute, and anything ensuing that block will execute. • Otherwise, the user is prompted for the username and password until either the proper information is provided or a 401 Unauthorized message is displayed due to multiple authentication failures. • Drawbacks: • Foremost, all users requiring access to that resource must use the same authentication pair • Second, changing the username or password can be done only by entering the code and making the manual adjustment. The next two methodologies remove these issues.