Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve documentation of managed resources #1186

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]
### Added
- Improve documentation of managed resources, particularly user federations [#826](https://github.com/adorsys/keycloak-config-cli/issues/826)
### Added
- improved logging for realm retrieval errors [#1010](https://github.com/adorsys/keycloak-config-cli/issues/1010)
### Fixed
- Fix required action import handling for no-delete option [#834](https://github.com/adorsys/keycloak-config-cli/issues/834)
Expand Down
83 changes: 79 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,35 @@
[![codecov](https://codecov.io/gh/adorsys/keycloak-config-cli/branch/main/graph/badge.svg)](https://codecov.io/gh/adorsys/keycloak-config-cli)
[![GitHub license](https://img.shields.io/github/license/adorsys/keycloak-config-cli)](https://github.com/adorsys/keycloak-config-cli/blob/main/LICENSE.txt)

# Table of Contents
- [Config Files](#config-files)
- [Variable Substitution](#variable-substitution)
- [Supported Substitutions](#supported-substitutions)
- [Logging](#logging)
- [JSON Logging Support](#json-logging-support)
- [Log Level](#log-level)
- [Supported Features](#supported-features)
- [Compatibility with Keycloak](#compatibility-with-keycloak)
- [Build this Project](#build-this-project)
- [Run Integration Tests](#run-integration-tests)
- [Run this Project](#run-this-project)
- [Docker](#docker)
- [Helm](#helm)
- [Configuration](#configuration)
- [CLI Options / Environment Variables](#cli-options--environment-variables)
- [Keycloak Options](#keycloak-options)
- [Import Options](#import-options)
- [Spring Boot Options](#spring-boot-options)
- [Perform Release](#perform-release)
- [Commercial Support](#commercial-support)

- [How keycloak-config-cli Tracks Resources](#how-keycloak-config-cli-tracks-resources)
- [Default Behavior](#default-behavior)
- [Customizing Resource Management](#customizing-resource-management)
- [Impact on User Federations](#impact-on-user-federations)
- [Example Configuration](#example-configuration)


# keycloak-config-cli

keycloak-config-cli is a Keycloak utility to ensure the desired configuration state for a realm based on a JSON/YAML file. The format of the JSON/YAML file based on the export realm format. Store and handle the configuration files inside git just like normal code. A Keycloak restart isn't required to apply the configuration.
Expand Down Expand Up @@ -63,13 +92,28 @@ keycloak-config-cli supports logging in JSON format. To enable, set `SPRING_PROF

## Log level

## Log Level Configuration

The following options allow you to configure the logging levels for different components of the `keycloak-config-cli`. Adjust these settings to control the verbosity of logs generated during execution.

| CLI Option | ENV Variable | Description | Default |
|-------------------------------------|---------------------------------|--------------------------------------------------------------------------------------|-------------------------------|
| --logging.level.root | LOGGING_LEVEL_ROOT | define the root log level | `info` |
| --logging.level.keycloak-config-cli | LOGGING_LEVEL_KEYCLOAKCONFIGCLI | log level of keycloak-config-cli components | value of `logging.level.root` |
| --logging.level.http | LOGGING_LEVEL_HTTP | log level http requests between keycloak-config-cli and Keycloak | value of `logging.level.root` |
| --logging.level.realm-config | LOGGING_LEVEL_REALMCONFIG | if set to trace, the realm config including **sensitive information** will be logged | value of `logging.level.root` |
| `--logging.level.root` | `LOGGING_LEVEL_ROOT` | Define the root log level. This setting applies to all loggers unless overridden. | `info` |
| `--logging.level.keycloak-config-cli` | `LOGGING_LEVEL_KEYCLOAKCONFIGCLI` | Log level for keycloak-config-cli components. This can be set to `trace`, `debug`, `info`, `warn`, or `error`. | Value of `logging.level.root` |
| `--logging.level.http` | `LOGGING_LEVEL_HTTP` | Log level for HTTP requests between keycloak-config-cli and Keycloak. | Value of `logging.level.root` |
| `--logging.level.realm-config` | `LOGGING_LEVEL_REALMCONFIG` | If set to `trace`, logs detailed information about realm configuration, including **sensitive information**. | Value of `logging.level.root` |

### Example Usage

To set the logging level for the Keycloak configuration CLI to debug, you can use the following command:

```shell
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please the closing of this code block is not clear.

java -jar ./target/keycloak-config-cli.jar \
--logging.level.keycloak-config-cli=debug \
--keycloak.url=http://localhost:8080 \
--keycloak.user=admin \
--keycloak.password=admin123 \
--import.files.locations=./contrib/example-config/moped.json
# Supported features

See: [docs/FEATURES.md](./docs/FEATURES.md)
Expand Down Expand Up @@ -295,3 +339,34 @@ git push --follow-tags
# Commercial support

Checkout https://adorsys.com/en/products/keycloak-config-cli/ for commercial support.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# Resource Management in keycloak-config-cli

## How keycloak-config-cli Tracks Resources

- keycloak-config-cli (kcc) stores information about resources it creates as realm attributes in the Keycloak database.
- This tracking mechanism allows kcc to manage these resources in subsequent runs.

## Default Behavior

- By default, kcc will delete and recreate resources that it initially created in previous runs.
- This ensures that the Keycloak configuration always matches the state defined in your configuration files.

## Customizing Resource Management

- The `import.managed.*` family of properties allows you to customize this behavior.
- Setting these properties to `no-delete` will prevent kcc from deleting resources, even if they're no longer present in your configuration files.

## Impact on User Federations

- This behavior applies to user federations (such as LDAP and Active Directory).
- When a user federation is deleted and recreated, all users created by that federation will also be deleted.
- This includes associated data like offline tokens.

## Example Configuration

To prevent deletion of specific resources:

```properties
import.managed.authentication-flow=no-delete
import.managed.user-federation=no-delete
Loading