diff --git a/.env.sample b/.env.sample index f5dbecb..b442e7b 100644 --- a/.env.sample +++ b/.env.sample @@ -43,3 +43,4 @@ COPY_ASSETS="$COPY_ASSETS icon.png|app:/web/dist/assets/icons/" # NEXTCLOUD_DOMAIN=nextcloud.example.com # SECRET_NEXTCLOUD_ID_VERSION=v1 # SECRET_NEXTCLOUD_SECRET_VERSION=v1 +# APP_ICONS="nextcloud:~/.abra/recipes/authentik/icons/nextcloud.png" diff --git a/README.md b/README.md index 4e26fba..176638a 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,22 @@ abra app cmd db rotate_db_pass abra app cmd app set_admin_pass ``` +## Add SSO for Nextcloud + +Uncomment Nextcloud configuration and set `NEXTCLOUD_DOMAIN` the using `abra app config `: + +``` +COMPOSE_FILE="$COMPOSE_FILE:compose.nextcloud.yml" +NEXTCLOUD_DOMAIN=nextcloud.example.com +SECRET_NEXTCLOUD_ID_VERSION=v1 +SECRET_NEXTCLOUD_SECRET_VERSION=v1 +APP_ICONS="nextcloud:~/.abra/recipes/authentik/icons/nextcloud.png" +``` + +Set the nextcloud Icon using `abra app cmd -l -d set_icons` + +The configuration inside Nextcloud can be found in the [nextcloud recipe](https://git.coopcloud.tech/coop-cloud/nextcloud#authentik-integration) + ## Customization Place the files you want to overwrite in a directory ``. diff --git a/abra.sh b/abra.sh index 14b1bf3..5008f22 100644 --- a/abra.sh +++ b/abra.sh @@ -97,6 +97,37 @@ else: } +set_icons(){ +for icon in $APP_ICONS; do + app=$(echo $icon | cut -d ":" -f1) + file_path=$(eval echo $(echo $icon | cut -d ":" -f2)) + file=$(basename $file_path) + echo copy icon $file_path for $app + abra app cp $APP_NAME $file_path app:/media/ + abra app cmd -T $APP_NAME app set_app_icon $app /media/$file +done +} + +set_app_icon() { +TOKEN=$(cat /run/secrets/admin_token) +python -c """ +import requests +import os +my_token = '$TOKEN' +application = '$1' +icon_path = '$2' +url = f'https://$DOMAIN/api/v3/core/applications/{application}/set_icon/' +headers = {'Authorization':f'Bearer {my_token}'} +with open(icon_path, 'rb') as img: + name_img = os.path.basename(icon_path) + files= {'file': (name_img,img,'image/png') } + with requests.Session() as s: + r = s.post(url,files=files,headers=headers) + print(r.status_code) +""" + +} + blueprint_cleanup() { /manage.py shell -c """ delete_flows = ['default-recovery-flow' , 'custom-authentication-flow' , 'invitation-enrollment-flow' , 'initial-setup']