Install JDBC authentication

To use the JDBC authentatication jWebSocket comes with an complete database schema (in jWebSocket 1.0 for MySQL)

There are the following tables in the MySQL database.

demo_users

The table of all user which can authenticate against the jWebSocket server:

CREATE TABLE  `jwebsocket`.`demo_users` (
  `user_id` int(10) unsigned NOT NULL DEFAULT '0',
  `firstname` varchar(30) DEFAULT NULL,
  `lastname` varchar(30) DEFAULT NULL,
  `loginname` varchar(25) NOT NULL,
  `password` varchar(20) NOT NULL,
  `enabled` tinyint(3) unsigned NOT NULL DEFAULT '1',
  PRIMARY KEY (`user_id`)
)

demo_roles, the table of roles a user can be assigned to

CREATE TABLE  `jwebsocket`.`demo_roles` (
  `role_id` int(10) unsigned NOT NULL DEFAULT '0',
  `name` varchar(30) NOT NULL,
  `description` text,
  PRIMARY KEY (`role_id`)
)
demo_rights

The table of all rights which can be part of a role

CREATE TABLE  `jwebsocket`.`demo_rights` (
  `right_id` int(10) unsigned NOT NULL DEFAULT '0',
  `name` varchar(80) NOT NULL,
  `description` text,
  PRIMARY KEY (`right_id`)
)

demo_user_roles

the n:m table maintaining the assignments between users and their roles

The relational constraints ensure that in case a user or a role gets updated or deleted the assignment table automatically adjusted.

CREATE TABLE  `jwebsocket`.`demo_user_roles` (
  `user_id` int(10) unsigned NOT NULL,
  `role_id` int(10) unsigned NOT NULL,
  PRIMARY KEY (`user_id`,`role_id`),
  KEY `fk_demo_uhr_roles` (`role_id`),
  CONSTRAINT `fk_demo_uhr_roles` FOREIGN KEY (`role_id`) REFERENCES `demo_roles` (`role_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_demo_uhr_user` FOREIGN KEY (`user_id`) REFERENCES `demo_users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE
)

demo_roles_rights

The n:m table maintaining the assignments between roles and their rights

The relational constraints ensure that in case a role or a right gets updated or deleted the assignment table automatically adjusted.

CREATE TABLE  `jwebsocket`.`demo_roles_rights` (
  `role_id` int(10) unsigned NOT NULL,
  `right_id` int(10) unsigned NOT NULL,
  PRIMARY KEY (`role_id`,`right_id`),
  KEY `fk_demo_rhr_rights` (`right_id`),
  CONSTRAINT `fk_demo_rhr_rights` FOREIGN KEY (`right_id`) REFERENCES `demo_rights` (`right_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_demo_rhr_roles` FOREIGN KEY (`role_id`) REFERENCES `demo_roles` (`role_id`) ON DELETE CASCADE ON UPDATE CASCADE
)

Configuration in system.xml

In the %JWEBSOCKET_HOME%conf/SystemPlugIn/system.xml configure to use the JDBC authentication:

<bean id="authManager" class="org.springframework.security.authentication.ProviderManager">
	<property name="providers">
		<list>
			<!-- Select here the authentication provider -->
			<ref local="jdbcAuthProvider"/>
		</list>
	</property>
</bean>

The following video shows a more detailed guide of how to configure jWebSocket Server with a JDBC Authentication Provider:



Publications

Learn more about WebSockets in general, get background information and gain deeper insight!

Join jWebSocket

Wether developer, designer or translator – join the jWebSocket team and grow together with our success!

Copyright © 2013 Innotrade GmbH. All rights reserved.