commit
d34c73f9b9
7 changed files with 28 additions and 87 deletions
|
@ -117,6 +117,8 @@ module.controller('RealmCreateCtrl', function($scope, Current, Realm, $upload, $
|
||||||
|
|
||||||
$scope.save = function() {
|
$scope.save = function() {
|
||||||
var realmCopy = angular.copy($scope.realm);
|
var realmCopy = angular.copy($scope.realm);
|
||||||
|
var ssl = window.location.protocol == 'https:';
|
||||||
|
realmCopy.sslNotRequired = !ssl;
|
||||||
console.log('creating new realm **');
|
console.log('creating new realm **');
|
||||||
Realm.create(realmCopy, function(data, headers) {
|
Realm.create(realmCopy, function(data, headers) {
|
||||||
var data = Realm.query(function() {
|
var data = Realm.query(function() {
|
||||||
|
@ -438,6 +440,12 @@ module.controller('RealmDefaultRolesCtrl', function ($scope, Realm, realm, appli
|
||||||
$scope.selectedRealmDefRoles = [];
|
$scope.selectedRealmDefRoles = [];
|
||||||
|
|
||||||
$scope.applications = angular.copy(applications);
|
$scope.applications = angular.copy(applications);
|
||||||
|
for (var i = 0; i < applications.length; i++) {
|
||||||
|
if (applications[i].name == 'account') {
|
||||||
|
$scope.application = $scope.applications[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$scope.availableAppRoles = [];
|
$scope.availableAppRoles = [];
|
||||||
$scope.selectedAppRoles = [];
|
$scope.selectedAppRoles = [];
|
||||||
|
|
|
@ -45,7 +45,20 @@
|
||||||
the adapter's dependencies may conflict with your application's.
|
the adapter's dependencies may conflict with your application's.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
After creating the <literal>jboss-deployment-structure.xml</literal> configuration file, you must create
|
Next thing you have to do is turn on the Keycloak adapter for this deployment. To do this you must
|
||||||
|
create a <literal>WEB-INF/jboss-web.xml</literal> file and specify a a Keycloak valve. This will override
|
||||||
|
any <literal>login-config</literal> setting you have defined with <literal>web.xml</literal>
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
<programlisting><![CDATA[<jboss-web>
|
||||||
|
<valve>
|
||||||
|
<class-name>org.keycloak.adapters.as7.KeycloakAuthenticatorValve</class-name>
|
||||||
|
</valve>
|
||||||
|
</jboss-web>]]>
|
||||||
|
</programlisting>
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
After creating the <literal>jboss-web.xml</literal> configuration file, you must create
|
||||||
a <literal>keycloak.json</literal> adapter config file within the <literal>WEB-INF</literal> directory
|
a <literal>keycloak.json</literal> adapter config file within the <literal>WEB-INF</literal> directory
|
||||||
of your WAR. The format of this config file is describe in the <link linkend='adapter-config'>general adapter configuration</link>
|
of your WAR. The format of this config file is describe in the <link linkend='adapter-config'>general adapter configuration</link>
|
||||||
section.
|
section.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<jboss-web>
|
<jboss-web>
|
||||||
<valve>
|
<valve>
|
||||||
<class-name>org.keycloak.adapters.as7.OAuthAuthenticatorValve</class-name>
|
<class-name>org.keycloak.adapters.as7.KeycloakAuthenticatorValve</class-name>
|
||||||
</valve>
|
</valve>
|
||||||
</jboss-web>
|
</jboss-web>
|
|
@ -1,5 +1,5 @@
|
||||||
<jboss-web>
|
<jboss-web>
|
||||||
<valve>
|
<valve>
|
||||||
<class-name>org.keycloak.adapters.as7.BearerTokenAuthenticatorValve</class-name>
|
<class-name>org.keycloak.adapters.as7.KeycloakAuthenticatorValve</class-name>
|
||||||
</valve>
|
</valve>
|
||||||
</jboss-web>
|
</jboss-web>
|
|
@ -1,5 +1,5 @@
|
||||||
<jboss-web>
|
<jboss-web>
|
||||||
<valve>
|
<valve>
|
||||||
<class-name>org.keycloak.adapters.as7.OAuthAuthenticatorValve</class-name>
|
<class-name>org.keycloak.adapters.as7.KeycloakAuthenticatorValve</class-name>
|
||||||
</valve>
|
</valve>
|
||||||
</jboss-web>
|
</jboss-web>
|
|
@ -1,80 +0,0 @@
|
||||||
package org.keycloak.adapters.as7;
|
|
||||||
|
|
||||||
import org.apache.catalina.Lifecycle;
|
|
||||||
import org.apache.catalina.LifecycleEvent;
|
|
||||||
import org.apache.catalina.LifecycleException;
|
|
||||||
import org.apache.catalina.LifecycleListener;
|
|
||||||
import org.apache.catalina.authenticator.AuthenticatorBase;
|
|
||||||
import org.apache.catalina.connector.Request;
|
|
||||||
import org.apache.catalina.connector.Response;
|
|
||||||
import org.apache.catalina.core.StandardContext;
|
|
||||||
import org.apache.catalina.deploy.LoginConfig;
|
|
||||||
import org.jboss.logging.Logger;
|
|
||||||
import org.keycloak.adapters.ResourceMetadata;
|
|
||||||
import org.keycloak.adapters.as7.config.CatalinaAdapterConfigLoader;
|
|
||||||
import org.keycloak.representations.adapters.config.AdapterConfig;
|
|
||||||
import org.keycloak.adapters.config.AdapterConfigLoader;
|
|
||||||
|
|
||||||
import javax.security.auth.login.LoginException;
|
|
||||||
import javax.servlet.ServletException;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Uses a configured remote auth server to do Bearer token authentication only. SkeletonKeyTokens are used
|
|
||||||
* to provide user data and role mappings.
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
|
|
||||||
* @version $Revision: 1 $
|
|
||||||
*/
|
|
||||||
public class BearerTokenAuthenticatorValve extends AuthenticatorBase implements LifecycleListener {
|
|
||||||
private static final Logger log = Logger.getLogger(BearerTokenAuthenticatorValve.class);
|
|
||||||
protected AdapterConfig adapterConfig;
|
|
||||||
protected ResourceMetadata resourceMetadata;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void start() throws LifecycleException {
|
|
||||||
super.start();
|
|
||||||
StandardContext standardContext = (StandardContext) context;
|
|
||||||
standardContext.addLifecycleListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void lifecycleEvent(LifecycleEvent event) {
|
|
||||||
if (event.getType() == Lifecycle.AFTER_START_EVENT) init();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void init() {
|
|
||||||
AdapterConfigLoader adapterConfigLoader = new CatalinaAdapterConfigLoader(context);
|
|
||||||
adapterConfig = adapterConfigLoader.getAdapterConfig();
|
|
||||||
adapterConfigLoader.init();
|
|
||||||
resourceMetadata = adapterConfigLoader.getResourceMetadata();
|
|
||||||
AuthenticatedActionsValve actions = new AuthenticatedActionsValve(adapterConfig, getNext(), getContainer(), getController());
|
|
||||||
setNext(actions);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void invoke(Request request, Response response) throws IOException, ServletException {
|
|
||||||
try {
|
|
||||||
log.debugv("{0} {1}", request.getMethod(), request.getRequestURI());
|
|
||||||
if (adapterConfig.isCors() && new CorsPreflightChecker(adapterConfig).checkCorsPreflight(request, response)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
super.invoke(request, response);
|
|
||||||
} finally {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean authenticate(Request request, HttpServletResponse response, LoginConfig config) throws IOException {
|
|
||||||
try {
|
|
||||||
CatalinaBearerTokenAuthenticator bearer = new CatalinaBearerTokenAuthenticator(resourceMetadata, true, adapterConfig.isUseResourceRoleMappings());
|
|
||||||
if (bearer.login(request, response)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
} catch (LoginException e) {
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -45,9 +45,9 @@ import java.util.Set;
|
||||||
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
|
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
|
||||||
* @version $Revision: 1 $
|
* @version $Revision: 1 $
|
||||||
*/
|
*/
|
||||||
public class OAuthAuthenticatorValve extends FormAuthenticator implements LifecycleListener {
|
public class KeycloakAuthenticatorValve extends FormAuthenticator implements LifecycleListener {
|
||||||
protected RealmConfiguration realmConfiguration;
|
protected RealmConfiguration realmConfiguration;
|
||||||
private static final Logger log = Logger.getLogger(OAuthAuthenticatorValve.class);
|
private static final Logger log = Logger.getLogger(KeycloakAuthenticatorValve.class);
|
||||||
protected UserSessionManagement userSessionManagement = new UserSessionManagement();
|
protected UserSessionManagement userSessionManagement = new UserSessionManagement();
|
||||||
protected AdapterConfig adapterConfig;
|
protected AdapterConfig adapterConfig;
|
||||||
protected ResourceMetadata resourceMetadata;
|
protected ResourceMetadata resourceMetadata;
|
||||||
|
@ -116,7 +116,7 @@ public class OAuthAuthenticatorValve extends FormAuthenticator implements Lifecy
|
||||||
}
|
}
|
||||||
|
|
||||||
// initiate or continue oauth2 protocol
|
// initiate or continue oauth2 protocol
|
||||||
oauth(request, response);
|
if (!adapterConfig.isBearerOnly()) oauth(request, response);
|
||||||
} catch (LoginException e) {
|
} catch (LoginException e) {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
Loading…
Reference in a new issue