Skip to content

Commit a4dc891

Browse files
author
Richard Jones
committed
added hook for external password validation, and some more docco
1 parent d707f9b commit a4dc891

File tree

5 files changed

+75
-19
lines changed

5 files changed

+75
-19
lines changed

CHANGES.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ are given with the most recent entry first.
4444
- added "crypt" password encoding and ability to set password with
4545
already encrypted password through roundup-admin
4646
- fixed the mailgw so that anonymous users may still access it
47-
47+
- add hook to allow external password verification, overridable in the
48+
tracker interfaces module
4849

4950
2002-09-13 0.5.0 beta2
5051
- all backends now have a .close() method, and it's used everywhere

doc/customizing.txt

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Customising Roundup
33
===================
44

5-
:Version: $Revision: 1.48 $
5+
:Version: $Revision: 1.49 $
66

77
.. This document borrows from the ZopeBook section on ZPT. The original is at:
88
http://www.zope.org/Documentation/Books/ZopeBook/current/ZPT.stx
@@ -185,11 +185,6 @@ Note: if you modify the schema, you'll most likely need to edit the
185185
your changes.
186186

187187
A tracker schema defines what data is stored in the tracker's database.
188-
The schemas shipped with Roundup turn it into a typical software bug tracker
189-
or help desk.
190-
191-
XXX make sure we ship the help desk
192-
193188
Schemas are defined using Python code in the ``dbinit.py`` module of your
194189
tracker. The "classic" schema looks like this::
195190

@@ -434,7 +429,9 @@ case though, so be careful to use the right one.
434429
Use the roundup-admin interface's create, set and retire methods to add,
435430
alter or remove items from the classes in question.
436431

437-
XXX example
432+
433+
See "`adding a new field to the classic schema`_" for an example that requires
434+
database content changes.
438435

439436

440437
Web Interface
@@ -1532,7 +1529,11 @@ Adding a field to the database
15321529

15331530
This is the easiest part of the change. The category would just be a plain
15341531
string, nothing fancy. To change what is in the database you need to add
1535-
some lines to the ``open()`` function in ``dbinit.py``::
1532+
some lines to the ``open()`` function in ``dbinit.py`` under the comment::
1533+
1534+
# add any additional database schema configuration here
1535+
1536+
add::
15361537

15371538
category = Class(db, "category", name=String())
15381539
category.setkey("name")
@@ -1558,6 +1559,38 @@ adding something with a more one to one relationship use Link() instead.
15581559
That is all you need to do to change the schema. The rest of the effort is
15591560
fiddling around so you can actually use the new category.
15601561

1562+
Populating the new category class
1563+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1564+
1565+
If you haven't initialised the database with the roundup-admin "initialise"
1566+
command, then you can add the following to the tracker ``dbinit.py`` in the
1567+
``init()`` function under the comment::
1568+
1569+
# add any additional database create steps here - but only if you
1570+
# haven't initialised the database with the admin "initialise" command
1571+
1572+
add::
1573+
1574+
category = db.getclass('category')
1575+
category.create(name="scipy", order="1")
1576+
category.create(name="chaco", order="2")
1577+
category.create(name="weave", order="3")
1578+
1579+
If the database is initalised, the you need to use the roundup-admin tool::
1580+
1581+
% roundup-admin -i <tracker home>
1582+
Roundup <version> ready for input.
1583+
Type "help" for help.
1584+
roundup> create category name=scipy order=1
1585+
1
1586+
roundup> create category name=chaco order=1
1587+
2
1588+
roundup> create category name=weave order=1
1589+
3
1590+
roundup> exit...
1591+
There are unsaved changes. Commit them (y/N)? y
1592+
1593+
15611594
Setting up security on the new objects
15621595
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15631596

roundup/cgi/client.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: client.py,v 1.46 2002-09-26 03:45:09 richard Exp $
1+
# $Id: client.py,v 1.47 2002-09-26 23:59:08 richard Exp $
22

