Keycloak

Форк
0
/
configuration-provider.adoc 
90 строк · 4.4 Кб
1
<#import "/templates/guide.adoc" as tmpl>
2
<#import "/templates/kc.adoc" as kc>
3
<#import "/templates/options.adoc" as opts>
4
<#import "/templates/links.adoc" as links>
5

6
<@tmpl.guide
7
title="Configuring providers"
8
summary="Understand how to configure providers">
9

10
The server is built with extensibility in mind and for that it provides a number of Service Provider Interfaces or SPIs, each one
11
responsible for providing a specific capability to the server. In this {section}, you are going to understand the core concepts around
12
the configuration of SPIs and their respective providers.
13

14
After reading this {section}, you should be able to use the concepts and the steps herein explained to install, uninstall, enable, disable, and configure
15
any provider, including those you have implemented to extend the server capabilities in order to better fulfill your requirements.
16

17
== Configuration option format
18

19
Providers can be configured by using a specific configuration format. The format consists of:
20

21
[source]
22
----
23
spi-<spi-id>-<provider-id>-<property>=<value>
24
----
25

26
The `<spi-id>` is the name of the SPI you want to configure.
27

28
The `<provider-id>` is the id of the provider you want to configure. This is the id set to the corresponding provider factory implementation.
29

30
The `<property>` is the actual name of the property you want to set for a given provider.
31

32
All those names (for spi, provider, and property) should be in lower case and if the name is in camel-case such as `myKeycloakProvider`, it should include dashes (`-`) before upper-case letters as follows: `my-keycloak-provider`.
33

34
Taking the `HttpClientSpi` SPI as an example, the name of the SPI is `connectionsHttpClient` and one of the provider implementations available is named `default`. In order to set the `connectionPoolSize` property you would use a configuration option as follows:
35

36
[source]
37
----
38
spi-connections-http-client-default-connection-pool-size=10
39
----
40

41
== Setting a provider configuration option
42

43
Provider configuration options are provided when starting the server. See all support configuration sources and formats for options in <@links.server id="configuration"/>. For example via a command line option:
44

45
.Setting the `connection-pool-size` for the `default` provider of the `connections-http-client` SPI
46
<@kc.start parameters="--spi-connections-http-client-default-connection-pool-size=10"/>
47

48
== Configuring a default provider
49

50
Depending on the SPI, multiple provider implementations can co-exist but only one of them is going to be used at runtime.
51
For these SPIs, a default provider is the primary implementation that is going to be active and used at runtime.
52

53
To configure a provider as the default you should run the `build` command as follows:
54

55
.Marking the `mycustomprovider` provider as the default provider for the `email-template` SPI
56
<@kc.build parameters="--spi-email-template-provider=mycustomprovider"/>
57

58
In the example above, we are using the `provider` property to set the id of the provider we want to mark as the default.
59

60
== Enabling and disabling a provider
61

62
To enable or disable a provider you should run the `build` command as follows:
63

64
.Enabling a provider
65
<@kc.build parameters="--spi-email-template-mycustomprovider-enabled=true"/>
66

67
To disable a provider, use the same command and set the `enabled` property to `false`.
68

69
== Installing and uninstalling a provider
70

71
Custom providers should be packaged in a Java Archive (JAR) file and copied to the `providers` directory of the distribution. After that,
72
you must run the `build` command in order to update the server's provider registry with the implementations from the JAR file.
73

74
This step is needed in order to optimize the server runtime so that all providers are known ahead-of-time rather than discovered only when starting the server or at runtime.
75

76
To uninstall a provider, you should remove the JAR file from the `providers` directory and run the `build` command again.
77

78
== Using third-party dependencies
79

80
When implementing a provider you might need to use some third-party dependency that is not available from the server distribution.
81

82
In this case, you should copy any additional dependency to the `providers` directory and run the `build` command.
83
Once you do that, the server is going to make these additional dependencies available at runtime for any provider that depends on them.
84

85
== References
86

87
* <@links.server id="configuration"/>
88
* https://www.keycloak.org/docs/latest/server_development/#_providers[Server Developer Documentation]
89

90
</@tmpl.guide>
91

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.