Skip to content

Commit 4bb7414

Browse files
committed
Add ability to be built as dynamic module
1 parent d373765 commit 4bb7414

File tree

4 files changed

+74
-16
lines changed

4 files changed

+74
-16
lines changed

.travis.yml

+12-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ compilers:
44
- gcc
55
env:
66
# Don't use `NGINX` as the variable name or Nginx won't daemonise
7-
- SHIB_NGINX_VERSION=1.9.13
8-
- SHIB_NGINX_VERSION=1.8.1
7+
- SHIB_NGINX_VERSION=1.9.13 SHIB_DYNAMIC_MODULE=true
8+
- SHIB_NGINX_VERSION=1.9.13 SHIB_DYNAMIC_MODULE=false
9+
- SHIB_NGINX_VERSION=1.8.1 SHIB_DYNAMIC_MODULE=true
10+
- SHIB_NGINX_VERSION=1.8.1 SHIB_DYNAMIC_MODULE=false
911
sudo: false
1012
addons:
1113
apt:
@@ -25,10 +27,16 @@ before_install:
2527
install:
2628
- wget -O - http://nginx.org/download/nginx-${SHIB_NGINX_VERSION}.tar.gz | tar -xzf -
2729
- cd nginx-${SHIB_NGINX_VERSION}
28-
- git clone https://github.com/openresty/headers-more-nginx-module.git -b v0.29
29-
- ./configure --with-debug --add-module=.. --add-module=./headers-more-nginx-module
30+
- git clone https://github.com/openresty/headers-more-nginx-module.git -b v0.30rc1
31+
- |
32+
if [ "$SHIB_DYNAMIC_MODULE" = true ]; then
33+
./configure --with-debug --add-dynamic-module=.. --add-dynamic-module=./headers-more-nginx-module
34+
else
35+
./configure --with-debug --add-module=.. --add-module=./headers-more-nginx-module
36+
fi
3037
- make
3138
- export PATH=$(pwd)/objs:$PATH
39+
- export SHIB_MODULE_PATH=$(pwd)/objs
3240
- cd ..
3341
script:
3442
- PERL5LIB=$HOME/perl5/lib/perl5 TEST_NGINX_VERBOSE=true prove -v

README.rst

+30-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Shibboleth auth request module for nginx
1+
Shibboleth auth request module for Nginx
22
========================================
33

44
.. image:: https://travis-ci.org/nginx-shib/nginx-http-shibboleth.svg?branch=master
@@ -27,6 +27,9 @@ same ``location`` block is untested and not advised.
2727
Read more about the `Behaviour`_ below and consult `Configuration`_ for
2828
important notes on avoiding spoofing if using headers for attributes.
2929

30+
For further information on why this is a dedicated module, see
31+
http://forum.nginx.org/read.php?2,238523,238523#msg-238523
32+
3033
Directives
3134
----------
3235

@@ -107,14 +110,32 @@ shib_request_use_headers on|off
107110
Installation
108111
------------
109112

110-
To compile nginx with this module, use the::
113+
This module can either be compiled statically or dynamically, since the
114+
introduction of `dynamic modules
115+
<https://www.nginx.com/resources/wiki/extending/converting/>`_ in Nginx
116+
1.9.11. The practical upshot of dynamic modules is that they can be loaded,
117+
as opposed to static modules which are permanently present and enabled.
111118

112-
--add-module <path>
113119

114-
option when you ``configure`` nginx.
120+
To compile Nginx with this module dynamically, pass the following option to
121+
``./configure`` when building Nginx::
115122

116-
For further information on why this is a dedicated module, see
117-
http://forum.nginx.org/read.php?2,238523,238523#msg-238523
123+
--add-dynamic-module=<path>
124+
125+
You will need to explicitly load the module in your ``nginx.conf`` by
126+
including::
127+
128+
load_module /path/to/modules/ngx_http_shibboleth_module.so;
129+
130+
and reloading Nginx.
131+
132+
To compile Nginx with this module statically, pass the following option to
133+
``./configure`` when building Nginx::
134+
135+
--add-module=<path>
136+
137+
No additional loading is required as the module is built-in with this
138+
configuration.
118139

119140

120141
Configuration
@@ -266,10 +287,10 @@ on aspects like the `blocks()` function.
266287
Integration tests are run automatically with Travis CI but
267288
also be run manually (requires Perl & CPAN to be installed)::
268289

269-
cd nginx-shibboleth-auth
290+
cd nginx-http-shibboleth
270291
cpanm --notest --local-lib=$HOME/perl5 Test::Nginx
271-
# nginx must be present in path and built with debugging symbols
272-
prove
292+
# nginx must be present in PATH and built with debugging symbols
293+
PERL5LIB=$HOME/perl5/lib/perl5 prove
273294

274295
Versioning
275296
----------

