Home | History | Annotate | Download | only in etc
      1 # 
      2 # This is a sample properties file for the org.eclipse.jetty.security.JDBCLoginService
      3 # implemtation of the UserRealm interface.  This allows Jetty users authentication 
      4 # to work from a database.
      5 #
      6 #   +-------+      +------------+      +-------+
      7 #   | users |      | user_roles |      | roles |
      8 #   +-------+      +------------+      +-------+
      9 #   | id    |     /| user_id    |\     | id    |
     10 #   | user  -------| role_id    |------- role  |
     11 #   | pwd   |     \|            |/     |       |
     12 #   +-------+      +------------+      +-------+
     13 #   
     14 # 
     15 # 'cachetime' is a time in seconds to cache positive database
     16 # lookups in internal hash table. Set to 0 to disable caching.
     17 # 
     18 #
     19 # For MySQL:
     20 # create a MYSQL user called "jetty" with password "jetty"
     21 #
     22 # Create the tables:
     23 # create table users 
     24 # (
     25 #     id integer primary key,
     26 #     username varchar(100) not null unique key,
     27 #     pwd varchar(20) not null
     28 # );
     29 # 
     30 # create table roles
     31 # (
     32 #     id integer primary key,
     33 #     role varchar(100) not null unique key
     34 # );    
     35 #
     36 # create table user_roles
     37 # (
     38 #     user_id integer not null,
     39 #     role_id integer not null,
     40 #     unique key (user_id, role_id),
     41 #     index(user_id)
     42 # );
     43 #
     44 # I'm not sure unique key with a first component of user_id will be
     45 # user by MySQL in query, so additional index wouldn't hurt.
     46 #
     47 # To test JDBC implementation:
     48 #
     49 # mysql> insert into users values (1, 'admin', 'password');
     50 # mysql> insert into roles values (1, 'server-administrator');
     51 # mysql> insert into roles values (2, 'content-administrator');
     52 # mysql> insert into user_roles values (1, 1);
     53 # mysql> insert into user_roles values (1, 2);
     54 #
     55 # Replace HashUserRealm in etc/admin.xml with JDBCUserRealm and
     56 # set path to properties file.
     57 #
     58 jdbcdriver = org.gjt.mm.mysql.Driver
     59 url = jdbc:mysql://localhost/jetty
     60 username = jetty
     61 password = jetty
     62 usertable = users
     63 usertablekey = id
     64 usertableuserfield = username
     65 usertablepasswordfield = pwd
     66 roletable = roles
     67 roletablekey = id
     68 roletablerolefield = role
     69 userroletable = user_roles
     70 userroletableuserkey = user_id
     71 userroletablerolekey = role_id
     72 cachetime = 300
     73