33
__doc__ = """
44
WWW request handler (also used in the stand-alone server).
@@ -424,7 +424,10 @@ def header(self, headers=None, response=None):
424424
if self.debug:
425425
self.headers_sent = headers
426426

427-
def set_cookie(self, user, password):
427+
def set_cookie(self, user):
428+
''' Set up a session cookie for the user and store away the user's
429+
login info against the session.
430+
'''
428431
# TODO generate a much, much stronger session key ;)
429432
self.session = binascii.b2a_base64(repr(random.random())).strip()
430433

@@ -498,9 +501,7 @@ def loginAction(self):
498501
self.error_message.append(_('No such user "%(name)s"')%locals())
499502
return
500503

501-
# and that the password is correct
502-
pw = self.db.user.get(self.userid, 'password')
503-
if password != pw:
504+
if not self.verifyPassword(self.userid, password):
504505
self.make_user_anonymous()
505506
self.error_message.append(_('Incorrect password'))
506507
return
@@ -511,7 +512,12 @@ def loginAction(self):
511512
raise Unauthorised, _("You do not have permission to login")
512513

513514
# set the session cookie
514-
self.set_cookie(self.user, password)
515+
self.set_cookie(self.user)
516+
517+
def verifyPassword(self, userid, password):
518+
''' Verify the password that the user has supplied
519+
'''
520+
return password == self.db.user.get(self.userid, 'password')
515521

516522
def loginPermission(self):
517523
''' Determine whether the user has permission to log in.
@@ -577,8 +583,14 @@ def registerAction(self):
577583
self.user = cl.get(self.userid, 'username')
578584
# re-open the database for real, using the user
579585
self.opendb(self.user)
580-
password = self.db.user.get(self.userid, 'password')
581-
self.set_cookie(self.user, password)
586+
587+
# update the user's session
588+
if self.session:
589+
self.db.sessions.set(self.session, user=self.user,
590+
last_use=time.time())
591+
else:
592+
# new session cookie
593+
self.set_cookie(self.user)
582594

583595
# nice message
584596
message = _('You are now registered, welcome!')

roundup/templates/classic/dbinit.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: dbinit.py,v 1.29 2002-09-13 03:31:18 richard Exp $
18+
# $Id: dbinit.py,v 1.30 2002-09-26 23:59:08 richard Exp $
1919

2020
import os
2121

@@ -55,6 +55,8 @@ def open(name=None):
5555
klass=String(), name=String(),
5656
url=String())
5757
query.setkey("name")
58+
59+
# add any additional database schema configuration here
5860

5961
# Note: roles is a comma-separated string of Role names
6062
user = Class(db, "user",
@@ -187,6 +189,9 @@ def init(adminpw):
187189
address=config.ADMIN_EMAIL, roles='Admin')
188190
user.create(username="anonymous", roles='Anonymous')
189191

192+
# add any additional database create steps here - but only if you
193+
# haven't initialised the database with the admin "initialise" command
194+
190195
db.commit()
191196

192197
# vim: set filetype=python ts=4 sw=4 et si

roundup/templates/minimal/dbinit.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: dbinit.py,v 1.1 2002-09-26 04:15:07 richard Exp $
18+
# $Id: dbinit.py,v 1.2 2002-09-26 23:59:08 richard Exp $
1919

2020
import os
2121

@@ -43,6 +43,8 @@ def open(name=None):
4343
address=String(), alternate_addresses=String(), roles=String())
4444
user.setkey("username")
4545

46+
# add any additional database schema configuration here
47+
4648
#
4749
# SECURITY SETTINGS
4850
#
@@ -100,6 +102,9 @@ def init(adminpw):
100102
address=config.ADMIN_EMAIL, roles='Admin')
101103
user.create(username="anonymous", roles='Anonymous')
102104

105+
# add any additional database create steps here - but only if you
106+
# haven't initialised the database with the admin "initialise" command
107+
103108
db.commit()
104109

105110
# vim: set filetype=python ts=4 sw=4 et si

0 commit comments

Comments
 (0)