Proyecto

General

Perfil

Keycloak by Neodoo En » Histórico » Versión 2

Francisco Javier Solans Benedí, 2024-04-10 08:08

1 2 Francisco Javier Solans Benedí
{{toc}}
2 1 Francisco Javier Solans Benedí
3 2 Francisco Javier Solans Benedí
# Usage Instructions
4 1 Francisco Javier Solans Benedí
5 2 Francisco Javier Solans Benedí
## Getting started
6 1 Francisco Javier Solans Benedí
7 2 Francisco Javier Solans Benedí
1. Launch the product via 1-Click
8
2. Use a web browser to access the Admin console at: https://[ec2-ip]:8443, where [ec2_ip] is the public ip provided by Amazon for your instance.
9
3. Log in using the following credentials:
10
   * Username: admin
11
   * Password: the instance_id of the instance
12 1 Francisco Javier Solans Benedí
13 2 Francisco Javier Solans Benedí
You can also access your instance via SSH using the username and your Amazon private key.
14 1 Francisco Javier Solans Benedí
15 2 Francisco Javier Solans Benedí
The **username** depends on the operative system:
16
* Centos 9 Stream: 'ec2-user'
17
* Other Centos: 'centos'
18
* Ubuntu: 'ubuntu'
19
* Rocky Linux: 'rocky'
20 1 Francisco Javier Solans Benedí
21 2 Francisco Javier Solans Benedí
## Installation details
22 1 Francisco Javier Solans Benedí
23 2 Francisco Javier Solans Benedí
### Keycloak installed with wildfly distribution
24 1 Francisco Javier Solans Benedí
25
In versions prior to 19.0.1, we install Keyckloak embedded within the wildfly application server
26
27
The configuration files are located inside the embedded WildFly, that is, in the directory $KEYCLOAK_HOME where KEYCLOAK_HOME is /usr/java/keycloak.
28
29
For more details on the installation, you can refer to the documentation at https://www.keycloak.org/docs/latest/server_installation/index.html
30
31 2 Francisco Javier Solans Benedí
### Keycloak installed with the Quarkus distribution.
32
33 1 Francisco Javier Solans Benedí
From version 19.0.1, we install Keycloak with Quarkus as the distribution with WildFly is deprecated.
34
35
The configuration file is located in the directory $KEYCLOAK_HOME/conf/keycloak.conf where $KEYCLOAK_HOME is /usr/java/keycloak.
36
37
For more details on the installation, you can refer to the documentation at https://www.keycloak.org/docs/latest/server_installation/index.html
38
39 2 Francisco Javier Solans Benedí
### TLS configuration in Keycloak
40
41 1 Francisco Javier Solans Benedí
By default, we have created a self-signed certificate using Java Keystore so it's not validated by any authority (by default, the Keycloak server looks for the file $KEYCLOAK_HOME/conf/server.keystore).
42 2 Francisco Javier Solans Benedí
43 1 Francisco Javier Solans Benedí
If you want to obtain a valid certificate, you will need to request one from a certificate authority and make the necessary changes in Keycloak.
44
45 2 Francisco Javier Solans Benedí
### Service configuration
46
47 1 Francisco Javier Solans Benedí
Server service is configured with systemd.
48 2 Francisco Javier Solans Benedí
49 1 Francisco Javier Solans Benedí
The Keycloak service is in /etc/systemd/system/keycloak.service, which indicates whether to start Keycloak in development or production mode:
50 2 Francisco Javier Solans Benedí
* If you have chosen Keycloak with H2, the service will start in development mode: ExecStart=/usr/java/keycloak/bin/kc.sh start-dev
51
* If you have chosen Keycloak with MySQL or PostgreSQL, the service is started for production mode: ExecStart=/usr/java/keycloak/bin/kc.sh start
52 1 Francisco Javier Solans Benedí
53
View status server:
54 2 Francisco Javier Solans Benedí
``` shell
55 1 Francisco Javier Solans Benedí
[centos@ip-172-31-9-232 etc]$ sudo systemctl status keycloak
56 2 Francisco Javier Solans Benedí
```
57 1 Francisco Javier Solans Benedí
58 2 Francisco Javier Solans Benedí
Stop server:
59
``` shell
60 1 Francisco Javier Solans Benedí
[centos@ip-172-31-9-232 etc]$ sudo systemctl stop keycloak
61 2 Francisco Javier Solans Benedí
```
62 1 Francisco Javier Solans Benedí
63 2 Francisco Javier Solans Benedí
Start server:
64
``` shell
65 1 Francisco Javier Solans Benedí
[centos@ip-172-31-9-232 etc]$ sudo systemctl start keycloak
66 2 Francisco Javier Solans Benedí
```
67 1 Francisco Javier Solans Benedí
68
Data persistence modes
69
70
H2 (Default)
71
72
Keycloak comes with its own embedded Java-based relational database called H2. Usually recommended for development environments, for production environments it is recommended to work with better relational databases.
73
74
We provide products with MySQL or PostgreSQL.
75
76
MySQL
77
78
Keycloak is configured with a MySQL database.
79
80
PostgreSQL
81
82
Keycloak is configured with a PostgreSQL database.
83
84
MySQL
85 2 Francisco Javier Solans Benedí
86 1 Francisco Javier Solans Benedí
View service status:
87 2 Francisco Javier Solans Benedí
``` shell
88 1 Francisco Javier Solans Benedí
$ sudo systemctl status  mysql
89
90 2 Francisco Javier Solans Benedí
Stop service:
91
``` shell
92 1 Francisco Javier Solans Benedí
$ sudo systemctl stop mysql
93 2 Francisco Javier Solans Benedí
```
94 1 Francisco Javier Solans Benedí
Start service:
95 2 Francisco Javier Solans Benedí
``` shell
96 1 Francisco Javier Solans Benedí
$ sudo systemctl start mysql
97 2 Francisco Javier Solans Benedí
```
98
99 1 Francisco Javier Solans Benedí
Access the MySQL console from your terminal:
100 2 Francisco Javier Solans Benedí
``` shell
101 1 Francisco Javier Solans Benedí
$ sudo mysql
102 2 Francisco Javier Solans Benedí
```
103
104 1 Francisco Javier Solans Benedí
PostgreSQL
105 2 Francisco Javier Solans Benedí
106 1 Francisco Javier Solans Benedí
View service status:
107 2 Francisco Javier Solans Benedí
``` shell
108 1 Francisco Javier Solans Benedí
$ sudo systemctl status  postgresql
109 2 Francisco Javier Solans Benedí
```
110 1 Francisco Javier Solans Benedí
111 2 Francisco Javier Solans Benedí
Stop service:
112
``` shell
113 1 Francisco Javier Solans Benedí
$ sudo systemctl stop postgresql
114 2 Francisco Javier Solans Benedí
```
115 1 Francisco Javier Solans Benedí
116 2 Francisco Javier Solans Benedí
Start service:
117
``` shell
118 1 Francisco Javier Solans Benedí
$ sudo systemctl start postgresql
119 2 Francisco Javier Solans Benedí
```
120
121 1 Francisco Javier Solans Benedí
Access the MySQL console from your terminal:
122 2 Francisco Javier Solans Benedí
``` shell
123 1 Francisco Javier Solans Benedí
$ sudo -u postgres psql
124 2 Francisco Javier Solans Benedí
```
125 1 Francisco Javier Solans Benedí
126 2 Francisco Javier Solans Benedí
## Other useful data
127
128
**Location of sensitive information**
129 1 Francisco Javier Solans Benedí
All the information is saved in the database.
130
131
In MySQL the data folder is /var/lib/mysql
132
In PostgreSQL the data folder is /var/lib/pgsql/data
133
134 2 Francisco Javier Solans Benedí
**Encryption configuration**
135 1 Francisco Javier Solans Benedí
There is no encrypted data.
136
137 2 Francisco Javier Solans Benedí
**Changing system credentials**
138 1 Francisco Javier Solans Benedí
To change the Kecycloak credentials you have to go to the menu on the right, users, credentials and press the reset button.
139
140 2 Francisco Javier Solans Benedí
**Instructions on how the user interacts with Keycloak to decrypt necessary data**
141 1 Francisco Javier Solans Benedí
You can use the Keycloak management console to view all necessary data.
142
143 2 Francisco Javier Solans Benedí
**How to assess and monitor the health and proper function of the application.**
144 1 Francisco Javier Solans Benedí
1. Navigate to your Amazon EC2 console and verify that you're in the correct region.
145
2. Choose Instance and select your launched instance.
146
3. Select the server to display your metadata page and choose the Status checks tab at the bottom of the page to review if your status checks passed or failed.
147
148 2 Francisco Javier Solans Benedí
## Additional resources
149 1 Francisco Javier Solans Benedí
150 2 Francisco Javier Solans Benedí
* https://www.keycloak.org/
151
* https://www.keycloak.org/server/enabletls 
152
* https://www.keycloak.org/server/configuration