keycloak-config-cli icon indicating copy to clipboard operation
keycloak-config-cli copied to clipboard

Improve config validation and editing

Open thomasdarimont opened this issue 1 year ago • 6 comments

Problem Statement

Currently keycloak-config-cli can detect configuration errors like missing or unknown attribute only when running against keycloak. Also when editing config files, user have to know upfront which properties are supported which is errorprone and time consuming.

Proposed Solution

It would be helpful if there were some schema support to help with the validation during editing. The schema could also be used to provide code completion in IDEs (vscode and intellij).

One way to implement this is to extract the schemes for the representations from the https://www.keycloak.org/docs-api/latest/rest-api/openapi.json OpenAPI spec and use it to validate the configuration file.

It might be necessary to generate Keycloak version specific schema files. Additionally the user should be able to supply the used Keycloak version to automatically use the proper schema file.

keycloak-config-cli should provide a "lint" command to check the configuration for potential unsupported / misspell properties.

Environment

no_response

Additional information

YAML validation with JSON Schema in IntelliJ YAML validation with JSON Schema in vscode

Acceptance Criteria

Configuration files can be validated automatically before applying a configuration against a Keycloak environment. Users can get auto-completion for allowed configuration properities.

thomasdarimont avatar Aug 06 '24 14:08 thomasdarimont

Hello @thomasdarimont.

Did you do any progess on this ticket or should we work on this. If yes, we will start reseaching on how to infer a json schema from an openapi file.

Motouom avatar Dec 16 '24 09:12 Motouom

I didn't have time to work on this. Feel free to give this a spin!

thomasdarimont avatar Dec 16 '24 09:12 thomasdarimont

Hello @thomasdarimont

I have already done most of the validations config and editing, I just have a few other validations(specific validations to add. I wish to ask if you have any idea on wether we can do it in such a way that, once the user opens the JSON or yaml config file, it should automatically be set to the JSON schema that is meant to kc-cli?

Motouom avatar Dec 16 '24 15:12 Motouom

Thanks for picking this up. Regarding the config schema validation: Have you tried this in intelliJ? https://www.jetbrains.com/help/idea/yaml.html#use-schema-keyword

thomasdarimont avatar Feb 04 '25 09:02 thomasdarimont

Yes @thomasdarimont, i have tried it already and it is working, Even on vs code.

i was wondering if there was a way we could integrate the schema in the IDE other than the way it is done in IntelliJ by configuring it.

for example:

  • creating a URL for the json schema that can be accessible to everyone.
  • creating some sort of an extension.

i would like to have you thoughts on it.

Motouom avatar Feb 04 '25 09:02 Motouom

Hello @thomasdarimont, @Thendo20 , @AssahBismarkabah please can you review this #1331? I will close the last PR(#1268).

Motouom avatar Oct 22 '25 09:10 Motouom