Skip to content

Commit 79a111c

Browse files
dsommerscron2
authored andcommitted
sample-plugin: New plugin for testing multiple auth plugins
This plugin allows setting username/passwords as well as configure deferred authentication behaviour as part of the runtime initialization. With this plug-in it is easier to test various scenarios where multiple authentication plug-ins are active on the server side. A test documentation was also added to describe various test cases and the expected results. Signed-off-by: David Sommerseth <davids@openvpn.net> Acked-by: Antonio Quartulli <antonio@openvpn.net> Message-Id: <20220313193154.9350-2-openvpn@sf.lists.topphemmelig.net> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23932.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
1 parent fd567aa commit 79a111c

File tree

3 files changed

+565
-0
lines changed

3 files changed

+565
-0
lines changed

doc/tests/authentication-plugins.md

+151
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
# TESTING OF MULTIPLE AUTHENTICATION PLUG-INS
2+
3+
4+
OpenVPN 2.x can support loading and authenticating users through multiple
5+
plug-ins at the same time. But it can only support a single plug-in doing
6+
deferred authentication. However, a plug-in supporting deferred
7+
authentication may be accompanied by other authentication plug-ins **not**
8+
doing deferred authentication.
9+
10+
This is a test script useful to test the various combinations and order of
11+
plug-in execution.
12+
13+
The configuration files are expected to be used from the root of the build
14+
directory.
15+
16+
To build the needed authentication plug-in, run:
17+
18+
make -C sample/sample-plugins
19+
20+
21+
## Test configs
22+
23+
* Client config
24+
25+
verb 4
26+
dev tun
27+
client
28+
remote x.x.x.x
29+
ca sample/sample-keys/ca.crt
30+
cert sample/sample-keys/client.crt
31+
key sample/sample-keys/client.key
32+
auth-user-pass
33+
34+
* Base server config (`base-server.conf`)
35+
36+
verb 4
37+
dev tun
38+
server 10.8.0.0 255.255.255.0
39+
dh sample/sample-keys/dh2048.pem
40+
ca sample/sample-keys/ca.crt
41+
cert sample/sample-keys/server.crt
42+
key sample/sample-keys/server.key
43+
44+
45+
## Test cases
46+
47+
### Test: *sanity-1*
48+
49+
This tests the basic authentication with an instant answer.
50+
51+
config base-server.conf
52+
plugin multi-auth.so S1.1 0 foo bar
53+
54+
#### Expected results
55+
- Username/password `foo`/`bar`: **PASS**
56+
- Anything else: **FAIL**
57+
58+
59+
### Test: *sanity-2*
60+
61+
This is similar to `sanity-1`, but does the authentication
62+
through two plug-ins providing an instant reply.
63+
64+
config base-server.conf
65+
plugin multi-auth.so S2.1 0 foo bar
66+
plugin multi-auth.so S2.2 0 foo bar
67+
68+
#### Expected results
69+
- Username/password `foo`/`bar`: **PASS**
70+
- Anything else: **FAIL**
71+
72+
73+
### Test: *sanity-3*
74+
75+
This is also similar to `sanity-1`, but uses deferred authentication
76+
with a 1 second delay on the response.
77+
78+
plugin multi-auth.so S3.1 1000 foo bar
79+
80+
#### Expected results
81+
- Username/password `foo`/`bar`: **PASS**
82+
- Anything else: **FAIL**
83+
84+
85+
### Test: *case-a*
86+
87+
Runs two authentications, the first one deferred by 1 second and the
88+
second one providing an instant response.
89+
90+
plugin multi-auth.so A.1 1000 foo bar
91+
plugin multi-auth.so A.2 0 foo bar
92+
93+
#### Expected results
94+
- Username/password `foo`/`bar`: **PASS**
95+
- Anything else: **FAIL**
96+
97+
98+
### Test: *case-b*
99+
100+
This is similar to `case-a`, but the instant authentication response
101+
is provided first before the deferred authentication.
102+
103+
plugin multi-auth.so B.1 0 foo bar
104+
plugin multi-auth.so B.2 1000 test pass
105+
106+
#### Expected results
107+
- **Always FAIL**
108+
- This test should never pass, as each plug-in expects different
109+
usernames and passwords.
110+
111+
112+
### Test: *case-c*
113+
114+
This is similar to the two prior tests, but the authentication result
115+
is returned instantly in both steps.
116+
117+
plugin multi-auth.so C.1 0 foo bar
118+
plugin multi-auth.so C.2 0 foo2 bar2
119+
120+
#### Expected results
121+
- **Always FAIL**
122+
- This test should never pass, as each plug-in expects different
123+
usernames and passwords.
124+
125+
126+
### Test: *case-d*
127+
128+
This is similar to the `case-b` test, but the order of deferred
129+
and instant response is reversed.
130+
131+
plugin ./multi-auth.so D.1 2000 test pass
132+
plugin ./multi-auth.so D.2 0 foo bar
133+
134+
#### Expected results
135+
- **Always FAIL**
136+
- This test should never pass, as each plug-in expects different
137+
usernames and passwords.
138+
139+
140+
### Test: *case-e*
141+
142+
This test case will run two deferred authentication plug-ins. This is
143+
**not** supported by OpenVPN, and should therefore fail instantly.
144+
145+
plugin ./multi-auth.so E1 1000 test1 pass1
146+
plugin ./multi-auth.so E2 2000 test2 pass2
147+
148+
#### Expected results
149+
- The OpenVPN server process should stop running
150+
- An error about multiple deferred plug-ins being configured
151+
should be seen in the server log.

sample/sample-plugins/Makefile.plugins

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#
99
PLUGINS = \
1010
defer/simple \
11+
defer/multi-auth \
1112
keying-material-exporter-demo/keyingmaterialexporter \
1213
log/log log/log_v3 \
1314
simple/base64 \

0 commit comments

Comments
 (0)