1.2.2.4 Function Reference

The web.auth.setup() function has the following parameters and returns an AuthAdmin object:

start( storage[,cursor=None][,dir=None][,table='Auth'])

Warning: Because more options may be specified in future versions of this function you should not rely on the order of these parameters. Instead they should be specified with the parameter name and an = sign as is used in the examples in this documentation.

storage
The storage driver to use for the auth user, level and app information. storage can be 'database' or 'file'.

If storage is 'database' you must also specify cursor to be a valid web.database cursor. By default the necessary database tables beign with 'Auth'. If you want them to begin with something else, perhaps if you want two lots of auth storage in the same database, you can specify the table prepend string using table. For example table='Auth2' would create the tables Auth2Level, Auth2User and Auth2App.

If storage is 'file' you must also specify a directory dir which allows read and write access where the auth information is stored.

The AuthAdminFile object returned by the setup() function when storage='file' has the following methods and attributes:

class AuthAdminFile( )

applicationExists( app)
Return True if there is an application named app, False otherwise.

addApplication( app)
Adds an application named app.

removeApplication( app)
Removes the application named app.

apps( )
Return a list of application names.

userExists( username)
Return True if there is a user with the username username, False otherwise.

addUser( username, password[,firstname=''][,surname=''][email=''])
Adds a user with the username username and password password to the system. You can optionally also specify the firstname, surname and email address of the user.

removeUser( username)
Removes the user with the username username.

getFirstname( username)
Returns the firstname of the user username.

setFirstname( username, value)
Sets the firstname of the user username to value.

getSurname( username)
Returns the surname of the user username.

setSurname( username, value)
Sets the surname of the user username to value.

getPassword( username)
Returns the password of the user username.

setPassword( username, value)
Sets the password of the user username to value.

getEmail( username)
Returns the email address of the user username.

setEmail( username, value)
Sets the email address of the user username to value.

users( )
Return a list of usernames.

getAccessLevel( username, app)
Returns the access level of the user username for the application named app.

setAccessLevel( username, app, level)
Sets the access level of the user username for the application named app to level.

getAccessLevels( username)
Returns a dictionary of application name, access level pairs for the user with the username username.

The AuthManagerDatabase object returned by the setup() function when storage='database' has the all the methods and attributes of the AuthAdminFile object as well as the following methods:

class AuthAdminFile( )
createTables( )
Try to create the tables necessary for the auth module using the value specified earlier by table as the prepend for the table names. Returns a list of any errors encountered.

dropTables( )
Try to drop the auth tables, returning a list of any errors encountered.

tablesExist( )
If all the tables exist returns True. If any are missing returns False.

See About this document... for information on suggesting changes.