-
-
Notifications
You must be signed in to change notification settings - Fork 7
7. Keycloak Setup
Keycloak is an open-source identity and access management solution that allows you to secure your applications and services. This guide will walk you through the setup process for Keycloak.
Before you begin, make sure you have the following prerequisites in place:
-
Java: Keycloak is built on Java, so you need to have Java Development Kit (JDK) installed on your system. You can download it from Oracle or use OpenJDK.
-
Database: Keycloak requires a database to store its configuration and user data. You can use databases like PostgreSQL, MySQL, or H2 (for development purposes).
-
WildFly (Optional): If you want to deploy Keycloak as a standalone server, you can use WildFly as the application server. Download it from the WildFly website.
Follow these steps to set up Keycloak:
-
Download Keycloak: Go to the Keycloak Downloads page and download the latest stable release.
-
Extract the Archive: Extract the downloaded archive to your desired location on your server.
-
Configure the Database: Depending on your chosen database, you'll need to set up a database and configure Keycloak to use it. Refer to the official Keycloak documentation for database-specific instructions.
-
Configure Standalone.xml (WildFly): If you're using WildFly, open the
standalone/configuration/standalone.xml
file and configure the Keycloak subsystem. Refer to the Keycloak documentation for detailed instructions. -
Start Keycloak: Start Keycloak by running the appropriate script for your operating system. For example, on Unix-based systems, you can run:
bin/standalone.sh
On Windows:
bin/standalone.bat
-
Access the Admin Console: Once Keycloak is up and running, you can access the admin console by navigating to http://localhost:8080/auth/admin/ in your web browser. You can log in with the admin credentials you set during the initial setup.
-
Create Realms and Clients: In the admin console, you can create realms to separate your applications' security domains and configure clients for your applications.
-
Integrate Applications: Integrate your applications with Keycloak for authentication and authorization. Keycloak provides various client libraries and adapters for different platforms and languages.
-
User Management: You can manage users, roles, and groups through the admin console or Keycloak's REST API.
To run Keycloak in a Docker container, follow these steps:
- Pull the Keycloak Docker Image: Open your terminal and run the following command to pull the official Keycloak Docker image:
docker pull jboss/keycloak
- Create a Docker Network (Optional): You can create a Docker network to isolate Keycloak from other containers if needed:
docker network create keycloak-network
- Run Keycloak Container: Start a Keycloak container using the following command:
docker run -d --name keycloak \
-e KEYCLOAK_USER=admin \
-e KEYCLOAK_PASSWORD=admin \
-p 8090:8080 \
--network keycloak-network \
jboss/keycloak
- Access the Admin Console: Once the container is running, you can access the Keycloak admin console by navigating to http://localhost:8090 in your web browser. Use the admin credentials you set during container startup.
Note: If you use
docker-compose
, please skip the above steps
If you install Keycloak using Docker, you won't need to create a new administration account because there is already one with the username admin
and the password admin
. Your admin console will appear as follows:
Note: If you are utilizing Docker Compose in your project, all the necessary configurations will be automatically imported into your Keycloak server. Therefore, you can skip all the steps for configuring Keycloak below if you prefer not to configure it manually.
Role | Description |
---|---|
Admin | Admins manage operations, user accounts, and technology for smooth business functioning |
Driver | Drivers operate vehicles for transportation |
Stoker | Stokers tend to fires to produce steam or heat |
Officer | Officers enforce rules and regulations |
Customer | Customers make purchases or receive services |
If you found this documentation helpful, please consider giving it a ⭐️ on GitHub.
🐛 Found a bug or have a suggestion? Report an issue.
📣 Have questions or need support? Visit our Support Section.