Skip to content

Commit

Permalink
Merge pull request #179 from lucasponce/JAAS-Support
Browse files Browse the repository at this point in the history
Add BASIC JAAS security to .war artifacts
  • Loading branch information
jshaughn committed May 9, 2016
2 parents d5944bf + e58e4e3 commit 06bad6b
Show file tree
Hide file tree
Showing 12 changed files with 215 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,26 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">

<security-constraint>
<web-resource-collection>
<web-resource-name>REST endpoints</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>*</role-name>
</auth-constraint>
</security-constraint>

<login-config>
<auth-method>BASIC</auth-method>
<realm-name>ApplicationRealm</realm-name>
</login-config>

<security-role>
<role-name>read-write</role-name>
</security-role>
<security-role>
<role-name>read-only</role-name>
</security-role>

</web-app>
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,26 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">

<security-constraint>
<web-resource-collection>
<web-resource-name>REST endpoints</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>*</role-name>
</auth-constraint>
</security-constraint>

<login-config>
<auth-method>BASIC</auth-method>
<realm-name>ApplicationRealm</realm-name>
</login-config>

<security-role>
<role-name>read-write</role-name>
</security-role>
<security-role>
<role-name>read-only</role-name>
</security-role>

</web-app>
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,26 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">

<security-constraint>
<web-resource-collection>
<web-resource-name>REST endpoints</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>*</role-name>
</auth-constraint>
</security-constraint>

<login-config>
<auth-method>BASIC</auth-method>
<realm-name>ApplicationRealm</realm-name>
</login-config>

<security-role>
<role-name>read-write</role-name>
</security-role>
<security-role>
<role-name>read-only</role-name>
</security-role>

</web-app>
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,26 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">

<security-constraint>
<web-resource-collection>
<web-resource-name>REST endpoints</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>*</role-name>
</auth-constraint>
</security-constraint>

<login-config>
<auth-method>BASIC</auth-method>
<realm-name>ApplicationRealm</realm-name>
</login-config>

<security-role>
<role-name>read-write</role-name>
</security-role>
<security-role>
<role-name>read-only</role-name>
</security-role>

</web-app>
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,26 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">

<security-constraint>
<web-resource-collection>
<web-resource-name>REST endpoints</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>*</role-name>
</auth-constraint>
</security-constraint>

<login-config>
<auth-method>BASIC</auth-method>
<realm-name>ApplicationRealm</realm-name>
</login-config>

<security-role>
<role-name>read-write</role-name>
</security-role>
<security-role>
<role-name>read-only</role-name>
</security-role>

</web-app>
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,26 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">

<security-constraint>
<web-resource-collection>
<web-resource-name>REST endpoints</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>*</role-name>
</auth-constraint>
</security-constraint>

<login-config>
<auth-method>BASIC</auth-method>
<realm-name>ApplicationRealm</realm-name>
</login-config>

<security-role>
<role-name>read-write</role-name>
</security-role>
<security-role>
<role-name>read-only</role-name>
</security-role>

</web-app>
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,26 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">

<security-constraint>
<web-resource-collection>
<web-resource-name>REST endpoints</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>*</role-name>
</auth-constraint>
</security-constraint>

<login-config>
<auth-method>BASIC</auth-method>
<realm-name>ApplicationRealm</realm-name>
</login-config>

<security-role>
<role-name>read-write</role-name>
</security-role>
<security-role>
<role-name>read-only</role-name>
</security-role>

</web-app>
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,26 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">

<security-constraint>
<web-resource-collection>
<web-resource-name>REST endpoints</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>*</role-name>
</auth-constraint>
</security-constraint>

<login-config>
<auth-method>BASIC</auth-method>
<realm-name>ApplicationRealm</realm-name>
</login-config>

<security-role>
<role-name>read-write</role-name>
</security-role>
<security-role>
<role-name>read-only</role-name>
</security-role>

</web-app>
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ class BusITest extends AbstractITestBase {
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory")
env.put(Context.PROVIDER_URL, "http-remoting://127.0.0.1:8080")
env.put(Context.SECURITY_PRINCIPAL, 'hawkular')
env.put(Context.SECURITY_CREDENTIALS, 'hawkular')
env.put(Context.SECURITY_PRINCIPAL, 'jdoe')
env.put(Context.SECURITY_CREDENTIALS, 'password')

InitialContext namingContext = new InitialContext(env)
ConnectionFactory connectionFactory = (ConnectionFactory) namingContext.lookup('jms/RemoteConnectionFactory')
JMSContext context = connectionFactory.createContext('hawkular', 'hawkular')
JMSContext context = connectionFactory.createContext('jdoe', 'password')
Topic topic = (Topic) namingContext.lookup('java:/topic/HawkularAvailData')
JMSProducer producer = context.createProducer()

Expand Down Expand Up @@ -227,12 +227,12 @@ class BusITest extends AbstractITestBase {
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory")
env.put(Context.PROVIDER_URL, "http-remoting://127.0.0.1:8080")
env.put(Context.SECURITY_PRINCIPAL, 'hawkular')
env.put(Context.SECURITY_CREDENTIALS, 'hawkular')
env.put(Context.SECURITY_PRINCIPAL, 'jdoe')
env.put(Context.SECURITY_CREDENTIALS, 'password')

InitialContext namingContext = new InitialContext(env)
ConnectionFactory connectionFactory = (ConnectionFactory) namingContext.lookup('jms/RemoteConnectionFactory')
JMSContext context = connectionFactory.createContext('hawkular', 'hawkular')
JMSContext context = connectionFactory.createContext('jdoe', 'password')
Topic topic = (Topic) namingContext.lookup('java:/topic/HawkularMetricData')
JMSProducer producer = context.createProducer()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@
#
#admin=PowerUser,BillingAdmin,
#guest=guest
hawkular=guest
jdoe=read-write,read-only,guest
jsmith=read-write,read-only
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@
# The following illustrates how an admin user could be defined, this
# is for illustration only and does not correspond to a usable password.
#
hawkular=2e1e5cc53887b6592e92423688b5ff7d
jdoe=35c8096d943bf6555d0a39f35fd5c7e0
jsmith=946d26a68d0cb5fb1b8ef5760b9326d5
29 changes: 29 additions & 0 deletions hawkular-alerts-rest/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,33 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">

<security-constraint>
<web-resource-collection>
<web-resource-name>Status endpoint</web-resource-name>
<url-pattern>/status</url-pattern>
</web-resource-collection>
</security-constraint>

<security-constraint>
<web-resource-collection>
<web-resource-name>REST endpoints</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>*</role-name>
</auth-constraint>
</security-constraint>

<login-config>
<auth-method>BASIC</auth-method>
<realm-name>ApplicationRealm</realm-name>
</login-config>

<security-role>
<role-name>read-write</role-name>
</security-role>
<security-role>
<role-name>read-only</role-name>
</security-role>

</web-app>

0 comments on commit 06bad6b

Please sign in to comment.