Re: made cgi authentification module for prewikka
Tilman Baumann <[email protected]>
| Newsgroups | gmane.comp.security.ids.prelude.devel |
|---|---|
| Organization | Collax |
| Message-ID | <[email protected]> |
As if attaching a file would be so hard... Sorry, here the diff. Am Mittwoch, 7. Juni 2006 20:15 schrieb Tilman Baumann: > Hello, > > i made a authentification module for prewikka which looks at the > REMOTE_USER environment the webserver sets for cgi scripts. > This is usefull if your webserver makes authentification for you. > With this script you don't need so maintain a user table in the prewikka > database. > > This is my first python hack. Maybe it's a bit cude. But it works for me. > :) Maybe anybody has suggestions for the code... -- Tilman Baumann Software Developer Collax GmbH . Boetzinger Strasse 60 . 79111 Freiburg . Germany p: +49 (0) 89-990157-0 f: +49 (0) 89-990157-11 _______________________________________________ Prelude-devel site list [email protected] http://www.prelude-ids.org/mailman/listinfo/prelude-devel
001-cgi-auth.diff
(text/x-diff, 3 KB)
diff -N -u -r prewikka-0.9.5_old/prewikka/modules/auth/cgi/__init__.py prewikka-0.9.5/prewikka/modules/auth/cgi/__init__.py --- prewikka-0.9.5_old/prewikka/modules/auth/cgi/__init__.py 1970-01-01 01:00:00.000000000 +0100 +++ prewikka-0.9.5/prewikka/modules/auth/cgi/__init__.py 2006-06-07 18:43:40.000000000 +0200 @@ -0,0 +1,2 @@ + + diff -N -u -r prewikka-0.9.5_old/prewikka/modules/auth/cgi/cgi.py prewikka-0.9.5/prewikka/modules/auth/cgi/cgi.py --- prewikka-0.9.5_old/prewikka/modules/auth/cgi/cgi.py 1970-01-01 01:00:00.000000000 +0100 +++ prewikka-0.9.5/prewikka/modules/auth/cgi/cgi.py 2006-06-07 18:43:40.000000000 +0200 @@ -0,0 +1,43 @@ +# Copyright (C) 2004,2005 PreludeIDS Technologies. All Rights Reserved. +# Author: Nicolas Delon <[email protected]> +# +# This file is part of the Prewikka program. +# +# This program 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 2, or (at your option) +# any later version. +# +# This program 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 this program; see the file COPYING. If not, write to +# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + +import os + +from prewikka import Auth, User, Database + +def load(env, config): + return CGIAuth(env, config) + +class CGIAuth(Auth.AnonymousAuth): + def __init__(self, env, config): + # Need to call Auth.Auth's init because the init of + # our superclass Auth.AnonymousAuth does not set env. + Auth.Auth.__init__(self, env) + self.config = config + + def getUser(self, request): + user = os.environ.get("REMOTE_USER","") + if not user: + raise Auth.AuthError() + permissions = [ User.PERM_IDMEF_VIEW, + User.PERM_IDMEF_ALTER, + User.PERM_COMMAND, + User.PERM_INTRUSIVE_COMMAND ] + return User.User(self.db, user, permissions, self.config) + diff -N -u -r prewikka-0.9.5_old/setup.py prewikka-0.9.5/setup.py --- prewikka-0.9.5_old/setup.py 2006-06-07 18:55:45.000000000 +0200 +++ prewikka-0.9.5/setup.py 2006-06-07 18:56:35.000000000 +0200 @@ -172,7 +172,7 @@ packages=[ 'prewikka', 'prewikka.views', 'prewikka.templates', 'prewikka.modules', 'prewikka.modules.log', 'prewikka.modules.log.stderr', - 'prewikka.modules.auth', 'prewikka.modules.auth.loginpassword' ], + 'prewikka.modules.auth', 'prewikka.modules.auth.loginpassword', 'prewikka.modules.auth.cgi' ], data_files=[ ("share/prewikka/cgi-bin", [ "cgi-bin/prewikka.cgi" ]), ("share/prewikka/htdocs/images", glob.glob("htdocs/images/*")), ("share/prewikka/htdocs/css", glob.glob("htdocs/css/*.css")),