mirror of
https://git.nadeko.net/Fijxu/invidious.git
synced 2025-06-28 09:58:25 +00:00
cookies: replace alternative domains and backend domains by Host header instead
This commit is contained in:
parent
ce97a41301
commit
642b2e8bf0
@ -123,10 +123,6 @@ class Config
|
|||||||
property domain : String?
|
property domain : String?
|
||||||
# Materialious redirects
|
# Materialious redirects
|
||||||
property materialious_domain : String?
|
property materialious_domain : String?
|
||||||
# Alternative domains. You can add other domains, like TOR and I2P addresses
|
|
||||||
property alternative_domains : Array(String) = [] of String
|
|
||||||
# Backend domains. Domains for numbered backends
|
|
||||||
property backend_domains : Array(String) = [] of String
|
|
||||||
|
|
||||||
# Subscribe to channels using PubSubHubbub (requires domain, hmac_key)
|
# Subscribe to channels using PubSubHubbub (requires domain, hmac_key)
|
||||||
property use_pubsub_feeds : Bool | Int32 = false
|
property use_pubsub_feeds : Bool | Int32 = false
|
||||||
|
@ -60,15 +60,7 @@ module Invidious::Routes::Login
|
|||||||
sid = Base64.urlsafe_encode(Random::Secure.random_bytes(32))
|
sid = Base64.urlsafe_encode(Random::Secure.random_bytes(32))
|
||||||
Invidious::Database::SessionIDs.insert(sid, email)
|
Invidious::Database::SessionIDs.insert(sid, email)
|
||||||
|
|
||||||
# Checks if there is any alternative domain, like a second domain name,
|
env.response.cookies["SID"] = Invidious::User::Cookies.sid(env.request.headers["Host"], sid)
|
||||||
# TOR or I2P address
|
|
||||||
if alt = CONFIG.alternative_domains.index(env.request.headers["Host"])
|
|
||||||
env.response.cookies["SID"] = Invidious::User::Cookies.sid(CONFIG.alternative_domains[alt], sid)
|
|
||||||
elsif alt = CONFIG.backend_domains.index(env.request.headers["Host"])
|
|
||||||
env.response.cookies["SID"] = Invidious::User::Cookies.sid(CONFIG.backend_domains[alt], sid)
|
|
||||||
else
|
|
||||||
env.response.cookies["SID"] = Invidious::User::Cookies.sid(CONFIG.domain, sid)
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
return error_template(401, "Wrong username or password")
|
return error_template(401, "Wrong username or password")
|
||||||
end
|
end
|
||||||
@ -168,15 +160,7 @@ module Invidious::Routes::Login
|
|||||||
Invidious::Database::Users.insert(user)
|
Invidious::Database::Users.insert(user)
|
||||||
Invidious::Database::SessionIDs.insert(sid, email)
|
Invidious::Database::SessionIDs.insert(sid, email)
|
||||||
|
|
||||||
# Checks if there is any alternative domain, like a second domain name,
|
env.response.cookies["SID"] = Invidious::User::Cookies.sid(env.request.headers["Host"], sid)
|
||||||
# TOR or I2P address
|
|
||||||
if alt = CONFIG.alternative_domains.index(env.request.headers["Host"])
|
|
||||||
env.response.cookies["SID"] = Invidious::User::Cookies.sid(CONFIG.alternative_domains[alt], sid)
|
|
||||||
elsif alt = CONFIG.backend_domains.index(env.request.headers["Host"])
|
|
||||||
env.response.cookies["SID"] = Invidious::User::Cookies.sid(CONFIG.backend_domains[alt], sid)
|
|
||||||
else
|
|
||||||
env.response.cookies["SID"] = Invidious::User::Cookies.sid(CONFIG.domain, sid)
|
|
||||||
end
|
|
||||||
|
|
||||||
if env.request.cookies["PREFS"]?
|
if env.request.cookies["PREFS"]?
|
||||||
user.preferences = env.get("preferences").as(Preferences)
|
user.preferences = env.get("preferences").as(Preferences)
|
||||||
|
@ -224,15 +224,7 @@ module Invidious::Routes::PreferencesRoute
|
|||||||
File.write("config/config.yml", CONFIG.to_yaml)
|
File.write("config/config.yml", CONFIG.to_yaml)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
# Checks if there is any alternative domain, like a second domain name,
|
env.response.cookies["PREFS"] = Invidious::User::Cookies.prefs(env.request.headers["Host"], preferences)
|
||||||
# TOR or I2P address
|
|
||||||
if alt = CONFIG.alternative_domains.index(env.request.headers["Host"])
|
|
||||||
env.response.cookies["PREFS"] = Invidious::User::Cookies.prefs(CONFIG.alternative_domains[alt], preferences)
|
|
||||||
elsif alt = CONFIG.backend_domains.index(env.request.headers["Host"])
|
|
||||||
env.response.cookies["PREFS"] = Invidious::User::Cookies.prefs(CONFIG.backend_domains[alt], preferences)
|
|
||||||
else
|
|
||||||
env.response.cookies["PREFS"] = Invidious::User::Cookies.prefs(CONFIG.domain, preferences)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
env.redirect referer
|
env.redirect referer
|
||||||
@ -267,15 +259,7 @@ module Invidious::Routes::PreferencesRoute
|
|||||||
preferences.dark_mode = "dark"
|
preferences.dark_mode = "dark"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks if there is any alternative domain, like a second domain name,
|
env.response.cookies["PREFS"] = Invidious::User::Cookies.prefs(env.request.headers["Host"], preferences)
|
||||||
# TOR or I2P address
|
|
||||||
if alt = CONFIG.alternative_domains.index(env.request.headers["Host"])
|
|
||||||
env.response.cookies["PREFS"] = Invidious::User::Cookies.prefs(CONFIG.alternative_domains[alt], preferences)
|
|
||||||
elsif alt = CONFIG.backend_domains.index(env.request.headers["Host"])
|
|
||||||
env.response.cookies["PREFS"] = Invidious::User::Cookies.prefs(CONFIG.backend_domains[alt], preferences)
|
|
||||||
else
|
|
||||||
env.response.cookies["PREFS"] = Invidious::User::Cookies.prefs(CONFIG.domain, preferences)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if redirect
|
if redirect
|
||||||
|
Loading…
Reference in New Issue
Block a user