YunoHost-Apps / jellyfin_ynh

Jellyfin package for YunoHost
https://jellyfin.org/
GNU General Public License v3.0
26 stars 24 forks source link

New user has no access to libraries #124

Closed selfhoster1312 closed 1 year ago

selfhoster1312 commented 1 year ago

Describe the bug

When a new user is created on Yunohost, they do not have access to the media libraries configured in Jellyfin. I have to go and manually "enable access to all libraries".

Context

Jellyfin v10.8.5~ynh1

Steps to reproduce

  1. Add a new user foo from yunohost admin web interface
  2. Connect as foo on jellyfin
  3. See 0 library/content

Expected behavior

Previously, the user creation script granted access to all libraries by default. I don't know if it's regression in Yunohost package or upstream, but this changed a few months ago.

I think by default creating a user should grant them access to all libraries. If someone disagrees, it could be a setting on the Yunohost application config, or maybe a dedicated LDAP permission.

selfhoster1312 commented 1 year ago

I found cause: new default settings for LDAP plugin.

Possible to change in plugin settings: baseURL/web/index.html#!/configurationpage?name=LDAP-Auth

Will try to write script to give permission retroactively. EDIT: Here's a script. Don't forget to set API_KEY and JELLYFIN_URL at the top. Jellyfin URL should end with /.

#! /usr/bin/env python3

API_KEY=""
JELLYFIN_URL=""

import json
import requests

def apiEndpoint(endpoint):
    return JELLYFIN_URL + endpoint + "?api_key=" + API_KEY

def apiPost(endpoint, struct):
    r = requests.post(apiEndpoint(endpoint), json=struct)
    r.raise_for_status()
    stripped = r.text.strip()
    if stripped != "":
        return r.json()
    else:
        return None

def apiGet(endpoint):
    r = requests.get(apiEndpoint(endpoint))
    r.raise_for_status()
    stripped = r.text.strip()
    if stripped != "":
        return r.json()
    else:
        return None

users = apiGet('users')

for user in users:
    if not user["Policy"]["EnableAllFolders"]:
        print(user["Name"] + " doesn't have library access... enabling")
        newPolicy = user["Policy"]
        newPolicy["EnableAllFolders"] = True
        apiPost('users/' + user["Id"] + '/Policy', newPolicy)