= DB Authentication Plugin = == DEPRECATED == If you want a DB-based authentication system, use [wiki:AccountManagerPlugin AccountManager] and the !SessionStore backend. If you need a more custom database layout, you should just make a custom password store for !AccountManager. == Description == A plugin to replace the default Trac auth plugin. It allows for users/groups to be stored in a database ('''SQLite''', '''PostgreSQL''', '''MySQL'''), true login/logout, can serve multiple projects, and maintains cookies so you can keep the login for longer than just one session. == Bugs/Feature Requests == Existing bugs and feature requests for DbAuthPlugin are [report:9?COMPONENT=DbAuthPlugin here]. If you have any issues, create a [http://trac-hacks.org/newticket?component=DbAuthPlugin&owner=brad new ticket]. == Download == Download the zipped source for Trac [download:dbauthplugin/0.9 0.9] or [download:dbauthplugin/0.10 0.10]. == Source == You can check out DbAuthPlugin from [http://trac-hacks.org/svn/dbauthplugin here] using Subversion, or [source:dbauthplugin browse the source] with Trac. == Usage / Install == These usage/install notes are for the version that works with Trac 0.10. If you are still working with DbAuthPlugin for Trac 0.9, see [http://www.trac-hacks.org/wiki/DbAuthPlugin?version=4 this version] of the wiki page. * In the [source:dbauthplugin/0.10/install/ install/] directory, you will find SQLite and MySQL scripts to create the three tables needed. You will then have to populate those tables with insert statements. The ''envname'' fields in each of the tables is the name of your Trac environment. Note the 'all' ''envname'' will allow the user to be in all environments, but have only one row in the table (multiple projects). {{{ sqlite> insert into trac_permissions values ('all', 'brad', 'admins'); sqlite> insert into trac_users values ('all','brad','brad','brad@dsource.org'); }}} * Example of loading table: {{{ sqlite3 /path/to/project/db/trac.db < create-tables-sqlite-3.0.sql }}} * If you add users/groups to the table(s), you'll need to give them permissions in trac-admin or webadmin plugin. {{{ % trac-admin /path/to/env permission add admins TRAC_ADMIN }}} * If you would like to '''restrict_owner''' on tickets to only be the users in your tables, you need to make use of the [source:userdir.py userdir.py] file. You will need to see [http://projects.edgewall.com/trac/ticket/2456 Ticket 2456 at p.e.c], and patch Trac accordingly. This wasn't heavily tested with the 0.10 version in [838]. * Make these changes in the global trac.ini file, or your environment's trac.ini file. The global one may make more sense, because this plugin is used across environments: {{{ [components] trac.web.auth.* = disabled #trac.userdir.* = enabled # only if you want to use this #webadmin.* = enabled dbauth.* = enabled [dbauth] #database = sqlite:/home/brad/dev/python/trac-dbauth/0.10/install/dbauth.db database = mysql://brad:brad@localhost/dbauth envroot = /var/trac/ #algorithm = # hash algorithm for passwords; values can be sha or md5; default is sha users_table = trac_users users_envname_field = envname users_username_field = username users_password_field = password users_email_field = email perms_table = trac_permissions perms_envname_field = envname perms_username_field = username perms_groupname_field = groupname cookies_table = trac_cookies cookies_envname_field = envname cookies_cookie_field = cookie cookies_username_field = username cookies_ipnr_field = ipnr cookies_unixtime_field = unixtime }}} * As of [838], a !CentralDatabaseManager now supports all database backends that Trac works with. SQLite, MySQL, Postgresql * Note that passwords in ''password'' field must be hashes, or authentication will fail * Notes from anonymous via #1878: * Eggs are built with {{{ # python setup.py bdist_egg }}} * There is a need for the egg to cache. I had to add to my apache2 conf the following line: {{{ SetEnv PYTHON_EGG_CACHE {trac.environ}/egg_cache }}} == Example == http://trac-hacks.org/attachment/wiki/DbAuthPlugin/dbauth1.png?format=raw Users can now login by visiting == Recent Changes == [[ChangeLog(dbauthplugin, 3)]] == Author/Contributors == '''Author:''' [wiki:brad] [[BR]] '''Contributors:''' Karol Krizka, borrowed heavily from Jonas's original work [[TagIt(plugin,brad,beta,0.9,0.10)]]