Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
1f7dc300
Commit
1f7dc300
authored
Aug 26, 1997
by
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added su support
parent
c362b81a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
22 deletions
+57
-22
lib/python/AccessControl/User.py
lib/python/AccessControl/User.py
+51
-16
lib/python/AccessControl/UserFolder_manage_main.dtml
lib/python/AccessControl/UserFolder_manage_main.dtml
+2
-4
lib/python/AccessControl/__init__.py
lib/python/AccessControl/__init__.py
+4
-2
No files found.
lib/python/AccessControl/User.py
View file @
1f7dc300
"""Access control
objects
"""
"""Access control
package
"""
__version__
=
'$Revision: 1.
1
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
2
$'
[
11
:
-
2
]
from
Persistence
import
Persistent
,
PersistentMapping
import
Globals
from
Persistence
import
Persistent
from
Persistence
import
PersistentMapping
from
Acquisition
import
Implicit
from
DocumentTemplate
import
HTML
from
Globals
import
MessageDialog
from
Globals
import
Bobobase
from
base64
import
decodestring
from
string
import
join
,
strip
,
split
,
lower
...
...
@@ -31,19 +31,46 @@ class SafeDtml(HTML):
class
User
(
Implicit
,
Persistent
):
""" """
def
__init__
(
self
,
name
=
None
,
password
=
None
,
roles
=
[]):
if
name
is
not
None
:
self
.
_name
=
name
self
.
_password
=
password
self
.
_roles
=
roles
def
__len__
(
self
):
return
1
def
__str__
(
self
):
return
self
.
_name
def
__repr__
(
self
):
return
self
.
_name
class
SuperUser
:
def
__init__
(
self
):
try
:
f
=
open
(
'%s/access'
%
CUSTOMER_HOME
,
'r'
)
d
=
split
(
strip
(
f
.
readline
()),
':'
)
f
.
close
()
self
.
_name
=
d
[
0
]
self
.
_password
=
d
[
1
]
self
.
_roles
=
(
'manage'
,)
except
:
self
.
_name
=
'superuser'
self
.
_password
=
'123'
self
.
_roles
=
(
'manage'
,)
def
__len__
(
self
):
return
1
def
__str__
(
self
):
return
self
.
_name
def
__repr__
(
self
):
return
self
.
_name
su
=
SuperUser
()
class
UserFolder
(
Implicit
,
Persistent
):
...
...
@@ -69,10 +96,7 @@ class UserFolder(Implicit, Persistent):
)
def
_init
(
self
):
self
.
_data
=
PersistentMapping
({
'Brian'
:
User
(
'Brian'
,
'123'
,[
'manage'
,]),
'Jim Fulton'
:
User
(
'Jim Fulton'
,
'123'
,
[
'manage'
,]),
'Paul Everitt'
:
User
(
'Paul Everitt'
,
'123'
,[
'manage'
,])
})
self
.
_data
=
PersistentMapping
()
def
__len__
(
self
):
return
len
(
self
.
userNames
())
...
...
@@ -85,13 +109,14 @@ class UserFolder(Implicit, Persistent):
return
self
.
_data
.
keys
()
def
roleNames
(
self
):
return
Bobobase
[
'roles'
]
# return ['manage','foo','bar','spam']
return
Globals
.
Bobobase
[
'roles'
]
def
validate
(
self
,
request
,
auth
,
roles
=
None
):
if
lower
(
auth
[:
6
])
!=
'basic '
:
return
None
[
name
,
password
]
=
split
(
decodestring
(
split
(
auth
)[
-
1
]),
':'
)
if
(
name
==
su
.
_name
)
and
(
password
==
su
.
_password
):
return
su
try
:
user
=
self
.
_data
[
name
]
except
:
return
None
if
password
!=
user
.
_password
:
...
...
@@ -154,7 +179,21 @@ class UserFolder(Implicit, Persistent):
del
self
.
_data
[
n
]
return
self
.
manage_main
(
self
,
REQUEST
)
def
manage_addRole
(
self
,
REQUEST
,
role
):
""" """
roles
=
Globals
.
Bobobase
[
'roles'
]
if
role
not
in
roles
:
Globals
.
Bobobase
[
'roles'
]
=
tuple
(
roles
)
+
(
role
,)
return
self
.
manage_main
(
self
,
REQUEST
)
def
manage_deleteRole
(
self
,
REQUEST
,
role
):
""" """
roles
=
Globals
.
Bobobase
[
'roles'
]
if
role
in
roles
:
roles
=
list
(
roles
)
del
roles
[
roles
.
index
(
role
)]
Globals
.
Bobobase
[
'roles'
]
=
tuple
(
roles
)
return
self
.
manage_main
(
self
,
REQUEST
)
...
...
@@ -162,10 +201,6 @@ class UserFolder(Implicit, Persistent):
def
manage_addUserFolder
(
self
,
self2
,
REQUEST
):
""" """
# if self.__dict__.has_key('__allow_groups__'):
# return MessageDialog(title='Object exists',
# message='This object already has a User Folder',
# action='%s/manage' % REQUEST['PARENT_URL'])
i
=
UserFolder
()
i
.
_init
()
self
.
_setObject
(
'UserFolder'
,
i
)
...
...
lib/python/AccessControl/UserFolder_manage_main.dtml
View file @
1f7dc300
...
...
@@ -24,8 +24,8 @@
<!--#if userNames-->
<TR>
<TD VALIGN="TOP">
The following users have been defined. To edit a user,
select a user
from the list
and click the <I>Edit User</I> button.
The following users have been defined. To edit a user,
select a user
and click the <I>Edit User</I> button.
</TD>
<TD VALIGN="TOP">
<FORM ACTION="<!--#var PARENT_URL-->/manage_editForm" METHOD="POST">
...
...
@@ -48,7 +48,6 @@
<!--#/if userNames-->
<TR>
<TD COLSPAN="2" VALIGN="TOP">
<BR>
To add a new user, enter the name, password, confirmation and
roles for the new user and click the <I>Add User</I> button.
</TD>
...
...
@@ -90,7 +89,6 @@
<!--#if userNames-->
<TR>
<TD VALIGN="TOP">
<BR>
To delete one or more users, select the users
you wish to delete and click the <I>Delete Users</I> button.
</TD>
...
...
lib/python/AccessControl/__init__.py
View file @
1f7dc300
__doc__
=
"""$Id: __init__.py,v 1.
1 1997/08/26 18:54:42
brian Exp $"""
__version__
=
'$Revision: 1.
1
$'
[
11
:
-
2
]
__doc__
=
"""$Id: __init__.py,v 1.
2 1997/08/26 22:01:07
brian Exp $"""
__version__
=
'$Revision: 1.
2
$'
[
11
:
-
2
]
import
User
...
...
@@ -11,3 +11,5 @@ __.meta_types=({'name':'User Folder',
__
.
methods
=
{
'manage_addUserFolder'
:
User
.
manage_addUserFolder
,
}
__
.
role_names
=
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment