Details
diff --git a/project-integrations/aerogear-ups/app/src/main/webapp/admin/admin.html b/project-integrations/aerogear-ups/app/src/main/webapp/admin/admin.html
new file mode 100755
index 0000000..8102dc0
--- /dev/null
+++ b/project-integrations/aerogear-ups/app/src/main/webapp/admin/admin.html
@@ -0,0 +1 @@
+<h1>This would be the admin page for the UPS admin console.</h1>
\ No newline at end of file
diff --git a/project-integrations/aerogear-ups/app/src/main/webapp/WEB-INF/web.xml b/project-integrations/aerogear-ups/app/src/main/webapp/WEB-INF/web.xml
index af91ffa..1be2b56 100755
--- a/project-integrations/aerogear-ups/app/src/main/webapp/WEB-INF/web.xml
+++ b/project-integrations/aerogear-ups/app/src/main/webapp/WEB-INF/web.xml
@@ -23,6 +23,16 @@
<security-constraint>
<web-resource-collection>
+ <web-resource-name>AdminConsole</web-resource-name>
+ <url-pattern>/admin/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>admin</role-name>
+ </auth-constraint>
+ </security-constraint>
+
+ <security-constraint>
+ <web-resource-collection>
<web-resource-name>Database</web-resource-name>
<url-pattern>/rest/*</url-pattern>
</web-resource-collection>
diff --git a/project-integrations/aerogear-ups/auth-server/pom.xml b/project-integrations/aerogear-ups/auth-server/pom.xml
index 6ac1405..5dba72b 100755
--- a/project-integrations/aerogear-ups/auth-server/pom.xml
+++ b/project-integrations/aerogear-ups/auth-server/pom.xml
@@ -135,6 +135,17 @@
<artifactId>keycloak-timer-basic</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.keycloak</groupId>
+ <artifactId>keycloak-export-import-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.keycloak</groupId>
+ <artifactId>keycloak-export-import-impl</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
<dependency>
<groupId>org.jboss.spec.javax.servlet</groupId>
diff --git a/project-integrations/aerogear-ups/auth-server/src/main/java/org/aerogear/ups/security/UpsSecurityApplication.java b/project-integrations/aerogear-ups/auth-server/src/main/java/org/aerogear/ups/security/UpsSecurityApplication.java
new file mode 100755
index 0000000..eddeace
--- /dev/null
+++ b/project-integrations/aerogear-ups/auth-server/src/main/java/org/aerogear/ups/security/UpsSecurityApplication.java
@@ -0,0 +1,40 @@
+package org.aerogear.ups.security;
+
+import org.jboss.resteasy.core.Dispatcher;
+import org.keycloak.models.KeycloakSession;
+import org.keycloak.models.RealmModel;
+import org.keycloak.models.UserModel;
+import org.keycloak.services.managers.RealmManager;
+import org.keycloak.services.resources.KeycloakApplication;
+
+import javax.servlet.ServletContext;
+import javax.ws.rs.core.Context;
+
+/**
+ * @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
+ * @version $Revision: 1 $
+ */
+public class UpsSecurityApplication extends KeycloakApplication {
+ public UpsSecurityApplication(@Context ServletContext context, @Context Dispatcher dispatcher) {
+ super(context, dispatcher);
+ }
+
+ @Override
+ protected void setupDefaultRealm(String contextPath) {
+ super.setupDefaultRealm(contextPath);
+ KeycloakSession session = factory.createSession();
+ session.getTransaction().begin();
+
+ // disable master realm by deleting the admin user.
+ try {
+ RealmManager manager = new RealmManager(session);
+ RealmModel master = manager.getKeycloakAdminstrationRealm();
+ UserModel admin = master.getUser("admin");
+ if (admin != null) master.removeUser(admin.getLoginName());
+ session.getTransaction().commit();
+ } finally {
+ session.close();
+ }
+
+ }
+}
diff --git a/project-integrations/aerogear-ups/auth-server/src/main/webapp/WEB-INF/testrealm.json b/project-integrations/aerogear-ups/auth-server/src/main/webapp/WEB-INF/testrealm.json
index bc2d8f7..bcbd7ad 100755
--- a/project-integrations/aerogear-ups/auth-server/src/main/webapp/WEB-INF/testrealm.json
+++ b/project-integrations/aerogear-ups/auth-server/src/main/webapp/WEB-INF/testrealm.json
@@ -20,6 +20,19 @@
{ "type" : "password",
"value" : "password" }
]
+ },
+ {
+ "username" : "admin",
+ "enabled": true,
+ "firstName": "Bill",
+ "lastName": "Burke",
+ "credentials" : [
+ { "type" : "password",
+ "value" : "admin" }
+ ],
+ "requiredActions": [
+ "UPDATE_PASSWORD"
+ ]
}
],
"roles" : {
@@ -38,6 +51,10 @@
{
"username": "bburke@redhat.com",
"roles": ["user"]
+ },
+ {
+ "username": "admin",
+ "roles": ["user", "admin"]
}
],
"scopeMappings": [
@@ -64,6 +81,12 @@
"username": "bburke@redhat.com",
"roles": ["manage-account"]
}
+ ],
+ "demo-realm": [
+ {
+ "username": "admin",
+ "roles": ["realm-admin"]
+ }
]
}
diff --git a/project-integrations/aerogear-ups/auth-server/src/main/webapp/WEB-INF/web.xml b/project-integrations/aerogear-ups/auth-server/src/main/webapp/WEB-INF/web.xml
index 048c39d..bb58ec0 100755
--- a/project-integrations/aerogear-ups/auth-server/src/main/webapp/WEB-INF/web.xml
+++ b/project-integrations/aerogear-ups/auth-server/src/main/webapp/WEB-INF/web.xml
@@ -16,7 +16,7 @@
<servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServlet30Dispatcher</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
- <param-value>org.keycloak.services.resources.KeycloakApplication</param-value>
+ <param-value>org.aerogear.ups.security.UpsSecurityApplication</param-value>
</init-param>
<init-param>
<param-name>resteasy.servlet.mapping.prefix</param-name>