admin管理员组

文章数量:1287665

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.

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.

Share Improve this question asked Mar 2, 2013 at 17:27 Arjun PatelArjun Patel 3536 silver badges22 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 10

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/wiki/Basic_access_authentication

本文标签: javascriptHow to display HTTP 401 basic authentication dialogStack Overflow