Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 48104d88ad9e52e5e609a2a472941484948e4c34 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# 
# 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

Back to the top