The password is not a parameter of the apache configuration.
[toast/tdyndns.git] / bin / tdyndns_auth_simplepwd
1 #!/usr/bin/python
2 """
3 Acts as auth program for the "external" authentication module
4 http://code.google.com/p/mod-auth-external/
5
6 It makes sure that the given user name exists at the system
7 (with a UID > 1000) and that the password corresponds to
8 the password that is provided by the AuthExternalContext
9 directive in the apache configuration.
10 """
11 import os
12 import pwd
13 import sys
14
15 # Get provided username and password
16 username = os.environ.get('USER')
17 password = os.environ.get('PASS')
18 valid_password = os.environ.get('CONTEXT')
19
20
21 # We want to have a existing user ...
22 try:
23         user_info = pwd.getpwnam(username)
24 except KeyError:
25         # invalid user name
26         sys.exit(1)
27
28 if user_info.pw_uid < 1000:
29         # the system user has to have a UID above 1000
30         sys.exit(1)
31
32
33 # ... and the password has to be as given above
34 if password != valid_password:
35         sys.exit(1)
36
37
38 sys.exit(0)