Skip to content

Commit 0f33aae

Browse files
authored
Merge branch 'main' into master
2 parents a00043e + 0e8f2d7 commit 0f33aae

15 files changed

+983
-49
lines changed

.github/workflows/test.yml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,6 @@ jobs:
3434
make vet
3535
make fmtcheck
3636
37-
# we only want to run tests if any code changes (not for README or docs changes)
38-
- name: Check Changed Files
39-
id: files
40-
uses: tj-actions/changed-files@v45
41-
with:
42-
files: |
43-
.github
44-
go.mod
45-
go.sum
46-
main.go
47-
keycloak
48-
provider
49-
scripts
50-
5137
outputs:
5238
code-files-changed: steps.files.outputs.any_changed
5339

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
---
2+
page_title: "keycloak_openid_client_authorization_client_scope_policy Resource"
3+
---
4+
5+
# keycloak\_openid\_client\_authorization\_client\_scope\_policy Resource
6+
7+
Allows you to manage openid Client Authorization Client Scope type Policies.
8+
9+
## Example Usage
10+
11+
```hcl
12+
resource "keycloak_realm" "realm" {
13+
realm = "my-realm"
14+
enabled = true
15+
}
16+
17+
resource "keycloak_openid_client" "test" {
18+
client_id = "client_id"
19+
realm_id = keycloak_realm.realm.id
20+
access_type = "CONFIDENTIAL"
21+
service_accounts_enabled = true
22+
authorization {
23+
policy_enforcement_mode = "ENFORCING"
24+
}
25+
}
26+
27+
resource "keycloak_openid_client_scope" "test1" {
28+
realm_id = keycloak_realm.realm.id
29+
name = "test1"
30+
description = "test1"
31+
}
32+
33+
resource "keycloak_openid_client_scope" "test2" {
34+
realm_id = keycloak_realm.realm.id
35+
name = "test2"
36+
description = "test2"
37+
}
38+
39+
resource "keycloak_openid_client_authorization_client_scope_policy" "test" {
40+
resource_server_id = keycloak_openid_client.test.resource_server_id
41+
realm_id = keycloak_realm.realm.id
42+
name = "test_policy_single"
43+
description = "test"
44+
decision_strategy = "AFFIRMATIVE"
45+
logic = "POSITIVE"
46+
47+
scope {
48+
id = keycloak_openid_client_scope.test1.id
49+
required = false
50+
}
51+
}
52+
53+
resource "keycloak_openid_client_authorization_client_scope_policy" "test_multiple" {
54+
resource_server_id = keycloak_openid_client.test.resource_server_id
55+
realm_id = keycloak_realm.realm.id
56+
name = "test_policy_multiple"
57+
description = "test"
58+
decision_strategy = "AFFIRMATIVE"
59+
logic = "POSITIVE"
60+
61+
scope {
62+
id = keycloak_openid_client_scope.test1.id
63+
required = false
64+
}
65+
66+
scope {
67+
id = keycloak_openid_client_scope.test2.id
68+
required = true
69+
}
70+
}
71+
72+
```
73+
74+
### Argument Reference
75+
76+
The following arguments are supported:
77+
78+
- `realm_id` - (Required) The realm this group exists in.
79+
- `resource_server_id` - (Required) The ID of the resource server.
80+
- `name` - (Required) The name of the policy.
81+
- `description` - (Optional) A description for the authorization policy.
82+
- `decision_strategy` - (Optional) The decision strategy, can be one of `UNANIMOUS`, `AFFIRMATIVE`, or `CONSENSUS`. Defaults to `UNANIMOUS`.
83+
- `logic` - (Optional) The logic, can be one of `POSITIVE` or `NEGATIVE`. Defaults to `POSITIVE`.
84+
- `scope` - An client scope to add [client scope](#scope-arguments). At least one should be defined.
85+
86+
### Scope Arguments
87+
88+
- `id` - (Required) Id of client scope.
89+
- `required` - (Optional) When `true`, then this client scope will be set as required. Defaults to `false`.
90+
91+
### Attributes Reference
92+
93+
In addition to the arguments listed above, the following computed attributes are exported:
94+
95+
- `id` - Policy ID representing the policy.
96+
97+
## Import
98+
99+
Client authorization policies can be imported using the format: `{{realmId}}/{{resourceServerId}}/{{policyId}}`.
100+
101+
Example:
102+
103+
```bash
104+
$ terraform import keycloak_openid_client_authorization_client_scope_policy.test my-realm/3bd4a686-1062-4b59-97b8-e4e3f10b99da/63b3cde8-987d-4cd9-9306-1955579281d9
105+
```
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
page_title: "keycloak_realm_localization Resource"
3+
---
4+
5+
# keycloak_realm_localization Resource
6+
7+
Allows for managing Realm Localization Text overrides within Keycloak.
8+
9+
A localization resource defines a schema for representing a locale with a map of key/value pairs and how they are managed within a realm.
10+
11+
Note: whilst you can provide localization texts for unsupported locales, they will not take effect until they are defined within the realm resource.
12+
13+
## Example Usage
14+
15+
```hcl
16+
resource "keycloak_realm" "realm" {
17+
realm = "my-realm"
18+
}
19+
20+
resource "keycloak_realm_localization" "german_texts" {
21+
realm_id = keycloak_realm.my_realm.id
22+
locale = "de"
23+
texts = {
24+
"Hello" : "Hallo"
25+
}
26+
}
27+
```
28+
29+
## Argument Reference
30+
31+
- `realm_id` - (Required) The ID of the realm the user profile applies to.
32+
- `locale` - (Required) The locale (language code) the texts apply to.
33+
- `texts` - (Optional) A map of translation keys to values.
34+
35+
36+
## Import
37+
38+
This resource does not currently support importing.

example/main.tf

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,14 @@ resource "keycloak_realm" "test" {
101101
}
102102
}
103103

