Skip to content

Commit a585f9b

Browse files
committed
WFLY-19923: QuickStart ServletSecurity cant configure the server during packaging
1 parent 0ea81c7 commit a585f9b

File tree

4 files changed

+5
-27
lines changed

4 files changed

+5
-27
lines changed

servlet-security/README-source.adoc

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -99,29 +99,15 @@ The batch executed successfully
9999

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

102-
. The following datasource was added to the `datasources` subsystem.
103-
+
104-
[source,xml,options="nowrap"]
105-
----
106-
<datasource jndi-name="java:jboss/datasources/ServletSecurityDS" pool-name="ServletSecurityDS">
107-
<connection-url>jdbc:h2:mem:servlet-security;DB_CLOSE_ON_EXIT=FALSE</connection-url>
108-
<driver>h2</driver>
109-
<security>
110-
<user-name>sa</user-name>
111-
<password>sa</password>
112-
</security>
113-
</datasource>
114-
----
115-
116102
. The following `security-realm` was added to the `elytron` subsystem.
117103
+
118104
[source,xml,options="nowrap"]
119105
----
120106
<jdbc-realm name="servlet-security-jdbc-realm">
121-
<principal-query sql="SELECT PASSWORD FROM USERS WHERE USERNAME = ?" data-source="ServletSecurityDS">
107+
<principal-query sql="SELECT PASSWORD FROM USERS WHERE USERNAME = ?" data-source="ExampleDS">
122108
<clear-password-mapper password-index="1"/>
123109
</principal-query>
124-
<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">
110+
<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">
125111
<attribute-mapping>
126112
<attribute to="roles" index="1"/>
127113
</attribute-mapping>

servlet-security/configure-server.cli

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
# Batch script to configure the security domain and define the database query used to authenticate users
22
batch
33

4-
5-
# Start by creating the JDBC datasource
6-
/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")
7-
8-
# Add the JDBC security realm creation
9-
/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}]}])
4+
# Create a JDBC security realm
5+
/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}]}])
106

117
# Configure the servlet-security-quickstart security domain
128
/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)

servlet-security/pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,6 @@
135135
<configuration>
136136
<discover-provisioning-info>
137137
<version>${version.server}</version>
138-
<!-- datasource added by CLI script -->
139-
<failsOnError>false</failsOnError>
140138
<add-ons>
141139
<add-on>h2-database</add-on>
142140
</add-ons>
@@ -172,8 +170,6 @@
172170
<configuration>
173171
<discover-provisioning-info>
174172
<version>${version.server}</version>
175-
<!-- datasource added by CLI script -->
176-
<failsOnError>false</failsOnError>
177173
<add-ons>
178174
<add-on>h2-database</add-on>
179175
</add-ons>

servlet-security/src/main/resources/META-INF/persistence.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
data source, this example data source is just for development and testing! -->
2626
<!-- The datasource is deployed as WEB-INF/servlet-security-quickstart-ds.xml,
2727
you can find it in the source at src/main/webapp/WEB-INF/servlet-security-quickstart-ds.xml -->
28-
<jta-data-source>java:jboss/datasources/ServletSecurityDS</jta-data-source>
28+
<jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source>
2929
<properties>
3030
<!-- Properties for Hibernate -->
3131
<property name="hibernate.hbm2ddl.auto" value="create-drop" />

0 commit comments

Comments
 (0)