You are on page 1of 9

Basic

Authentification for
Web Services

Luong The Nhan

Chapter 2
Basic Authentification for Web Services Basic Auth
concepts

Implementation
Mobile Application Development

Luong The Nhan


Faculty of Computer Science and Engineering
Ho Chi Minh University of Technology, VNU-HCM

2.1
Basic
Overview Authentification for
Web Services

Luong The Nhan

1 Basic Auth concepts Basic Auth


concepts

Implementation

2 Implementation

2.2
Basic
Why Basic Auth? Authentification for
Web Services

Luong The Nhan

• You should secure your web service, i.e.


everyone can not access your web service. Basic Auth
concepts

Implementation
• Basic Auth is a well and clearly defined
specification.

• It’s super simple.

2.3
Basic
How it works (1) Authentification for
Web Services

Luong The Nhan


• You take the username and the password,
and you put them into a colon-separated
string like so: "xxx:yyy".
• You then prepend the word "Basic " to Basic Auth
concepts
the string, so that you have: "Basic Implementation

xxx:yyy".
• You then base64 encode the API key
portion of the string, so you end up with:
"Basic eHh4Onl5eQ==".
• Lastly, you set this value as your
"Authorization" header when you make
your HTTP requests.
2.4
Basic
How it works (2) Authentification for
Web Services

Luong The Nhan

When the web server receives your request, it


then:
• base64 decodes the header value. Basic Auth
concepts
• Splits the string by the colon character. Implementation

• The left-hand portion is the username, the


right hand portion is the password.
• The server then validates these credentials,
and either allows you access or returns an
HTTP 401 UNAUTHORIZED response.

2.5
Basic
Authentification function Authentification for
Web Services

Luong The Nhan

Basic Auth
concepts

Implementation

2.6
Basic
Implement a Web service using HTTP headers Authentification for
Web Services

Luong The Nhan

Basic Auth
concepts

Implementation

2.7
Basic
Testing a Web service with Basic Auth Authentification for
Web Services

Luong The Nhan

Basic Auth
concepts

Implementation

2.8
Basic
Testing a Web service without Basic Auth Authentification for
Web Services

Luong The Nhan

Basic Auth
concepts

Implementation

2.9

You might also like