Commit 5e61e187 authored by Jim Fulton's avatar Jim Fulton

added REMOTE_USER support

parent a9f73592
"""Access control package"""
__version__='$Revision: 1.42 $'[11:-2]
__version__='$Revision: 1.43 $'[11:-2]
from PersistentMapping import PersistentMapping
......@@ -52,10 +52,12 @@ class User(Implicit, Persistent):
def __str__(self): return self.name
__repr__=__str__
_remote_user_mode=0
try:
f=open('%s/access' % SOFTWARE_HOME, 'r')
data=split(strip(f.readline()),':')
f.close()
_remote_user_mode=not data[1]
super=User(data[0],data[1],('manage',))
del data
except:
......@@ -147,8 +149,10 @@ class UserFolder(Implicit, Persistent, Navigation, Tabs, RoleManager,
return None
_mainUser=HTMLFile('mainUser', globals())
_add_User=HTMLFile('addUser', globals())
_editUser=HTMLFile('editUser', globals())
_add_User=HTMLFile('addUser', globals(),
remote_user_mode__=_remote_user_mode)
_editUser=HTMLFile('editUser', globals(),
remote_user_mode__=_remote_user_mode)
manage=manage_main=_mainUser
......@@ -272,6 +276,32 @@ class UserFolder(Implicit, Persistent, Navigation, Tabs, RoleManager,
raise ('Copy Error',
'<EM>Cannot change the id of a UserFolder</EM>')
if _remote_user_mode:
class UserFolder(UserFolder):
def validate(self,request,auth='',roles=None):
parent=request['PARENTS'][0]
e=request.environ
if e.has_key('REMOTE_USER'): name=e['REMOTE_USER']
else:
if nobody.hasRole(parent, roles):
return nobody
return None
# Check for superuser
if self._isTop() and (name==super.name):
return super
# Try to get user
try: user=self.data[name]
except: return None
# Try to authorize user
if user.hasRole(parent, roles):
return user
def manage_addUserFolder(self,dtself=None,REQUEST=None,**ignored):
""" """
......
......@@ -5,8 +5,11 @@
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555">
<!--#var manage_tabs-->
<P>
To add a new user, enter the name, password, confirmation and
roles for the new user and click &quot;Add&quot;.
To add a new user, enter the name,
<!--#unless remote_user_mode__-->
password, confirmation
<!--#/unless-->
and roles for the new user and click &quot;Add&quot;.
<FORM ACTION="manage_users" METHOD="POST">
<TABLE>
......@@ -18,6 +21,10 @@ roles for the new user and click &quot;Add&quot;.
<INPUT TYPE="TEXT" NAME="name" SIZE="20">
</TD>
</TR>
<!--#if remote_user_mode__-->
<INPUT TYPE="HIDDEN" NAME="password" value="password">
<INPUT TYPE="HIDDEN" NAME="confirm" value="password">
<!--#else-->
<TR>
<TD VALIGN="TOP">
<STRONG>Password</STRONG>
......@@ -34,6 +41,7 @@ roles for the new user and click &quot;Add&quot;.
<INPUT TYPE="PASSWORD" NAME="confirm" SIZE="20">
</TD>
</TR>
<!--#/if-->
<TR>
<TD VALIGN="TOP">
<STRONG>Roles</STRONG>
......
......@@ -15,6 +15,10 @@
<!--#var expr="user.name"-->
</TD>
</TR>
<!--#if remote_user_mode__-->
<INPUT TYPE="HIDDEN" NAME="password" value="<!--#var password-->">
<INPUT TYPE="HIDDEN" NAME="confirm" value="<!--#var password-->">
<!--#else-->
<TR>
<TD VALIGN="TOP">
<STRONG>Password</STRONG>
......@@ -31,6 +35,7 @@
<INPUT TYPE="PASSWORD" NAME="confirm" VALUE="<!--#var password-->" SIZE="20">
</TD>
</TR>
<!--#/if-->
<TR>
<TD VALIGN="TOP">
<STRONG>Roles</STRONG>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment