Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
operator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OZG-Cloud
devops
operator
Commits
785dfe08
Commit
785dfe08
authored
4 months ago
by
OZGCloud
Browse files
Options
Downloads
Patches
Plain Diff
OZG-7303 add realm loginTheme
parent
2c53c2d1
Branches
OZG-7303
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ozgcloud-keycloak-operator/src/main/java/de/ozgcloud/operator/keycloak/realm/KeycloakRealmService.java
+39
-0
39 additions, 0 deletions
...zgcloud/operator/keycloak/realm/KeycloakRealmService.java
with
39 additions
and
0 deletions
ozgcloud-keycloak-operator/src/main/java/de/ozgcloud/operator/keycloak/realm/KeycloakRealmService.java
+
39
−
0
View file @
785dfe08
...
...
@@ -42,6 +42,16 @@ import lombok.extern.log4j.Log4j2;
class
KeycloakRealmService
{
public
static
final
String
USER_PROFILE_CONFIG_OZGCLOUD_ATTRIBUTE_NAME
=
"ozgCloudUserId"
;
public
static
final
String
ENVIRONMENT_PROD
=
"prod"
;
public
static
final
String
ENVIRONMENT_TEST
=
"test"
;
public
static
final
String
ENVIRONMENT_DEV
=
"dev"
;
public
static
final
String
BUNDESLAND_BY
=
"by"
;
public
static
final
String
BUNDESLAND_SH
=
"sh"
;
public
static
final
String
LOGIN_THEME_OZG_SH
=
"ozg-sh"
;
public
static
final
String
LOGIN_THEME_OZG_BY
=
"ozg-by"
;
public
static
final
String
LOGIN_THEME_OZG_DEFAULT
=
"ozg"
;
private
final
KeycloakRealmRemoteService
remoteService
;
...
...
@@ -73,6 +83,7 @@ class KeycloakRealmService {
Optional
.
of
(
realm
)
.
map
(
mapper:
:
map
)
.
map
(
realmRepresentation
->
addRealmName
(
realmRepresentation
,
realmName
))
.
map
(
realmRepresentation
->
addRealmTheme
(
realmRepresentation
,
realmName
))
.
ifPresent
(
realmRepresentation
->
{
remoteService
.
createRealm
(
realmRepresentation
);
addUserProfileAttributes
(
realmRepresentation
);
...
...
@@ -92,6 +103,11 @@ class KeycloakRealmService {
return
realm
;
}
RealmRepresentation
addRealmTheme
(
RealmRepresentation
realm
,
String
realmName
)
{
realm
.
setLoginTheme
(
determinLoginTheme
(
realmName
));
return
realm
;
}
public
void
deleteRealm
(
String
realmName
)
{
remoteService
.
deleteRealm
(
realmName
);
}
...
...
@@ -113,4 +129,27 @@ class KeycloakRealmService {
new
UPAttribute
(
USER_PROFILE_CONFIG_OZGCLOUD_ATTRIBUTE_NAME
,
new
UPAttributePermissions
(
Set
.
of
(
"admin"
,
"user"
),
Set
.
of
(
"admin"
,
"user"
))));
}
String
determinLoginTheme
(
String
realmName
)
{
String
[]
parts
=
realmName
.
split
(
"-"
);
String
bundesland
=
parts
[
0
].
toLowerCase
();
String
environment
=
parts
[
parts
.
length
-
1
].
toLowerCase
();
switch
(
environment
)
{
case
ENVIRONMENT_PROD:
return
LOGIN_THEME_OZG_BY
;
case
ENVIRONMENT_DEV
,
ENVIRONMENT_TEST:
switch
(
bundesland
)
{
case
BUNDESLAND_SH:
return
LOGIN_THEME_OZG_SH
;
case
BUNDESLAND_BY:
return
LOGIN_THEME_OZG_BY
;
default
:
return
LOGIN_THEME_OZG_DEFAULT
;
}
default
:
return
LOGIN_THEME_OZG_DEFAULT
;
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment