diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2014-11-01 13:51:58 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2014-11-01 14:01:54 +0200 |
commit | 43ad26ba4149be4700ea60ad0750454bc9420c4b (patch) | |
tree | 6e5777f849f5fd557fa2e5885d38cfc927510eea | |
parent | 94e89bc0207394e49295bdeade92d8a6322a8aa7 (diff) | |
download | vmod-basicauth-43ad26ba4149be4700ea60ad0750454bc9420c4b.tar.gz vmod-basicauth-43ad26ba4149be4700ea60ad0750454bc9420c4b.tar.bz2 |
Support for VCL 4.0
* NEWS: Update.
* configure.ac: Version 1.2.90
Detect varnish version.
* src/.gitignore: Update.
* src/Makefile.am: Always build vcc_if.c and vcc_if.h, don't
include them in the distribution.
(.vcc.vcc3): New implicit rule for VCL 3.0
* src/vmod_basicauth.c: Include config.h.
Define varnish datatypes depending on the value of VARNISHVERSION.
(vmod_match): Change declaration.
* src/vmod_basicauth.vcc: Rewrite.
-rw-r--r-- | NEWS | 6 | ||||
-rw-r--r-- | configure.ac | 15 | ||||
-rw-r--r-- | src/.gitignore | 1 | ||||
-rw-r--r-- | src/Makefile.am | 31 | ||||
-rw-r--r-- | src/vmod_basicauth.c | 15 | ||||
-rw-r--r-- | src/vmod_basicauth.vcc | 57 |
6 files changed, 107 insertions, 18 deletions
@@ -1,9 +1,13 @@ -Vmod-basicauth NEWS -- history of user-visible changes. 2013-10-19 +Vmod-basicauth NEWS -- history of user-visible changes. 2014-11-01 Copyright (C) 2013 Sergey Poznyakoff See the end of file for copying conditions. Please send Vmod-basicauth bug reports to <gray@gnu.org> +Version 1.2.90 (git) + +Support for VCL 4.0 + Version 1.2, 2013-10-19 * Improve documentation. diff --git a/configure.ac b/configure.ac index 5df1fde..83d52ae 100644 --- a/configure.ac +++ b/configure.ac @@ -14,7 +14,7 @@ # You should have received a copy of the GNU General Public License # along with vmod-basicauth. If not, see <http://www.gnu.org/licenses/>. AC_PREREQ(2.69) -AC_INIT([vmod-basicauth], 1.2, [gray@gnu.org]) +AC_INIT([vmod-basicauth], 1.2.90, [gray@gnu.org]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_SRCDIR(src/vmod_basicauth.vcc) @@ -64,10 +64,17 @@ case "$VARNISHSRC" in esac VARNISHSRC=`cd $VARNISHSRC && pwd` +VARNISHVERSION= AC_CHECK_FILE([$VARNISHSRC/include/varnishapi.h], - [], - [AC_MSG_FAILURE(["$VARNISHSRC" is not a Varnish source directory])]) - + [VARNISHVERSION=3], + [AC_CHECK_FILE([$VARNISHSRC/include/vapi/vsm.h], + [VARNISHVERSION=4], + [AC_MSG_FAILURE(["$VARNISHSRC" is not a Varnish source directory])]) ]) + +AC_DEFINE_UNQUOTED([VARNISHVERSION],$VARNISHVERSION,[Varnish major version number]) +AM_CONDITIONAL([VARNISH3],[test $VARNISHVERSION -eq 3]) +AM_CONDITIONAL([VARNISH4],[test $VARNISHVERSION -eq 4]) + # Check that varnishtest is built in the varnish source directory AC_CHECK_FILE([$VARNISHSRC/bin/varnishtest/varnishtest], [], diff --git a/src/.gitignore b/src/.gitignore index 7f6e438..ce7aef0 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -1,2 +1,3 @@ vcc_if.c vcc_if.h +*.rst diff --git a/src/Makefile.am b/src/Makefile.am index 983bee9..6ddcf41 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,5 +1,5 @@ # This file is part of vmod-basicauth -# Copyright (C) 2013 Sergey Poznyakoff +# Copyright (C) 2013-2014 Sergey Poznyakoff # # Vmod-basicauth is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -29,17 +29,34 @@ libvmod_basicauth_la_SOURCES = \ md5.c\ sha1.c\ sha1.h\ - vcc_if.c \ - vcc_if.h \ vmod_basicauth.c -BUILT_SOURCES = vcc_if.c vcc_if.h +nodist_libvmod_basicauth_la_SOURCES = vcc_if.c vcc_if.h -vcc_if.c vcc_if.h: $(VARNISHSRC)/lib/libvmod_std/vmod.py $(top_srcdir)/src/vmod_basicauth.vcc - @PYTHON@ $(VARNISHSRC)/lib/libvmod_std/vmod.py $(top_srcdir)/src/vmod_basicauth.vcc +vmod_basicauth.lo: vcc_if.h + +CLEANFILES = vcc_if.c vcc_if.h *.rst + +if VARNISH4 + vmodtool = $(VARNISHSRC)/lib/libvcc/vmodtool.py + vmodtoolargs = --strict + vccfile = $(top_srcdir)/src/vmod_basicauth.vcc +else + vmodtool = $(VARNISHSRC)/lib/libvmod_std/vmod.py + vmodtoolargs = + vccfile = vmod_basicauth.vcc3 + +vmod_basicauth.vcc3: $(top_srcdir)/src/vmod_basicauth.vcc + CLEANFILES += vmod_basicauth.vcc3 +endif + +.vcc.vcc3: + sed -n '/^\$$/{s///;s/\(Module *[^ ][^ ]*\).*/\1/;p}' $< > $@ + +vcc_if.c vcc_if.h: $(vmodtool) $(vccfile) + @PYTHON@ $(vmodtool) $(vmodtoolargs) $(vccfile) EXTRA_DIST = \ vmod_basicauth.vcc -CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h diff --git a/src/vmod_basicauth.c b/src/vmod_basicauth.c index c63f7fa..3563c20 100644 --- a/src/vmod_basicauth.c +++ b/src/vmod_basicauth.c @@ -15,6 +15,7 @@ along with vmod-basicauth. If not, see <http://www.gnu.org/licenses/>. */ #define _GNU_SOURCE +#include <config.h> #include <stdio.h> #include <stdlib.h> #include <errno.h> @@ -26,6 +27,15 @@ #include "vrt.h" #include "vcc_if.h" +#include "pthread.h" +#if VARNISHVERSION == 3 +# define VCL_VOID void +# define VCL_BOOL unsigned +# define VCL_STRING const char * +# define MOD_CTX struct sess * +#else +# define MOD_CTX const struct vrt_ctx * +#endif #include "basicauth.h" #include "sha1.h" @@ -169,9 +179,8 @@ match(const char *pass, const char *hash, struct priv_data *pd) #define BASICPREF "Basic " #define BASICLEN (sizeof(BASICPREF)-1) -unsigned -vmod_match(struct sess *sp, struct vmod_priv *priv, - const char *file, const char *s) +VCL_BOOL +vmod_match(MOD_CTX sp, struct vmod_priv *priv, VCL_STRING file, VCL_STRING s) { char buf[1024]; char lbuf[1024]; diff --git a/src/vmod_basicauth.vcc b/src/vmod_basicauth.vcc index 35ac3c7..cda0d66 100644 --- a/src/vmod_basicauth.vcc +++ b/src/vmod_basicauth.vcc @@ -1,4 +1,55 @@ -Module basicauth -Init init_function -Function BOOL match(PRIV_VCL, STRING, STRING) +# This file is part of vmod-basicauth +# Copyright (C) 2013-2014 Sergey Poznyakoff +# +# Vmod-basicauth is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# Vmod-basicauth is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with vmod-basicauth. If not, see <http://www.gnu.org/licenses/>. +$Module basicauth 3 Basic HTTP authentication + +COLOPHON +======== +This document provides a short description of the **vmod-basicauth** module. +For a detailed documentation, please see the vmod-basicauth(3) manual page. + +DESCRIPTION +=========== +The **vmod-basicauth** module implements basic HTTP authentication against +the password file created using the **htpasswd** command. + +Four kinds of password hashes are supported: Apache MD5, crypt, SHA1, +and plaintext. + +$Init init_function +$Function BOOL match(PRIV_VCL, STRING, STRING) + +Description + The **match** function returns **TRUE** or **FALSE** depending on whether + the authentication succeeds or not. The *passfile* argument supplies the + name of the password file to use. The *authstr* argument is the + authentication string (normally, the value of the Authorization HTTP + header). + +Example + :: + + if (!basicauth.match("/var/www/.htpasswd", req.http.Authorization)) { + return(synth(401, "Restricted")); + } + +SEE ALSO +======== + +* vcl(7) +* varnishd(1) + +
\ No newline at end of file |