104+
resource "keycloak_realm_localization" "test_translation" {
105+
realm_id = keycloak_realm.test.id
106+
locale = "en"
107+
texts = {
108+
"test" : "translation"
109+
}
110+
}
111+
104112
resource "keycloak_required_action" "custom-terms-and-conditions" {
105113
realm_id = keycloak_realm.test.realm
106114
alias = "TERMS_AND_CONDITIONS"
@@ -116,7 +124,7 @@ resource "keycloak_required_action" "update-password" {
116124
enabled = true
117125
name = "Update Password"
118126

119-
config {
127+
config = {
120128
max_auth_age = "600"
121129
}
122130
}
@@ -439,25 +447,25 @@ resource "keycloak_ldap_full_name_mapper" "full_name_mapper" {
439447
}
440448

441449
resource "keycloak_ldap_custom_mapper" "custom_mapper" {
442-
name = "custom-mapper"
443-
realm_id = keycloak_ldap_user_federation.openldap.realm_id
444-
ldap_user_federation_id = keycloak_ldap_user_federation.openldap.id
450+
name = "custom-mapper"
451+
realm_id = keycloak_ldap_user_federation.openldap.realm_id
452+
ldap_user_federation_id = keycloak_ldap_user_federation.openldap.id
445453

446-
provider_id = "msad-user-account-control-mapper"
447-
provider_type = "org.keycloak.storage.ldap.mappers.LDAPStorageMapper"
454+
provider_id = "msad-user-account-control-mapper"
455+
provider_type = "org.keycloak.storage.ldap.mappers.LDAPStorageMapper"
448456
}
449457

450458
resource "keycloak_ldap_custom_mapper" "custom_mapper_with_config" {
451-
name = "custom-mapper-with-config"
452-
realm_id = keycloak_ldap_user_federation.openldap.realm_id
453-
ldap_user_federation_id = keycloak_ldap_user_federation.openldap.id
454-
455-
provider_id = "user-attribute-ldap-mapper"
456-
provider_type = "org.keycloak.storage.ldap.mappers.LDAPStorageMapper"
457-
config = {
458-
"user.model.attribute" = "username"
459-
"ldap.attribute" = "cn"
460-
}
459+
name = "custom-mapper-with-config"
460+
realm_id = keycloak_ldap_user_federation.openldap.realm_id
461+
ldap_user_federation_id = keycloak_ldap_user_federation.openldap.id
462+
463+
provider_id = "user-attribute-ldap-mapper"
464+
provider_type = "org.keycloak.storage.ldap.mappers.LDAPStorageMapper"
465+
config = {
466+
"user.model.attribute" = "username"
467+
"ldap.attribute" = "cn"
468+
}
461469
}
462470

463471

go.mod

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/hashicorp/go-version v1.7.0
99
github.com/hashicorp/terraform-plugin-log v0.9.0
1010
github.com/hashicorp/terraform-plugin-sdk/v2 v2.35.0
11-
golang.org/x/net v0.33.0
11+
golang.org/x/net v0.36.0
1212
)
1313

1414
require (
@@ -46,11 +46,11 @@ require (
4646
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
4747
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
4848
github.com/zclconf/go-cty v1.15.0 // indirect
49-
golang.org/x/crypto v0.31.0 // indirect
49+
golang.org/x/crypto v0.35.0 // indirect
5050
golang.org/x/mod v0.21.0 // indirect
51-
golang.org/x/sync v0.10.0 // indirect
52-
golang.org/x/sys v0.28.0 // indirect
53-
golang.org/x/text v0.21.0 // indirect
51+
golang.org/x/sync v0.11.0 // indirect
52+
golang.org/x/sys v0.30.0 // indirect
53+
golang.org/x/text v0.22.0 // indirect
5454
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
5555
google.golang.org/appengine v1.6.8 // indirect
5656
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
@@ -59,3 +59,4 @@ require (
5959
)
6060

6161
go 1.22.0
62+
toolchain go1.23.7

go.sum

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,22 +147,22 @@ github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940 h1:4r45xpDWB6
147147
github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940/go.mod h1:CmBdvvj3nqzfzJ6nTCIwDTPZ56aVGvDrmztiO5g3qrM=
148148
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
149149
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
150-
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
151-
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
150+
golang.org/x/crypto v0.35.0 h1:b15kiHdrGCHrP6LvwaQ3c03kgNhhiMgvlhxHQhmg2Xs=
151+
golang.org/x/crypto v0.35.0/go.mod h1:dy7dXNW32cAb/6/PRuTNsix8T+vJAqvuIy5Bli/x0YQ=
152152
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
153153
golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0=
154154
golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
155155
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
156156
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
157157
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
158158
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
159-
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
160-
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
159+
golang.org/x/net v0.36.0 h1:vWF2fRbw4qslQsQzgFqZff+BItCvGFQqKzKIzx1rmoA=
160+
golang.org/x/net v0.36.0/go.mod h1:bFmbeoIPfrw4sMHNhb4J9f6+tPziuGjq7Jk/38fxi1I=
161161
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
162162
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
163163
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
164-
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
165-
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
164+
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
165+
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
166166
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
167167
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
168168
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -175,19 +175,19 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
175175
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
176176
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
177177
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
178-
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
179-
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
178+
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
179+
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
180180
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
181181
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
182-
golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q=
183-
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
182+
golang.org/x/term v0.29.0 h1:L6pJp37ocefwRRtYPKSWOWzOtWSxVajvz2ldH/xi3iU=
183+
golang.org/x/term v0.29.0/go.mod h1:6bl4lRlvVuDgSf3179VpIxBF0o10JUpXWOnI7nErv7s=
184184
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
185185
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
186186
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
187187
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
188188
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
189-
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
190-
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
189+
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
190+
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
191191
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
192192
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
193193
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=

keycloak/keycloak_client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"crypto/x509"
88
"encoding/json"
99
"fmt"
10-
"github.com/hashicorp/terraform-plugin-log/tflog"
1110
"io"
1211
"net/http"
1312
"net/http/cookiejar"
@@ -18,6 +17,7 @@ import (
1817
"time"
1918

2019
"github.com/hashicorp/go-version"
20+
"github.com/hashicorp/terraform-plugin-log/tflog"
2121

2222
"golang.org/x/net/publicsuffix"
2323

@@ -293,7 +293,7 @@ func (keycloakClient *KeycloakClient) addRequestHeaders(request *http.Request) {
293293
request.Header.Set("User-Agent", keycloakClient.userAgent)
294294
}
295295

296-
if request.Method == http.MethodPost || request.Method == http.MethodPut || request.Method == http.MethodDelete {
296+
if request.Header.Get("Content-type") == "" && (request.Method == http.MethodPost || request.Method == http.MethodPut || request.Method == http.MethodDelete) {
297297
request.Header.Set("Content-type", "application/json")
298298
}
299299
}

0 commit comments

Comments
 (0)