.\" Copyright (c) 2001-2002 Packet Design, LLC. .\" All rights reserved. .\" .\" Subject to the following obligations and disclaimer of warranty, .\" use and redistribution of this software, in source or object code .\" forms, with or without modifications are expressly permitted by .\" Packet Design; provided, however, that: .\" .\" (i) Any and all reproductions of the source or object code .\" must include the copyright notice above and the following .\" disclaimer of warranties; and .\" (ii) No rights are granted, in any manner or form, to use .\" Packet Design trademarks, including the mark "PACKET DESIGN" .\" on advertising, endorsements, or otherwise except as such .\" appears in the above copyright notice or in the software. .\" .\" THIS SOFTWARE IS BEING PROVIDED BY PACKET DESIGN "AS IS", AND .\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, PACKET DESIGN MAKES NO .\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING .\" THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED .\" WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, .\" OR NON-INFRINGEMENT. PACKET DESIGN DOES NOT WARRANT, GUARANTEE, .\" OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS .\" OF THE USE OF THIS SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, .\" RELIABILITY OR OTHERWISE. IN NO EVENT SHALL PACKET DESIGN BE .\" LIABLE FOR ANY DAMAGES RESULTING FROM OR ARISING OUT OF ANY USE .\" OF THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY DIRECT, .\" INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE, OR CONSEQUENTIAL .\" DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, LOSS OF .\" USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY THEORY OF .\" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF .\" THE USE OF THIS SOFTWARE, EVEN IF PACKET DESIGN IS ADVISED OF .\" THE POSSIBILITY OF SUCH DAMAGE. .\" .\" Author: Archie Cobbs .\" .\" $Id: http_servlet_basicauth.3,v 1.1 2012/02/21 23:25:53 misho Exp $ .\" .Dd April 22, 2002 .Dt HTTP_SERVLET_AUTH 3 .Os .Sh NAME .Nm http_servlet_basicauth .Nd HTTP basic authentication servlet .Sh LIBRARY PDEL Library (libpdel, \-lpdel) .Sh SYNOPSIS .In sys/types.h .In stdio.h .In netinet/in.h .In openssl/ssl.h .In pdel/http/http_defs.h .In pdel/http/http_server.h .In pdel/http/servlet/basicauth.h .Ft "struct http_servlet *" .Fn http_servlet_basicauth_create "http_servlet_basicauth_t *auth" "void *arg" "void (*destroy)(void *)" .Sh DESCRIPTION .Fn http_servlet_basicauth_create creates a new servlet that implements HTTP basic authentication. The servlet should be registered with a lower order than the other servlets that it protects, so that it executes first. .Pp .Fa auth is a pointer to a function having this type: .Pp .Bd -literal -compact -offset 3n typedef const char *http_servlet_basicauth_t(void *arg, struct http_request *req, const char *username, const char *password); .Ed .Pp .Fa arg is the opaque cookie supplied to .Fn http_servlet_basicauth_create . .Fa req is the HTTP request object and .Fa username and .Fa password are the credentials supplied with the request, or the empty string if none were supplied. .Pp .Fn auth should return .Dv NULL to allow access. Otherwise, it should return the authorization realm string to deny access. This string is not freed by the calling function. .Em Warning : this is reversed from usual semantics; returning .Dv NULL indicates success and allows access. .Pp When the servlet is destroyed, if .Fa destroy is not .Dv NULL , it will be invoked with .Fa arg as its parameter. .Sh RETURN VALUES On failure, .Fn http_servlet_basicauth_create returns .Dv NULL and sets .Va errno to an appropriate value. .Sh SEE ALSO .Xr http_request 3 , .Xr http_response 3 , .Xr http_server 3 , .Xr http_servlet 3 , .Xr http_servlet_cookieauth 3 , .Xr libpdel 3 .Rs .%A J. Franks .%A P. Hallam-Baker .%A J. Hostetler .%A S. Lawrence .%A P. Leach .%A A. Luotonen .%A L. Stewart .%T "HTTP Authentication: Basic and Digest Access Authentication" .%O RFC 2617 .Re .Sh HISTORY The PDEL library was developed at Packet Design, LLC. .Dv "http://www.packetdesign.com/" .Sh AUTHORS .An Archie Cobbs Aq archie@freebsd.org