keycloak: allow nextcloud mail profile attrs
This commit is contained in:
parent
73728bcc09
commit
c8f9b59e4a
@ -2,7 +2,7 @@
|
|||||||
apiVersion: batch/v1
|
apiVersion: batch/v1
|
||||||
kind: Job
|
kind: Job
|
||||||
metadata:
|
metadata:
|
||||||
name: keycloak-realm-settings-12
|
name: keycloak-realm-settings-13
|
||||||
namespace: sso
|
namespace: sso
|
||||||
spec:
|
spec:
|
||||||
backoffLimit: 0
|
backoffLimit: 0
|
||||||
@ -144,20 +144,60 @@ spec:
|
|||||||
attrs = profile.get("attributes")
|
attrs = profile.get("attributes")
|
||||||
if not isinstance(attrs, list):
|
if not isinstance(attrs, list):
|
||||||
attrs = []
|
attrs = []
|
||||||
has_mailu_email = any(
|
|
||||||
isinstance(item, dict) and item.get("name") == "mailu_email" for item in attrs
|
required_attrs = [
|
||||||
)
|
{
|
||||||
if not has_mailu_email:
|
"name": "mailu_email",
|
||||||
attrs.append(
|
"displayName": "Atlas Mailbox",
|
||||||
{
|
"multivalued": False,
|
||||||
"name": "mailu_email",
|
"annotations": {"group": "user-metadata"},
|
||||||
"displayName": "Atlas Mailbox",
|
"permissions": {"view": ["admin"], "edit": ["admin"]},
|
||||||
"multivalued": False,
|
"validations": {"email": {}, "length": {"max": 255}},
|
||||||
"annotations": {"group": "user-metadata"},
|
},
|
||||||
"permissions": {"view": ["admin"], "edit": ["admin"]},
|
{
|
||||||
"validations": {"email": {}, "length": {"max": 255}},
|
"name": "mailu_app_password",
|
||||||
}
|
"displayName": "Atlas Mail App Password",
|
||||||
)
|
"multivalued": False,
|
||||||
|
"annotations": {"group": "user-metadata"},
|
||||||
|
"permissions": {"view": ["admin"], "edit": ["admin"]},
|
||||||
|
"validations": {"length": {"max": 255}},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "nextcloud_mail_primary_email",
|
||||||
|
"displayName": "Nextcloud Mail Primary Email",
|
||||||
|
"multivalued": False,
|
||||||
|
"annotations": {"group": "user-metadata"},
|
||||||
|
"permissions": {"view": ["admin"], "edit": ["admin"]},
|
||||||
|
"validations": {"email": {}, "length": {"max": 255}},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "nextcloud_mail_account_count",
|
||||||
|
"displayName": "Nextcloud Mail Account Count",
|
||||||
|
"multivalued": False,
|
||||||
|
"annotations": {"group": "user-metadata"},
|
||||||
|
"permissions": {"view": ["admin"], "edit": ["admin"]},
|
||||||
|
"validations": {"length": {"max": 32}},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "nextcloud_mail_synced_at",
|
||||||
|
"displayName": "Nextcloud Mail Last Synced",
|
||||||
|
"multivalued": False,
|
||||||
|
"annotations": {"group": "user-metadata"},
|
||||||
|
"permissions": {"view": ["admin"], "edit": ["admin"]},
|
||||||
|
"validations": {"length": {"max": 64}},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
def has_attr(name: str) -> bool:
|
||||||
|
return any(isinstance(item, dict) and item.get("name") == name for item in attrs)
|
||||||
|
|
||||||
|
updated = False
|
||||||
|
for attr in required_attrs:
|
||||||
|
if not has_attr(attr.get("name", "")):
|
||||||
|
attrs.append(attr)
|
||||||
|
updated = True
|
||||||
|
|
||||||
|
if updated:
|
||||||
profile["attributes"] = attrs
|
profile["attributes"] = attrs
|
||||||
status, _ = http_json("PUT", profile_url, access_token, profile)
|
status, _ = http_json("PUT", profile_url, access_token, profile)
|
||||||
if status not in (200, 204):
|
if status not in (200, 204):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user