I am new to web development. I have Android application that hosts some web pages using HTTPServer. I am using Netty to decode/encode request/responses. Now, I want to display basic authentication dialog when someone navigates to the my webpage. Something like this:
Can I get some pointers ? Is it something HTTP built in functionality, any RFC ? Do I need to write some java script ? Any help would be great.
You just need to send the appropriate headers when a client requests a resource you want to require authentication for.
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Basic realm="Restricted Area"
The client can then retry the request while sending a base64 encoded header in the format username:password
.
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
See also: http://en.wikipedia.org/wiki/Basic_access_authentication