add jellyfin auth

This commit is contained in:
2026-01-17 16:35:13 -08:00
parent 86aad1bb58
commit 1a5042c110
2 changed files with 19 additions and 5 deletions
+16
View File
@@ -14,6 +14,22 @@ export default {
} }
const authorizationHeader = request.headers.get('Authorization').split(' ').pop() const authorizationHeader = request.headers.get('Authorization').split(' ').pop()
const [user, pass] = atob(authorizationHeader).split(':') const [user, pass] = atob(authorizationHeader).split(':')
if (env.JELLYFIN_HOST) {
const response = await fetch(new URL('/Users/AuthenticateByName', env.JELLYFIN_HOST), {
'method': 'POST',
'body': JSON.stringify({
'Username': user,
'Pw': pass
}),
'headers': {
'content-type': 'application/json',
'authorization':'MediaBrowser Client="cf-basic-auth", Device="cf-basic-auth", DeviceId="cf-basic-auth", Version="0.0.0"'
}
})
if (response.ok) {
return fetch(request)
}
}
if (!(user in env) || env[user] !== pass) { if (!(user in env) || env[user] !== pass) {
return deny() return deny()
} }
+3 -5
View File
@@ -1,7 +1,5 @@
name = "cf-basic-auth" name = "cf-basic-auth-jellyfin"
main = "src/index.js" main = "src/index.js"
compatibility_date = "2024-12-18" compatibility_date = "2024-12-18"
workers_dev=false
#[route] keep_vars=true
#pattern="sub.domain.com/*"
#zone_name = "domain.com"