config

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
11
ngx_addon_name=ngx_http_shibboleth_module
2-
HTTP_MODULES="$HTTP_MODULES ngx_http_shibboleth_module"
3-
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_shibboleth_module.c"
2+
3+
if test -n "$ngx_module_link"; then
4+
ngx_module_type=HTTP
5+
ngx_module_name=ngx_http_shibboleth_module
6+
ngx_module_srcs="$ngx_addon_dir/ngx_http_shibboleth_module.c"
7+
8+
. auto/module
9+
else
10+
HTTP_MODULES="$HTTP_MODULES ngx_http_shibboleth_module"
11+
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_shibboleth_module.c"
12+
fi

t/shibboleth.t

+21-1
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,18 @@ use Test::Nginx::Socket;
77
repeat_each(1);
88

99
# Each `TEST` in __DATA__ below generates a block for each pattern match
10-
# count
10+
# count. Increase the magic number accordingly if adding new tests or
11+
# expanding checks in existing tests (this will add more blocks).
1112
plan tests => repeat_each() * (50);
1213

14+
# Populate config for the dynamic module, if requested
15+
our $main_config = '';
16+
my $SHIB_DYNAMIC_MODULE = $ENV{'SHIB_DYNAMIC_MODULE'};
17+
if ($SHIB_DYNAMIC_MODULE && $SHIB_DYNAMIC_MODULE eq 'true') {
18+
my $SHIB_MODULE_PATH = $ENV{'SHIB_MODULE_PATH'} ? $ENV{'SHIB_MODULE_PATH'} : 'modules';
19+
$main_config = "load_module $SHIB_MODULE_PATH/ngx_http_headers_more_filter_module.so;
20+
load_module $SHIB_MODULE_PATH/ngx_http_shibboleth_module.so;";
21+
}
1322

1423
our $config = <<'_EOC_';
1524
# 401 must be returned with WWW-Authenticate header
@@ -148,6 +157,7 @@ __DATA__
148157
149158
=== TEST 1: Testing 401 response
150159
--- config eval: $::config
160+
--- main_config eval: $::main_config
151161
--- request
152162
GET /test1
153163
--- error_code: 401
@@ -159,6 +169,7 @@ qr/\[(warn|error|crit|alert|emerg)\]/
159169
160170
=== TEST 2: Testing 401 response with main request header
161171
--- config eval: $::config
172+
--- main_config eval: $::main_config
162173
--- request
163174
GET /test2
164175
--- error_code: 401
@@ -171,6 +182,7 @@ qr/\[(warn|error|crit|alert|emerg)\]/
171182
172183
=== TEST 3: Testing 403 response with main request header
173184
--- config eval: $::config
185+
--- main_config eval: $::main_config
174186
--- request
175187
GET /test3
176188
--- error_code: 403
@@ -182,6 +194,7 @@ qr/\[(warn|error|crit|alert|emerg)\]/
182194
183195
=== TEST 4: Testing 403 response with main request header
184196
--- config eval: $::config
197+
--- main_config eval: $::main_config
185198
--- request
186199
GET /test4
187200
--- error_code: 403
@@ -193,6 +206,7 @@ qr/\[(warn|error|crit|alert|emerg)\]/
193206
194207
=== TEST 5: Testing redirection with in-built header addition
195208
--- config eval: $::config
209+
--- main_config eval: $::main_config
196210
--- request
197211
GET /test5
198212
--- error_code: 301
@@ -205,6 +219,7 @@ qr/\[(warn|error|crit|alert|emerg)\]/
205219
206220
=== TEST 6: Testing redirection with subrequest header manipulation in main request
207221
--- config eval: $::config
222+
--- main_config eval: $::main_config
208223
--- request
209224
GET /test6
210225
--- error_code: 301
@@ -218,6 +233,7 @@ qr/\[(warn|error|crit|alert|emerg)\]/
218233
219234
=== TEST 7: Testing successful auth, no leaked variables
220235
--- config eval: $::config
236+
--- main_config eval: $::main_config
221237
--- user_files
222238
>>> test7
223239
Hello, world
@@ -237,6 +253,7 @@ qr/copied header/
237253
238254
=== TEST 8: Testing successful auth, no leaked variables, main request headers set
239255
--- config eval: $::config
256+
--- main_config eval: $::main_config
240257
--- user_files
241258
>>> test8
242259
Hello, world
@@ -257,6 +274,7 @@ qr/shib request authorizer copied header:/
257274
258275
=== TEST 9: Testing no auth with correct headers; subrequest header changes are ignored
259276
--- config eval: $::config
277+
--- main_config eval: $::main_config
260278
--- request
261279
GET /test9
262280
--- error_code: 403
@@ -270,6 +288,7 @@ qr/\[(warn|error|crit|alert|emerg)\]/
270288
271289
=== TEST 10: Testing no auth with overwritten headers; subrequest header changes are ignored
272290
--- config eval: $::config
291+
--- main_config eval: $::main_config
273292
--- request
274293
GET /test10
275294
--- error_code: 403
@@ -283,6 +302,7 @@ qr/\[(warn|error|crit|alert|emerg)\]/
283302
284303
=== TEST 11: Testing successful auth, no leaked variables, no headers set
285304
--- config eval: $::config
305+
--- main_config eval: $::main_config
286306
--- user_files
287307
>>> test11
288308
Hello, world

0 commit comments

Comments
 (0)