add jellyfin auth
This commit is contained in:
@@ -14,6 +14,22 @@ export default {
|
||||
}
|
||||
const authorizationHeader = request.headers.get('Authorization').split(' ').pop()
|
||||
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) {
|
||||
return deny()
|
||||
}
|
||||
|
||||
+3
-5
@@ -1,7 +1,5 @@
|
||||
name = "cf-basic-auth"
|
||||
name = "cf-basic-auth-jellyfin"
|
||||
main = "src/index.js"
|
||||
compatibility_date = "2024-12-18"
|
||||
|
||||
#[route]
|
||||
#pattern="sub.domain.com/*"
|
||||
#zone_name = "domain.com"
|
||||
workers_dev=false
|
||||
keep_vars=true
|
||||
Reference in New Issue
Block a user