mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-03-31 14:24:16 +02:00
Optimized nextcloud keycloak ldap implementation
This commit is contained in:
parent
e2166235ad
commit
99f633d222
@ -885,6 +885,7 @@
|
|||||||
"email"
|
"email"
|
||||||
],
|
],
|
||||||
"optionalClientScopes": [
|
"optionalClientScopes": [
|
||||||
|
"nextcloud",
|
||||||
"address",
|
"address",
|
||||||
"phone",
|
"phone",
|
||||||
"organization",
|
"organization",
|
||||||
@ -1195,7 +1196,7 @@
|
|||||||
{
|
{
|
||||||
"id": "15dd4961-5b4f-4635-a3f1-a21e1fa7bf3a",
|
"id": "15dd4961-5b4f-4635-a3f1-a21e1fa7bf3a",
|
||||||
"name": "nextcloud",
|
"name": "nextcloud",
|
||||||
"description": "",
|
"description": "Optimized mappers for nextcloud oidc_login with ldap.",
|
||||||
"protocol": "openid-connect",
|
"protocol": "openid-connect",
|
||||||
"attributes": {
|
"attributes": {
|
||||||
"include.in.token.scope": "false",
|
"include.in.token.scope": "false",
|
||||||
@ -1222,6 +1223,25 @@
|
|||||||
"claim.name": "nextcloudQuota",
|
"claim.name": "nextcloudQuota",
|
||||||
"jsonType.label": "int"
|
"jsonType.label": "int"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "018c63c6-3fea-43fe-abbf-2c17e3f2353f",
|
||||||
|
"name": "UID Mapper",
|
||||||
|
"protocol": "openid-connect",
|
||||||
|
"protocolMapper": "oidc-usermodel-attribute-mapper",
|
||||||
|
"consentRequired": false,
|
||||||
|
"config": {
|
||||||
|
"aggregate.attrs": "false",
|
||||||
|
"introspection.token.claim": "true",
|
||||||
|
"multivalued": "false",
|
||||||
|
"userinfo.token.claim": "true",
|
||||||
|
"user.attribute": "username",
|
||||||
|
"id.token.claim": "true",
|
||||||
|
"lightweight.claim": "false",
|
||||||
|
"access.token.claim": "true",
|
||||||
|
"claim.name": "{{ldap.attributes.user_id}}",
|
||||||
|
"jsonType.label": "String"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -2,6 +2,12 @@
|
|||||||
|
|
||||||
Details on specific apps like Cospend, including related SQL queries and debugging tips.
|
Details on specific apps like Cospend, including related SQL queries and debugging tips.
|
||||||
|
|
||||||
|
## Recieve Plugin Information
|
||||||
|
To recieve the relevant configuration options for a plugin type:
|
||||||
|
```bash
|
||||||
|
docker compose exec -u www-data application php occ config:list oidc_login
|
||||||
|
```
|
||||||
|
|
||||||
## App Relevant Tables 🗃️
|
## App Relevant Tables 🗃️
|
||||||
|
|
||||||
- `oc_appconfig`
|
- `oc_appconfig`
|
||||||
|
@ -15,6 +15,12 @@ docker compose exec -u www-data application /var/www/html/occ config:app:get soc
|
|||||||
|
|
||||||
More information: https://docs.nextcloud.com/server/latest/admin_manual/configuration_user/user_auth_ldap.html
|
More information: https://docs.nextcloud.com/server/latest/admin_manual/configuration_user/user_auth_ldap.html
|
||||||
|
|
||||||
|
## Get LDAP Configuration
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker compose exec -u www-data application php occ ldap:show-config
|
||||||
|
```
|
||||||
|
|
||||||
## Get all relevant entries except password
|
## Get all relevant entries except password
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
@ -27,6 +33,40 @@ SELECT * FROM `oc_appconfig` WHERE appid LIKE "%ldap%" and configkey != "s01ldap
|
|||||||
docker compose exec -it -u www-data application php occ ldap:check-user --update {{username}}
|
docker compose exec -it -u www-data application php occ ldap:check-user --update {{username}}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Update LDAP Sync
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker compose exec -u www-data application php occ user:sync-account-data
|
||||||
|
```
|
||||||
|
|
||||||
|
### Update Each User
|
||||||
|
If you want to update **every LDAP user**, run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
for user in $(docker compose exec -u www-data application php occ user:list --output=json | jq -r 'keys[]'); do
|
||||||
|
docker compose exec -u www-data application php occ ldap:check-user --update "$user"
|
||||||
|
done
|
||||||
|
```
|
||||||
|
|
||||||
|
### Unlink All
|
||||||
|
```bash
|
||||||
|
for user in $(docker compose exec -u www-data application php occ ldap:show-remnants | tail -n +3 | awk -F '|' '{print $2}' | tr -d ' ' | grep -v '^$'); do
|
||||||
|
echo "Unlinking user from LDAP: $user"
|
||||||
|
echo "y" | docker compose exec -T -u www-data application php occ ldap:reset-user "$user"
|
||||||
|
done
|
||||||
|
```
|
||||||
|
|
||||||
|
### Reset LDAP Links for Orphaned Users
|
||||||
|
Run this **corrected script**:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
for user in $(docker compose exec -u www-data application php occ ldap:show-remnants | tail -n +3 | awk -F '|' '{print $2}' | tr -d ' ' | grep -v '^$'); do
|
||||||
|
echo "Resetting LDAP link for user: $user"
|
||||||
|
echo "y" | docker compose exec -T -u www-data application php occ ldap:reset-user "$user"
|
||||||
|
done
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Federation
|
## Federation
|
||||||
|
|
||||||
If users are just created via Keycloak and not via LDAP, they have a different username. Due to this reaso concider to use LDAP to guaranty that the username is valid.
|
If users are just created via Keycloak and not via LDAP, they have a different username. Due to this reaso concider to use LDAP to guaranty that the username is valid.
|
||||||
|
@ -16,6 +16,11 @@ docker-compose exec -it -u www-data application /var/www/html/occ
|
|||||||
docker compose exec -it -u www-data application php occ user:list
|
docker compose exec -it -u www-data application php occ user:list
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Get User Info
|
||||||
|
```bash
|
||||||
|
docker compose exec -u www-data application php occ user:info {{username}}
|
||||||
|
```
|
||||||
|
|
||||||
### Sync Users
|
### Sync Users
|
||||||
```bash
|
```bash
|
||||||
docker compose exec -it -u www-data application php occ user:sync
|
docker compose exec -it -u www-data application php occ user:sync
|
||||||
@ -35,7 +40,18 @@ docker compose exec -it -u www-data application php occ group:adduser admin {{us
|
|||||||
```bash
|
```bash
|
||||||
docker compose exec -it -u www-data application php occ user:delete {{username}}
|
docker compose exec -it -u www-data application php occ user:delete {{username}}
|
||||||
```
|
```
|
||||||
---
|
|
||||||
|
### Delete all User (if no ldap is used)
|
||||||
|
```bash
|
||||||
|
for user in $(docker compose exec -u www-data application php occ user:list --output=json | jq -r 'keys[]'); do
|
||||||
|
docker compose exec -u www-data application php occ user:delete "$user"
|
||||||
|
done
|
||||||
|
```
|
||||||
|
|
||||||
|
### Identify users which exist still in nextcloud but not in LDAP anymore
|
||||||
|
```bash
|
||||||
|
occ ldap:show-remnants
|
||||||
|
```
|
||||||
|
|
||||||
## App Administration
|
## App Administration
|
||||||
```bash
|
```bash
|
||||||
|
@ -97,10 +97,10 @@ return array (
|
|||||||
// note: on Keycloak, OIDC name claim = "${given_name} ${family_name}" or one of them if any is missing
|
// note: on Keycloak, OIDC name claim = "${given_name} ${family_name}" or one of them if any is missing
|
||||||
//
|
//
|
||||||
'oidc_login_attributes' => array (
|
'oidc_login_attributes' => array (
|
||||||
'id' => 'username',
|
'id' => '{{ldap.attributes.user_id}}',
|
||||||
'name' => 'name',
|
'name' => 'name',
|
||||||
'mail' => 'email',
|
'mail' => 'email',
|
||||||
# 'quota' => 'nextcloudQuota', # Not implemented yet
|
'quota' => 'nextcloudQuota',
|
||||||
# 'home' => 'homeDirectory', # Not implemented yet
|
# 'home' => 'homeDirectory', # Not implemented yet
|
||||||
'ldap_uid' => 'preferred_username',
|
'ldap_uid' => 'preferred_username',
|
||||||
# 'groups' => 'ownCloudGroups', # Not implemented yet
|
# 'groups' => 'ownCloudGroups', # Not implemented yet
|
||||||
|
@ -210,7 +210,7 @@ cards:
|
|||||||
|
|
||||||
- icon:
|
- icon:
|
||||||
class: "fa-solid fa-envelope"
|
class: "fa-solid fa-envelope"
|
||||||
title: "Mailu Mail Server"
|
title: "Mail Server"
|
||||||
text: "Revolutionize your email communications with Mailu, a secure and flexible mail server solution that integrates seamlessly into your workflow. Experience enhanced reliability, robust security, and an energetic approach to managing your digital correspondence."
|
text: "Revolutionize your email communications with Mailu, a secure and flexible mail server solution that integrates seamlessly into your workflow. Experience enhanced reliability, robust security, and an energetic approach to managing your digital correspondence."
|
||||||
url: https://{{domains.mailu}}
|
url: https://{{domains.mailu}}
|
||||||
link_text: "Elevate Your Email Now!"
|
link_text: "Elevate Your Email Now!"
|
||||||
@ -682,19 +682,19 @@ navigation:
|
|||||||
class: fas fa-user-shield
|
class: fas fa-user-shield
|
||||||
iframe: {{ applications | get_landingpage_iframe_enabled('keycloak') }}
|
iframe: {{ applications | get_landingpage_iframe_enabled('keycloak') }}
|
||||||
children:
|
children:
|
||||||
- name: Keycloak Master Admin
|
- name: Administration
|
||||||
description: Access the central admin console
|
description: Access the central admin console
|
||||||
icon:
|
icon:
|
||||||
class: fa-solid fa-shield-halved
|
class: fa-solid fa-shield-halved
|
||||||
url: https://{{domains.keycloak}}/admin
|
url: https://{{domains.keycloak}}/admin
|
||||||
iframe: {{ applications | get_landingpage_iframe_enabled('keycloak') }}
|
iframe: {{ applications | get_landingpage_iframe_enabled('keycloak') }}
|
||||||
- name: Manage Your Profile
|
- name: Profile
|
||||||
description: Update your personal admin settings
|
description: Update your personal admin settings
|
||||||
icon:
|
icon:
|
||||||
class: fa-solid fa-user-gear
|
class: fa-solid fa-user-gear
|
||||||
url: https://{{ domains.keycloak }}/realms/{{oidc.client.id}}/account
|
url: https://{{ domains.keycloak }}/realms/{{oidc.client.id}}/account
|
||||||
iframe: {{ applications | get_landingpage_iframe_enabled('keycloak') }}
|
iframe: {{ applications | get_landingpage_iframe_enabled('keycloak') }}
|
||||||
- name: Log Out of Keycloak
|
- name: Logout
|
||||||
description: End your admin session securely
|
description: End your admin session securely
|
||||||
icon:
|
icon:
|
||||||
class: fa-solid fa-right-from-bracket
|
class: fa-solid fa-right-from-bracket
|
||||||
|
Loading…
x
Reference in New Issue
Block a user