| # |
| # This is a sample properties file for the org.eclipse.jetty.security.JDBCLoginService |
| # implemtation of the UserRealm interface. This allows Jetty users authentication |
| # to work from a database. |
| # |
| # +-------+ +------------+ +-------+ |
| # | users | | user_roles | | roles | |
| # +-------+ +------------+ +-------+ |
| # | id | /| user_id |\ | id | |
| # | user -------| role_id |------- role | |
| # | pwd | \| |/ | | |
| # +-------+ +------------+ +-------+ |
| # |
| # |
| # 'cachetime' is a time in seconds to cache positive database |
| # lookups in internal hash table. Set to 0 to disable caching. |
| # |
| # |
| # For MySQL: |
| # create a MYSQL user called "jetty" with password "jetty" |
| # |
| # Create the tables: |
| # create table users |
| # ( |
| # id integer primary key, |
| # username varchar(100) not null unique key, |
| # pwd varchar(20) not null |
| # ); |
| # |
| # create table roles |
| # ( |
| # id integer primary key, |
| # role varchar(100) not null unique key |
| # ); |
| # |
| # create table user_roles |
| # ( |
| # user_id integer not null, |
| # role_id integer not null, |
| # unique key (user_id, role_id), |
| # index(user_id) |
| # ); |
| # |
| # I'm not sure unique key with a first component of user_id will be |
| # user by MySQL in query, so additional index wouldn't hurt. |
| # |
| # To test JDBC implementation: |
| # |
| # mysql> insert into users values (1, 'admin', 'password'); |
| # mysql> insert into roles values (1, 'server-administrator'); |
| # mysql> insert into roles values (2, 'content-administrator'); |
| # mysql> insert into user_roles values (1, 1); |
| # mysql> insert into user_roles values (1, 2); |
| # |
| # Replace HashUserRealm in etc/admin.xml with JDBCUserRealm and |
| # set path to properties file. |
| # |
| jdbcdriver = org.gjt.mm.mysql.Driver |
| url = jdbc:mysql://localhost/jetty |
| username = jetty |
| password = jetty |
| usertable = users |
| usertablekey = id |
| usertableuserfield = username |
| usertablepasswordfield = pwd |
| roletable = roles |
| roletablekey = id |
| roletablerolefield = role |
| userroletable = user_roles |
| userroletableuserkey = user_id |
| userroletablerolekey = role_id |
| cachetime = 300 |