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

added REMOTE_USER support

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