Added a script as example for custom authorization.
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Tue, 15 Apr 2014 19:18:25 +0000 (21:18 +0200)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Tue, 15 Apr 2014 19:18:25 +0000 (21:18 +0200)
bin/tdyndns_auth_simplepwd [new file with mode: 0755]

diff --git a/bin/tdyndns_auth_simplepwd b/bin/tdyndns_auth_simplepwd
new file mode 100755 (executable)
index 0000000..0f88cc5
--- /dev/null
@@ -0,0 +1,43 @@
+#!/usr/bin/python
+"""
+Acts as auth program for the "external" authentication module
+http://code.google.com/p/mod-auth-external/
+
+It makes sure that the given user name exists at the system
+(with a UID > 1000) and that the password corresponds to
+a specific one given in this file.
+"""
+
+# Configuration
+PASSWORD = 'hygCithOrs5'
+
+
+# ------------------------------------------------------------
+
+import os
+import pwd
+import sys
+
+# Get provided username and password
+username = os.environ.get('USER')
+password = os.environ.get('PASS')
+
+
+# We want to have a existing user ...
+try:
+       user_info = pwd.getpwnam(username)
+except KeyError:
+       # invalid user name
+       sys.exit(1)
+
+if user_info.pw_uid < 1000:
+       # the system user has to have a UID above 1000
+       sys.exit(1)
+
+
+# ... and the password has to be as given above
+if password != PASSWORD:
+       sys.exit(1)
+
+
+sys.exit(0)