Table of Contents

Installation of CzechIdM - Linux - CentOS8

We expect that the server is prepared as described in Server preparation - Linux - CentOS8.

This tutorial shows how to install full production-ready version of CzechIdM on standard software setup (Java, PostgreSQL, Tomcat, Apache HTTPd). If you are looking for a demo installation please see Getting Started.

If you install CzechIdM on with Microsoft SQL Server database backend, please skip PostgreSQL-related sections and swap them for this tutorial instead.

1. Create DB user and database in PostgreSQL

Switch the user from root to postgres and use psql to add the user and database into PostgreSQL:

su - postgres
psql 
CREATE USER czechidm PASSWORD 'XXXXXXXXXXXX';
 
# Choose appropriate collation and create database.
# with czech collation (- typical)
CREATE DATABASE "czechidm" WITH OWNER 'czechidm' ENCODING 'UTF8' LC_COLLATE = 'cs_CZ.UTF-8' LC_CTYPE = 'cs_CZ.UTF-8' template 'template0';
# or with english collation
# CREATE DATABASE "czechidm" WITH OWNER 'czechidm' ENCODING 'UTF8' LC_COLLATE = 'en_US.UTF-8' LC_CTYPE = 'en_US.UTF-8' template 'template0';

Try the access to new database with new user:

[root@tomcat1 data]# psql -h localhost -U czechidm
Password for czechidm user: 
psql (9.6.1)
For more information type "help".
 
czechidm=> 
If yout have the database installed on a different server than the application itself (Tomcat etc.), don't forget to configure PostgreSQL to allow remote SSL connection from that server and add this line to /data/pgsql/9.6/pg_hba.conf replacing {IP address} and {Mask} with the IP and mask of the CzechIdM application server:
hostssl	czechidm	czechidm	{IP address}/{Mask}	md5

and restart PostgreSQL.

2. JDBC driver installation ​- CentOS8 ​

CentOS

Download PostgreSQL JDBC driver from official page. In this example we download version 42.2.11.

wget https://jdbc.postgresql.org/download/postgresql-42.2.11.jar -P /opt/tomcat/current/lib/

3. Configure environment properties. Select application profile

Edit the configuration file /etc/systemd/system/tomcat.service - edit the line with environment variable choosing the appropriate application profile. We use production profile in our example, which enables you to configure production-ready instace of the identity manager.

The dev profile is for development and testing environments and as such it has debug logging enabled. For production deployment, use a profile named production as is shown in the example. The profile naming convention is mandatory because other CzechIdM configuration depends on it.

Change ​the following line:

Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true -Djavax.servlet.request.encoding=UTF-8'

into:

Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true -Djavax.servlet.request.encoding=UTF-8 -Dspring.profiles.active=production' 

Reload ​systemd after the changes:

systemctl daemon-reload

4. Create CzechIdM configuration folders

In CzechIdM, you can store all deployment-specific configuration (i.e. database credentials) outside the war file. This is a configure-once approach which greatly simplifies future deployments.

Create the directory structure:

mkdir -p /opt/czechidm/{etc,lib,backup,data}

5. Create CzechIdM configuration

Now we will create configuration files the CzechIdM will use.

Code snippets in this chapter can be mostly copy-pasted or (but please read through whole chapter to be aware of setting you have to adjust). Configuring the CzechIdM is about altering four or five lines altogether.

Adjust database configuration

If you followed this howto, the only thing you should need to adjust is a spring.datasource.password propetry. Set it to the password for czechidm user in PostgreSQL. If necessary, adjust other database connection properties…

spring.datasource.url=jdbc:postgresql://localhost:5432/czechidm
spring.datasource.username=czechidm
spring.datasource.password=********** TODO *********
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.validationQuery=SELECT 1
spring.datasource.test-on-borrow=true

Generate JWT token

Set value of the idm.sec.security.jwt.secret.token property as is described in the template file:

# Generate JWT token security string as "cat /dev/urandom | tr -dc 'a-z0-9' | head -c VALUE" where VALUE can be from 1 to 255.
# We recommend the VALUE to be at least 25.
idm.sec.security.jwt.secret.token=********** TODO *********

Local confidential storage

Local confidential storage is encrypted by AES algoritm. Read more. Confidential storage is encrypted by a key found in secret.key file you already created.

There are two properties in application-production.properties that influence the confidential storage:

CzechIdM doesn't contain any default key for crypt confidential storage. Please define it before you start using the IdM.

Confidential storage uses AES/CBC/PKCS5Padding (more info) algorithm which operates with 128bit or 256bit key.

