Difference between revisions of "Keycloak"

From Dogtag
Jump to: navigation, search
m (Configuring Tomcat Client)
m (See Also)
Line 99: Line 99:
 
* [https://github.com/keycloak/keycloak Keycloak GitHub Repository]
 
* [https://github.com/keycloak/keycloak Keycloak GitHub Repository]
 
* [https://www.keycloak.org/documentation.html Keycloak Documentation]
 
* [https://www.keycloak.org/documentation.html Keycloak Documentation]
 +
* [https://www.keycloak.org/docs/latest/securing_apps/index.html#_tomcat_adapter Keycloak Tomcat Adapters]
 
* [http://blog.arungupta.me/bind-wildfly-different-ip-address-multihomed/ Bind WildFly to a different IP address]
 
* [http://blog.arungupta.me/bind-wildfly-different-ip-address-multihomed/ Bind WildFly to a different IP address]
 
* [https://dzone.com/articles/deploying-keycloak-in-tomcat Deploying Keycloak In Tomcat]
 
* [https://dzone.com/articles/deploying-keycloak-in-tomcat Deploying Keycloak In Tomcat]
 
* [https://www.youtube.com/watch?v=FdYAdJkwynA Configuring Tomcat to use Keycloak for oAuth login]
 
* [https://www.youtube.com/watch?v=FdYAdJkwynA Configuring Tomcat to use Keycloak for oAuth login]
 
* [[Keycloak OpenShift]]
 
* [[Keycloak OpenShift]]

Revision as of 04:20, 12 October 2019

Development

To build Keycloak:

$ git clone https://github.com/keycloak/keycloak.git
$ cd keycloak
$ mvn install

See also:

Installation

To install Keycloak server:

$ wget https://downloads.jboss.org/keycloak/6.0.1/keycloak-6.0.1.tar.gz
$ tar xzvf keycloak-6.0.1.tar.gz
$ cd keycloak-6.0.1/bin

To setup admin user:

$ ./add-user-keycloak.sh -u admin -p Secret.123

To start Keycloak server:

$ ./standalone.sh -b=0.0.0.0

Adding a New Realm

To access the Admin Console, open http://$HOSTNAME:8080/auth/admin/.

To access a realm, open http://$HOSTNAME:8080/auth/realms/<realm>/account.

Adding Roles in Realm

Adding Users in Realm

Configuring Tomcat Client

To create a Tomcat server:

$ pki-server create tomcat@keycloak
$ pki-server http-connector-mod -i tomcat@keycloak --port 9080 Connector1

To install Keycloak client adapter:

$ wget https://downloads.jboss.org/keycloak/6.0.1/adapters/keycloak-oidc/keycloak-tomcat8-adapter-dist-6.0.1.tar.gz
$ mkdir keycloak-tomcat8-adapter 
$ cd keycloak-tomcat8-adapter
$ tar xzvf ../keycloak-tomcat8-adapter-dist-6.0.1.tar.gz
$ mv * /var/lib/tomcats/keycloak/lib

To enable Keycloak, create <web application>/META-INF/context.xml:

<Context>
    <Valve className="org.keycloak.adapters.tomcat.KeycloakAuthenticatorValve"/>
</Context>

To register Tomcat client:

  • Open Keycloak Admin Console
  • Click Clients -> Create

To generate client adapter configuration, click Installation:

  • Format option: Keycloak OIDC JSON

Then store the configuration in <web application>/WEB-INF/keycloak.json:

{
  "realm": "demo",
  "auth-server-url": "http://$HOSTNAME:8080/auth",
  "ssl-required": "external",
  "resource": "tomcat",
  "public-client": true,
  "confidential-port": 0
}

To configure web application, edit <web application>/WEB-INF/web.xml:

  • Define security constraints
  • Define login-config with auth-method set to KEYCLOAK

To run Tomcat server:

$ pki-server run tomcat@keycloak

See Also