Skip to content

Commit 1e252e5

Browse files
authored
BREAKING: Support Keycloak 25 (#316)
* BREAKING: Support Keycloak 25 See README for details on breaking changes * Use OpenJDK 21 except for Debian
1 parent 3b639d2 commit 1e252e5

File tree

26 files changed

+183
-319
lines changed

26 files changed

+183
-319
lines changed

.github/workflows/ci.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ jobs:
1616
fail-fast: false
1717
matrix:
1818
include:
19-
- ruby: 2.7.7
19+
- ruby: 2.7.8
2020
puppet: 7
2121
fixtures: .fixtures.yml
2222
allow_failure: false
23-
- ruby: 3.2.2
23+
- ruby: 3.2.3
2424
puppet: 8
2525
fixtures: .fixtures.yml
2626
allow_failure: false
@@ -65,17 +65,17 @@ jobs:
6565
- "puppet7"
6666
- "puppet8"
6767
keycloak_version:
68-
- "24.0.5"
68+
- "25.0.1"
6969
keycloak_full:
7070
- "no"
7171
include:
7272
- set: "el8"
7373
puppet: "puppet7"
74-
keycloak_version: "24.0.5"
74+
keycloak_version: "25.0.1"
7575
keycloak_full: "yes"
7676
- set: "el8"
7777
puppet: "puppet8"
78-
keycloak_version: "24.0.5"
78+
keycloak_version: "25.0.1"
7979
keycloak_full: "yes"
8080
env:
8181
BUNDLE_WITHOUT: development:release

.sync.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ Rakefile:
2525
- puppet7
2626
- puppet8
2727
keycloak_version:
28-
- '24.0.5'
28+
- '25.0.1'
2929
keycloak_full: ['no']
3030
acceptance_includes:
3131
- set: el8
3232
puppet: puppet7
33-
keycloak_version: '24.0.5'
33+
keycloak_version: '25.0.1'
3434
keycloak_full: 'yes'
3535
- set: el8
3636
puppet: puppet8
37-
keycloak_version: '24.0.5'
37+
keycloak_version: '25.0.1'
3838
keycloak_full: 'yes'
3939
.gitignore:
4040
paths:

README.md

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#### Table of Contents
77

88
1. [Overview](#overview)
9+
* [Upgrade to 12.x](#upgrade-to-12x)
910
* [Upgrade to 8.x](#upgrade-to-8x)
1011
* [Changes to LDAP user provider IDs](#changes-to-ldap-user-provider-ids)
1112
* [Supported Versions of Keycloak](#supported-versions-of-keycloak)
@@ -35,6 +36,25 @@
3536

3637
The keycloak module allows easy installation and management of Keycloak.
3738

39+
### Upgrade to 12.x
40+
41+
Version 12.x of this module had some major breaking changes to support Keycloak 25.x.
42+
43+
The default Java version is now OpenJDK 21 except for Debian. The next major release will drop Debian support unless OpenJDK 21 is added to Debian repos.
44+
45+
The `keycloak_flow` and `keycloak_flow_execution` types had their `index` property replaced by `priority`. If you had executions with `index` 0,1,2 you'd need to set `priority` to something like 10,20,30.
46+
47+
The configuration options switched to using Hostname v2 options.
48+
49+
* `hostname` now accepts a URL
50+
* `hostname-url` is removed
51+
* `hostname-path` is removed
52+
* `hostname-port` is removed
53+
* `hostname-admin` now requires a URL
54+
* `hostname-admin-url` is removed
55+
* `hostname-strict-backchannel` is renamed to `hostname-backchannel-dynamic`
56+
* `hostname-strict-https` is removed
57+
3858
### Upgrade to 8.x
3959

4060
This module underwent major changes in the 8.0.0 release to support Keycloak that uses Quarkus.
@@ -176,7 +196,7 @@ This module may work on earlier versions but this is the only version tested.
176196
| 19.x - 21.x | 9.x |
177197
| 21.x | 10.x |
178198
| 22.x - 24.x | 11.x |
179-
| 24.x | 12.x |
199+
| 25.x | 12.x |
180200
| -----------------|---------------------------------|
181201

182202
## Usage
@@ -523,27 +543,27 @@ keycloak_flow_execution { 'auth-cookie under browser-with-duo on test':
523543
ensure => 'present',
524544
configurable => false,
525545
display_name => 'Cookie',
526-
index => 0,
546+
priority => 10,
527547
requirement => 'ALTERNATIVE',
528548
}
529549
keycloak_flow_execution { 'identity-provider-redirector under browser-with-duo on test':
530550
ensure => 'present',
531551
configurable => true,
532552
display_name => 'Identity Provider Redirector',
533-
index => 1,
553+
priority => 15,
534554
requirement => 'ALTERNATIVE',
535555
}
536556
keycloak_flow { 'form-browser-with-duo under browser-with-duo on test':
537557
ensure => 'present',
538-
index => 2,
558+
priority => 20,
539559
requirement => 'ALTERNATIVE',
540560
top_level => false,
541561
}
542562
keycloak_flow_execution { 'auth-username-password-form under form-browser-with-duo on test':
543563
ensure => 'present',
544564
configurable => false,
545565
display_name => 'Username Password Form',
546-
index => 0,
566+
priority => 10,
547567
requirement => 'REQUIRED',
548568
}
549569
keycloak_flow_execution { 'duo-universal under form-browser-with-duo on test':
@@ -558,7 +578,7 @@ keycloak_flow_execution { 'duo-universal under form-browser-with-duo on test':
558578
"duoGroups" => "duo"
559579
},
560580
requirement => 'REQUIRED',
561-
index => 1,
581+
priority => 15,
562582
}
563583
```
564584

data/os/Debian.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
2-
keycloak::java_package: openjdk-17-jdk
3-
keycloak::java_home: /usr/lib/jvm/java-1.17.0-openjdk-amd64/
4-
keycloak::java_alternative_path: /usr/lib/jvm/java-1.17.0-openjdk-amd64/bin/java
5-
keycloak::java_alternative: java-1.17.0-openjdk-amd64
2+
keycloak::java_package: openjdk-21-jdk
3+
keycloak::java_home: /usr/lib/jvm/java-1.21.0-openjdk-amd64/
4+
keycloak::java_alternative_path: /usr/lib/jvm/java-1.21.0-openjdk-amd64/bin/java
5+
keycloak::java_alternative: java-1.21.0-openjdk-amd64
66
keycloak::user_shell: '/usr/sbin/nologin'
77
keycloak::libunix_dbus_java_build_dependencies:
88
- 'zlib1g-dev'

data/os/Debian/11.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
---
22
keycloak::java_package_dependencies:
33
- ca-certificates-java
4+
keycloak::java_package: openjdk-17-jdk
5+
keycloak::java_home: /usr/lib/jvm/java-1.17.0-openjdk-amd64/
6+
keycloak::java_alternative_path: /usr/lib/jvm/java-1.17.0-openjdk-amd64/bin/java
7+
keycloak::java_alternative: java-1.17.0-openjdk-amd64

data/os/RedHat.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
2-
keycloak::java_package: java-17-openjdk-devel
3-
keycloak::java_home: /usr/lib/jvm/java-17-openjdk/
4-
keycloak::java_alternative_path: /usr/lib/jvm/java-17-openjdk/bin/java
5-
keycloak::java_alternative: /usr/lib/jvm/java-17-openjdk/bin/java
2+
keycloak::java_package: java-21-openjdk-devel
3+
keycloak::java_home: /usr/lib/jvm/java-21-openjdk/
4+
keycloak::java_alternative_path: /usr/lib/jvm/java-21-openjdk/bin/java
5+
keycloak::java_alternative: /usr/lib/jvm/java-21-openjdk/bin/java
66
keycloak::user_shell: '/sbin/nologin'
77
keycloak::libunix_dbus_java_build_dependencies:
88
- 'which'

lib/puppet/provider/keycloak_flow/kcadm.rb

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def self.instances
6262
flow[:flow_alias] = d['alias']
6363
flow[:realm] = realm
6464
flow[:description] = e['description']
65-
flow[:index] = e['index']
65+
flow[:priority] = e['priority']
6666
flow[:display_name] = e['displayName']
6767
flow[:alias] = e['displayName']
6868
if e['level'] != 0
@@ -105,6 +105,7 @@ def create
105105
data[:provider] = resource[:type]
106106
data[:description] = resource[:description]
107107
data[:type] = resource[:provider_id]
108+
data[:priority] = resource[:priority]
108109
url = "authentication/flows/#{resource[:flow_alias]}/executions/flow"
109110
end
110111
t = Tempfile.new('keycloak_flow')
@@ -134,7 +135,8 @@ def create
134135
unless execution_id.nil?
135136
update_data = {
136137
id: execution_id,
137-
requirement: resource[:requirement]
138+
requirement: resource[:requirement],
139+
priority: resource[:priority]
138140
}
139141
t = Tempfile.new('keycloak_flow_execution')
140142
t.write(JSON.pretty_generate(update_data))
@@ -181,19 +183,6 @@ def initialize(value = {})
181183
end
182184
end
183185

184-
def current_priority
185-
data = {}
186-
begin
187-
output = kcadm('get', "authentication/executions/#{id}", resource[:realm])
188-
data = JSON.parse(output)
189-
rescue Puppet::ExecutionFailure => e
190-
Puppet.debug("kcadm get execution failed\nError message: #{e.message}")
191-
rescue JSON::ParserError
192-
Puppet.debug('Unable to parse output from kcadm get execution')
193-
end
194-
data['priority'] || resource[:index]
195-
end
196-
197186
def flush
198187
unless @property_flush.empty?
199188
data = {}
@@ -204,10 +193,11 @@ def flush
204193
data[:providerId] = resource[:provider_id]
205194
data[:topLevel] = true
206195
url = "authentication/flows/#{id}"
207-
elsif @property_flush[:requirement]
196+
elsif @property_flush[:requirement] || @property_flush[:priority]
208197
data[:id] = id
209198
data[:description] = resource[:description]
210199
data[:requirement] = resource[:requirement]
200+
data[:priority] = resource[:priority]
211201
url = "authentication/flows/#{resource[:flow_alias]}/executions"
212202
end
213203
unless data.empty?
@@ -221,22 +211,6 @@ def flush
221211
raise Puppet::Error, "kcadm update flow failed\nError message: #{e.message}"
222212
end
223213
end
224-
if resource[:top_level] == :false && @property_flush[:index]
225-
index_difference = current_priority - @property_flush[:index]
226-
if index_difference.zero?
227-
Puppet.notice("Index difference for Keycloak_flow[#{resource[:name]}] is unchanged, skipping.")
228-
elsif index_difference.negative?
229-
incrementer = 1
230-
action = 'lower-priority'
231-
else
232-
incrementer = -1
233-
action = 'raise-priority'
234-
end
235-
while index_difference != 0
236-
kcadm('create', "authentication/executions/#{id}/#{action}", resource[:realm])
237-
index_difference += incrementer
238-
end
239-
end
240214
end
241215
# Collect the resources again once they've been changed (that way `puppet
242216
# resource` will show the correct values after changes have been made).

lib/puppet/provider/keycloak_flow_execution/kcadm.rb

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def self.instances
4848
execution[:configurable] = e['configurable'].to_s.to_sym if e.key?('configurable')
4949
execution[:flow_alias] = f['alias']
5050
execution[:realm] = realm
51-
execution[:index] = e['index']
51+
execution[:priority] = e['priority']
5252
execution[:display_name] = e['displayName'] if e.key?('displayName')
5353
if e['level'] != 0
5454
parent_level = levels.find { |k, _v| k == (e['level'] - 1) }
@@ -104,6 +104,7 @@ def create
104104
data[:displayName] = resource[:display_name] if resource[:display_name]
105105
data[:configurable] = convert_property_value(resource[:configurable]) if resource[:configurable]
106106
data[:alias] = resource[:alias] if resource[:alias]
107+
data[:priority] = resource[:priority]
107108
t = Tempfile.new('keycloak_flow_execution')
108109
t.write(JSON.pretty_generate(data))
109110
t.close
@@ -117,7 +118,8 @@ def create
117118
if resource[:requirement] != 'DISABLED'
118119
update_data = {
119120
id: new_id.strip,
120-
requirement: resource[:requirement]
121+
requirement: resource[:requirement],
122+
priority: resource[:priority]
121123
}
122124
tu = Tempfile.new('keycloak_flow_execution_update')
123125
tu.write(JSON.pretty_generate(update_data))
@@ -173,25 +175,13 @@ def initialize(value = {})
173175
end
174176
end
175177

176-
def current_priority
177-
data = {}
178-
begin
179-
output = kcadm('get', "authentication/executions/#{id}", resource[:realm])
180-
data = JSON.parse(output)
181-
rescue Puppet::ExecutionFailure => e
182-
Puppet.debug("kcadm get execution failed\nError message: #{e.message}")
183-
rescue JSON::ParserError
184-
Puppet.debug('Unable to parse output from kcadm get execution')
185-
end
186-
data['priority'] || resource[:index]
187-
end
188-
189178
def flush
190179
unless @property_flush.empty?
191-
if @property_flush[:requirement]
180+
if @property_flush[:requirement] || @property_flush[:priority]
192181
data = {}
193182
data[:id] = id
194-
data[:requirement] = resource[:requirement] if @property_flush[:requirement]
183+
data[:requirement] = resource[:requirement]
184+
data[:priority] = resource[:priority]
195185
t = Tempfile.new('keycloak_flow_execution')
196186
t.write(JSON.pretty_generate(data))
197187
t.close
@@ -225,22 +215,6 @@ def flush
225215
raise Puppet::Error, "kcadm update flow execution config failed\nError message: #{e.message}"
226216
end
227217
end
228-
if @property_flush[:index]
229-
index_difference = current_priority - @property_flush[:index]
230-
if index_difference.zero?
231-
Puppet.notice("Index difference for Keycloak_flow_execution[#{resource[:name]}] is unchanged, skipping.")
232-
elsif index_difference.negative?
233-
incrementer = 1
234-
action = 'lower-priority'
235-
else
236-
incrementer = -1
237-
action = 'raise-priority'
238-
end
239-
while index_difference != 0
240-
kcadm('create', "authentication/executions/#{id}/#{action}", resource[:realm])
241-
index_difference += incrementer
242-
end
243-
end
244218
end
245219
# Collect the resources again once they've been changed (that way `puppet
246220
# resource` will show the correct values after changes have been made).

lib/puppet/type/keycloak_client.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ def insync?(is)
215215

216216
newproperty(:web_origins, array_matching: :all, parent: PuppetX::Keycloak::ArrayProperty) do
217217
desc 'webOrigins'
218-
defaultto []
219218
end
220219

221220
newproperty(:login_theme) do

0 commit comments

Comments
 (0)