Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions servlet-security/README-source.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -99,29 +99,15 @@ The batch executed successfully

After stopping the server, open the `__{jbossHomeName}__/standalone/configuration/standalone.xml` file and review the changes.

. The following datasource was added to the `datasources` subsystem.
+
[source,xml,options="nowrap"]
----
<datasource jndi-name="java:jboss/datasources/ServletSecurityDS" pool-name="ServletSecurityDS">
<connection-url>jdbc:h2:mem:servlet-security;DB_CLOSE_ON_EXIT=FALSE</connection-url>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
</datasource>
----

. The following `security-realm` was added to the `elytron` subsystem.
+
[source,xml,options="nowrap"]
----
<jdbc-realm name="servlet-security-jdbc-realm">
<principal-query sql="SELECT PASSWORD FROM USERS WHERE USERNAME = ?" data-source="ServletSecurityDS">
<principal-query sql="SELECT PASSWORD FROM USERS WHERE USERNAME = ?" data-source="ExampleDS">
<clear-password-mapper password-index="1"/>
</principal-query>
<principal-query sql="SELECT R.NAME, 'Roles' FROM USERS_ROLES UR INNER JOIN ROLES R ON R.ID = UR.ROLE_ID INNER JOIN USERS U ON U.ID = UR.USER_ID WHERE U.USERNAME = ?" data-source="ServletSecurityDS">
<principal-query sql="SELECT R.NAME, 'Roles' FROM USERS_ROLES UR INNER JOIN ROLES R ON R.ID = UR.ROLE_ID INNER JOIN USERS U ON U.ID = UR.USER_ID WHERE U.USERNAME = ?" data-source="ExampleDS">
<attribute-mapping>
<attribute to="roles" index="1"/>
</attribute-mapping>
Expand Down
8 changes: 2 additions & 6 deletions servlet-security/configure-server.cli
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
# Batch script to configure the security domain and define the database query used to authenticate users
batch


# Start by creating the JDBC datasource
/subsystem=datasources/data-source=ServletSecurityDS:add(connection-url="jdbc:h2:mem:servlet-security;DB_CLOSE_ON_EXIT=FALSE", jndi-name="java:jboss/datasources/ServletSecurityDS", driver-name=h2, user-name="sa", password="sa")

# Add the JDBC security realm creation
/subsystem=elytron/jdbc-realm=servlet-security-jdbc-realm:add(principal-query=[{sql="SELECT PASSWORD FROM USERS WHERE USERNAME = ?", data-source="ServletSecurityDS", clear-password-mapper={password-index=1}},{sql="SELECT R.NAME, 'Roles' FROM USERS_ROLES UR INNER JOIN ROLES R ON R.ID = UR.ROLE_ID INNER JOIN USERS U ON U.ID = UR.USER_ID WHERE U.USERNAME = ?", data-source="ServletSecurityDS", attribute-mapping=[{index=1, to=Roles}]}])
# Create a JDBC security realm
/subsystem=elytron/jdbc-realm=servlet-security-jdbc-realm:add(principal-query=[{sql="SELECT PASSWORD FROM USERS WHERE USERNAME = ?", data-source="ExampleDS", clear-password-mapper={password-index=1}},{sql="SELECT R.NAME, 'Roles' FROM USERS_ROLES UR INNER JOIN ROLES R ON R.ID = UR.ROLE_ID INNER JOIN USERS U ON U.ID = UR.USER_ID WHERE U.USERNAME = ?", data-source="ExampleDS", attribute-mapping=[{index=1, to=Roles}]}])

# Configure the servlet-security-quickstart security domain
/subsystem=elytron/security-domain=servlet-security-quickstart-sd:add(default-realm=servlet-security-jdbc-realm, realms=[{realm=servlet-security-jdbc-realm}], permission-mapper=default-permission-mapper)
Expand Down
4 changes: 0 additions & 4 deletions servlet-security/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,6 @@
<configuration>
<discover-provisioning-info>
<version>${version.server}</version>
<!-- datasource added by CLI script -->
<failsOnError>false</failsOnError>
<add-ons>
<add-on>h2-database</add-on>
</add-ons>
Expand Down Expand Up @@ -172,8 +170,6 @@
<configuration>
<discover-provisioning-info>
<version>${version.server}</version>
<!-- datasource added by CLI script -->
<failsOnError>false</failsOnError>
<add-ons>
<add-on>h2-database</add-on>
</add-ons>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
data source, this example data source is just for development and testing! -->
<!-- The datasource is deployed as WEB-INF/servlet-security-quickstart-ds.xml,
you can find it in the source at src/main/webapp/WEB-INF/servlet-security-quickstart-ds.xml -->
<jta-data-source>java:jboss/datasources/ServletSecurityDS</jta-data-source>
<jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source>
<properties>
<!-- Properties for Hibernate -->
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
Expand Down
Loading