Length of the key determines the cipher which will be used. If you use 128b (16byte) key, CzechIdM will use AES-128. If you use 256b (32byte) key, CzechIdM will use AES-256.
  • OpenJDK/JDK 1.8u161 and all higher versions support AES-256 by default.
  • Older versions (below 1.8u161) do not offer it. On those Java distributions, you can use AES-128 or obtain the Unlimited Strength Jurisdiction Policy Files to enable AES-256.

Attachment store

In CzechIdM, users can sometimes add attachments (say, attach *.jpeg photo to their employee card request). Those files are stored in the attachment store. With the following property, you can configure, where the store is. If you used sample property file, the store is by-default located under /opt/czechidm/data .

# attachments will be stored under this path.
# new directories for attachment will be created in this folder (permissions has to be added)
# System.getProperty("user.home")/idm_data will be used if no path is given
idm.sec.core.attachment.storagePath=/opt/czechidm/data

Environment

If you install CzechIdM in multiple environments (typically test and production), you can display a label in the navigation bar which will tell the users in which environment they work. The default value "production" doesn't display any label. Set the value to test to display the label marking the Test environment.

# Application stage (development, test, production (default))
idm.pub.app.stage=production

6. Set correct permissions on CzechIdM files

chown tomcat:tomcat /opt/czechidm
chown -R tomcat:tomcat /opt/czechidm/{etc,data,backup,lib}
chmod 750 /opt/czechidm/{etc,data,backup,lib}
chmod 640 /opt/czechidm/etc/*

7. Adjust Tomcat's classpath

Apache Tomcat has to know where the new configuration is. Because CzechIdM uses SpringBoot project, we simply add the /opt/czechidm/etc directory (and others) on the classpath.

Create new file /opt/tomcat/current/bin/setenv.sh with following ​content:

CLASSPATH=/opt/czechidm/etc:/opt/czechidm/lib/*

And change owner of the file to tomcat:

chown root:tomcat /opt/tomcat/current/bin/setenv.sh

8. Create dedicated Java truststore

Java truststore is a file which contains SSL certificates which we consider trusted. Usually this means some certificates of end systems or their respective certificate authorities. When we need CzechIdM to communicate with some new system with SSL-encrypted way, we need to import particular certificate here and restart the Tomcat container.

At this point, we do not have any certificate to put into the truststore so we create a fake one with only one-day validity.

cd /opt/czechidm/etc
openssl genrsa -out fakecert.key
openssl req -new -key fakecert.key -out fakecert.csr -subj "/C=CZ/ST=Czech Republic/L=Prague/O=BCV/CN=CzechIdM placeholder cert"
openssl x509 -req -in fakecert.csr -signkey fakecert.key -days 1 -sha256 -out fakecert.crt
keytool -importcert -file fakecert.crt -alias placeholder-cert -keystore truststore.jks
    Enter keystore password:  ENTER SOME PASSWORD HERE AND REMEMBER IT FOR LATER
    Re-enter new password:
    ...
    Trust this certificate? [no]:  yes
    Certificate was added to keystore

rm fakecert.key fakecert.csr fakecert.crt
chmod 644 truststore.jks
chown root:root truststore.jks

Edit the Tomcat service file /etc/systemd/system/tomcat.service and add path to the truststore -Djavax.net.ssl.trustStore=/opt/czechidm/etc/truststore.jks and truststore password -Djavax.net.ssl.trustStorePassword=THE PASSWORD YOU ENTERED WHEN CREATING KEYSTORE to the Java options. Finally, reload the systemd and restart Tomcat.

systemctl daemon-reload
systemctl restart tomcat.service

9. Deploy the CzechIdM

Download the latest CzechIdM version. Currently it is idm-app-10.4.1.war.

Ensure Tomcat is stopped:

systemctl stop tomcat.service

Copy the identity manager WAR into webapps folder in Tomcat and name it idm.war:

cp idm-app-10.4.1.war /opt/tomcat/current/webapps/idm.war

Start the Tomcat container:

systemctl start tomcat.service

If everything is set up right, the CzechIdM will deploy. Default log is /opt/tomcat/​current/logs/​catalina.out.

10. Final Steps

Allow network services

Firewall may restrict the access to all port except ssh (22/tcp). To be able to use CzechIdM, allow port 443/tcp and reload firewalld:

firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --permanent --add-port=443/tcp
firewall-cmd --reload

Change default admin password

In the fresh CzechIdM installation, there is one user identity - admin with password admin. Right after you install the application, go to https://yourserver.tld/idm and change the default password.

Configure IdM

Follow some final configuration steps: Installation of CzechIdM - Final steps.