Skip to content

Commit 6f4fd53

Browse files
author
Douglass Kirkley
committed
feat: Add displayHTMLName to realm resource
feat: Add displayHTMLName to realm resource feat: Add displayHTMLName to realm resource
1 parent a4331c6 commit 6f4fd53

File tree

7 files changed

+32
-3
lines changed

7 files changed

+32
-3
lines changed

api/v1/keycloakrealm_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ type KeycloakRealmSpec struct {
5656
// +optional
5757
PasswordPolicies []PasswordPolicy `json:"passwordPolicy,omitempty"`
5858

59+
// DisplayHTMlName name to render in the UI
60+
// +optional
61+
DisplayHTMLName string `json:"displayHtmlName,omitempty"`
62+
5963
// FrontendURL Set the frontend URL for the realm. Use in combination with the default hostname provider to override the base URL for frontend requests for a specific realm.
6064
// +optional
6165
FrontendURL string `json:"frontendUrl,omitempty"`

config/crd/bases/v1.edp.epam.com_keycloakrealms.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ spec:
6060
apply to HTTP responses from the realm's browser clients.
6161
nullable: true
6262
type: object
63+
displayHtmlName:
64+
description: DisplayHTMlName name to display via the frontend
65+
type: string
6366
frontendUrl:
6467
description: FrontendURL Set the frontend URL for the realm. Use in
6568
combination with the default hostname provider to override the base

controllers/keycloakrealm/chain/realm_settings.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ func (h RealmSettings) ServeRequest(ctx context.Context, realm *keycloakApi.Keyc
3838
}
3939

4040
settings := adapter.RealmSettings{
41-
FrontendURL: realm.Spec.FrontendURL,
41+
DisplayHTMLName: realm.Spec.DisplayHTMLName,
42+
FrontendURL: realm.Spec.FrontendURL,
4243
}
4344

4445
if realm.Spec.Themes != nil {

controllers/keycloakrealm/chain/realm_settings_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ func TestRealmSettings_ServeRequest(t *testing.T) {
3939
PasswordPolicies: []keycloakApi.PasswordPolicy{
4040
{Type: "foo", Value: "bar"},
4141
},
42-
FrontendURL: "http://example.com",
42+
DisplayHTMLName: "<div class=\"kc-logo-text\"><span>Example</span></div>",
43+
FrontendURL: "http://example.com",
4344
},
4445
}
4546

@@ -53,7 +54,8 @@ func TestRealmSettings_ServeRequest(t *testing.T) {
5354
PasswordPolicies: []adapter.PasswordPolicy{
5455
{Type: "foo", Value: "bar"},
5556
},
56-
FrontendURL: realm.Spec.FrontendURL,
57+
DisplayHTMLName: realm.Spec.DisplayHTMLName,
58+
FrontendURL: realm.Spec.FrontendURL,
5759
}).Return(nil)
5860

5961
kClient.On("SetRealmEventConfig", realm.Spec.RealmName, &adapter.RealmEventConfig{

deploy-templates/crds/v1.edp.epam.com_keycloakrealms.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ spec:
6060
apply to HTTP responses from the realm's browser clients.
6161
nullable: true
6262
type: object
63+
displayHtmlName:
64+
description: DisplayHTMlName name to display via the frontend
65+
type: string
6366
frontendUrl:
6467
description: FrontendURL Set the frontend URL for the realm. Use in
6568
combination with the default hostname provider to override the base

docs/api.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6525,6 +6525,13 @@ KeycloakRealmSpec defines the desired state of KeycloakRealm.
65256525
BrowserSecurityHeaders is a map of security headers to apply to HTTP responses from the realm's browser clients.<br/>
65266526
</td>
65276527
<td>false</td>
6528+
</tr><tr>
6529+
<td><b>displayHtmlName</b></td>
6530+
<td>string</td>
6531+
<td>
6532+
DisplayHTMlName name to display via the frontend<br/>
6533+
</td>
6534+
<td>false</td>
65286535
</tr><tr>
65296536
<td><b>frontendUrl</b></td>
65306537
<td>string</td>

pkg/client/keycloak/adapter/gocloak_adapter_realms.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ type RealmSettings struct {
1818
Themes *RealmThemes
1919
BrowserSecurityHeaders *map[string]string
2020
PasswordPolicies []PasswordPolicy
21+
DisplayHTMLName string
2122
FrontendURL string
2223
TokenSettings *TokenSettings
2324
}
@@ -93,6 +94,14 @@ func setRealmSettings(realm *gocloak.RealmRepresentation, realmSettings *RealmSe
9394
realm.PasswordPolicy = gocloak.StringP(strings.Join(policies, " and "))
9495
}
9596

97+
if realmSettings.DisplayHTMLName != "" {
98+
if realm.Attributes == nil {
99+
realm.Attributes = &map[string]string{}
100+
}
101+
102+
(*realm.Attributes)["displayHTMLName"] = realmSettings.DisplayHTMLName
103+
}
104+
96105
if realmSettings.FrontendURL != "" {
97106
if realm.Attributes == nil {
98107
realm.Attributes = &map[string]string{}

0 commit comments

Comments
 (0)