[JAVA] Keycloak setup

Overview

In this second day of the Keycloak Advent Calendar, we'll walk you through the steps to set up Keycloak for a trial. It does not mention complicated settings. It's easy, so if you're interested, give it a try: slight_smile:

The setup procedure is as follows.

  1. Download Keycloak
  2. Start the server
  3. Create an admin user
  4. Login to the management console

In addition to this, this page also touches on how to Japaneseize and uninstall Keycloak.

For more information, please refer to Keycloak Guides. Japanese translation of the guide is also available on NRI OpenStandia (translated as of December).

System requirements

The requirements for launching Keycloak are as follows:

--OS that can execute Java

Setup procedure

This section describes the procedure from starting the Keycloak server, setting the administrator user, and logging in to the management console.

Download Keycloak

Download the Keycloak compressed file from the Keycloak Download Page.

Start the server

After downloading, unzip it to a suitable directory. Running standalone.sh or standalone.bat in the bin directory will start the Keycloak server.

--For Linux / Unix:

$ unzip keycloak-3.3.0.CR2.zip
$ ./bin/standalone.sh

--For Windows:

> unzip keycloak-3.3.0.CR2.zip
> bin\standalone.bat

In addition, "Wildfly" (Java EE container developed mainly by Red Hat) is included in the compressed file of Keycloak. Keycloak runs on top of this Wildfly.

: warning: By default, Keycloak does not allow access from remote hosts. This is due to WildFly's default specifications. To cancel this, add the IP address of the host allowed by the -b option to the startup script. If it is "0.0.0.0", all hosts are allowed.

$ ./bin/standalone.sh -b = 0.0.0.0

If the following message is displayed on the console, the startup is complete.

14:29:22,241 INFO  [org.jboss.as](Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
14:29:22,241 INFO  [org.jboss.as](Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
14:29:22,241 INFO  [org.jboss.as](Controller Boot Thread) WFLYSRV0025: Keycloak 3.3.0.CR2 (WildFly Core 3.0.1.Final) started in 12515ms - Started 536 of 858 services (570 services are lazy, passive or on-demand)
: information_source: If you want to stop the server, click Ctrl + C on the console.

Creating an admin user

After the server starts, open a browser and go to http: // localhost: 8080 / auth. The following page will be displayed.

Screenshot from 2017-10-29 11-03-10.png

Keycloak does not have an administrator account set by default. First you need to create it on the welcome page. With the created administrator account, you can create users, set authentication methods, register applications protected by Keycloak, and so on.

: information_source: If you want to access localhost, you can only create an initial admin user. This is a security measure. You can also use the script add-user-keycloak.sh </ code> to create an initial admin user on the command line. For more information, see the guides (Server Installation and Server Administration. Please refer to /index.html)).

Login to the management console

After creating an administrator account, you can log in to the admin console.

Click the "Administration Console" link at the bottom of the welcome page.

2017-10-29 11.07.Screenshots from 38.png

Enter the username and password you created on the welcome page. The Keycloak Management Console main page is displayed.

2017-10-29 11.08.Screenshots from 21.png

If you want to know about a setting item in the management console, hover the mouse over the? (Question mark) icon and a text explaining the setting item will pop up.

2017-10-29 11.09.Screenshots from 52.png

Localizing into Japanese

Keycloak is internationalized and Japanese is also supported. To translate the management console and user account services into Japanese, follow the steps below.

Click the "Themes" tab, set the "Internationalization Enabled" setting to "ON", and click the "Save" button.

2017-10-29 11.14.Screenshots from 46.png

Once you log out, Japanese localization should be completed, but it may not be reflected immediately due to cache etc. In that case, click the link labeled "Admin" on the right and select "Manage account".

2017-10-29 11.17.Screenshots from 16.png

There is a language setting at the top of the screen, so click it and select Japanese.

2017-10-29 11.29.Screenshots from 33.png

That's it. Please log out once to confirm.

2017-10-29 11.34.Screenshot from 04.png

When you try to log in again, a select box for selecting the language will appear on the login screen.

2017-10-29 11.41.Screenshot from 09.png

If you log in after specifying Japanese here, the screen that was in English will be displayed in Japanese.

2017-10-29 11.34.Screenshots from 45.png

Uninstall Keycloak

No special work is required to uninstall Keycloak. Basically, just delete the unzipped directory.

Reference material