Proyecto

General

Perfil

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

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

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 4 Francisco Javier Solans Benedí
### Data persistence modes
69 1 Francisco Javier Solans Benedí
70 6 Francisco Javier Solans Benedí
By default, 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.
71 1 Francisco Javier Solans Benedí
72 4 Francisco Javier Solans Benedí
We provide also this product with MySQL or PostgreSQL.
73 5 Francisco Javier Solans Benedí
* MySQL: Keycloak is configured with a MySQL database.
74
* PostgreSQL: Keycloak is configured with a PostgreSQL database.
75 1 Francisco Javier Solans Benedí
76 4 Francisco Javier Solans Benedí
#### MySQL
77 2 Francisco Javier Solans Benedí
78 1 Francisco Javier Solans Benedí
View service status:
79 2 Francisco Javier Solans Benedí
``` shell
80 1 Francisco Javier Solans Benedí
$ sudo systemctl status  mysql
81 3 Francisco Javier Solans Benedí
```
82 1 Francisco Javier Solans Benedí
83 2 Francisco Javier Solans Benedí
Stop service:
84
``` shell
85 1 Francisco Javier Solans Benedí
$ sudo systemctl stop mysql
86 2 Francisco Javier Solans Benedí
```
87 3 Francisco Javier Solans Benedí
88 1 Francisco Javier Solans Benedí
Start service:
89 2 Francisco Javier Solans Benedí
``` shell
90 1 Francisco Javier Solans Benedí
$ sudo systemctl start mysql
91 2 Francisco Javier Solans Benedí
```
92
93 1 Francisco Javier Solans Benedí
Access the MySQL console from your terminal:
94 2 Francisco Javier Solans Benedí
``` shell
95 1 Francisco Javier Solans Benedí
$ sudo mysql
96 2 Francisco Javier Solans Benedí
```
97
98 4 Francisco Javier Solans Benedí
#### PostgreSQL
99 2 Francisco Javier Solans Benedí
100 1 Francisco Javier Solans Benedí
View service status:
101 2 Francisco Javier Solans Benedí
``` shell
102 1 Francisco Javier Solans Benedí
$ sudo systemctl status  postgresql
103 2 Francisco Javier Solans Benedí
```
104 1 Francisco Javier Solans Benedí
105 2 Francisco Javier Solans Benedí
Stop service:
106
``` shell
107 1 Francisco Javier Solans Benedí
$ sudo systemctl stop postgresql
108 2 Francisco Javier Solans Benedí
```
109 1 Francisco Javier Solans Benedí
110 2 Francisco Javier Solans Benedí
Start service:
111
``` shell
112 1 Francisco Javier Solans Benedí
$ sudo systemctl start postgresql
113
```
114 2 Francisco Javier Solans Benedí
115
Access the MySQL console from your terminal:
116 1 Francisco Javier Solans Benedí
``` shell
117
$ sudo -u postgres psql
118 4 Francisco Javier Solans Benedí
```
119 1 Francisco Javier Solans Benedí
120 2 Francisco Javier Solans Benedí
## Other useful data
121
122
**Location of sensitive information**
123 1 Francisco Javier Solans Benedí
All the information is saved in the database.
124
125
In MySQL the data folder is /var/lib/mysql
126
In PostgreSQL the data folder is /var/lib/pgsql/data
127
128 2 Francisco Javier Solans Benedí
**Encryption configuration**
129 1 Francisco Javier Solans Benedí
There is no encrypted data.
130
131 2 Francisco Javier Solans Benedí
**Changing system credentials**
132 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.
133
134 2 Francisco Javier Solans Benedí
**Instructions on how the user interacts with Keycloak to decrypt necessary data**
135 1 Francisco Javier Solans Benedí
You can use the Keycloak management console to view all necessary data.
136
137 2 Francisco Javier Solans Benedí
**How to assess and monitor the health and proper function of the application.**
138 1 Francisco Javier Solans Benedí
1. Navigate to your Amazon EC2 console and verify that you're in the correct region.
139
2. Choose Instance and select your launched instance.
140
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.
141
142 2 Francisco Javier Solans Benedí
## Additional resources
143 1 Francisco Javier Solans Benedí
144 2 Francisco Javier Solans Benedí
* https://www.keycloak.org/
145
* https://www.keycloak.org/server/enabletls 
146
* https://www.keycloak.org/server/configuration