blob: 48104d88ad9e52e5e609a2a472941484948e4c34 [file] [log] [blame]
Jake Slack03928ae2014-05-13 18:41:56 -07001#
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#
58jdbcdriver = org.gjt.mm.mysql.Driver
59url = jdbc:mysql://localhost/jetty
60username = jetty
61password = jetty
62usertable = users
63usertablekey = id
64usertableuserfield = username
65usertablepasswordfield = pwd
66roletable = roles
67roletablekey = id
68roletablerolefield = role
69userroletable = user_roles
70userroletableuserkey = user_id
71userroletablerolekey = role_id
72cachetime = 300