Compare commits

...

8 Commits

Author SHA1 Message Date
John Wong
5e8b3b6e12
Merge c3b06e7a6d into 53e8a5d62d 2024-09-29 13:05:09 -05:00
TheFrenchGhosty
53e8a5d62d
Remove myself from CODEOWNERS on the config file (#4942) 2024-09-28 23:54:52 +02:00
John Wong
c3b06e7a6d
Merge branch 'iv-org:master' into master 2024-09-14 18:28:31 +08:00
kaka
d3e6d7b6c5 Set the cookie first 2023-07-15 08:49:18 +08:00
kaka
f5244055a2 @SamantazFox: Put that code before return if (on line 64) 2023-07-15 06:57:37 +08:00
John Wong
af86cdbd38
Merge branch 'iv-org:master' into master 2023-07-15 06:47:36 +08:00
John Wong
b3637f20a9 check the config flag first 2023-04-10 10:58:11 +08:00
John Wong
c676272604 login_only 2023-04-08 22:23:36 +08:00
3 changed files with 20 additions and 13 deletions

2
.github/CODEOWNERS vendored
View File

@ -6,7 +6,7 @@ docker/ @unixfox
kubernetes/ @unixfox kubernetes/ @unixfox
README.md @thefrenchghosty README.md @thefrenchghosty
config/config.example.yml @thefrenchghosty @SamantazFox @unixfox config/config.example.yml @SamantazFox @unixfox
scripts/ @syeopite scripts/ @syeopite
shards.lock @syeopite shards.lock @syeopite

View File

@ -82,6 +82,7 @@ class Config
# Used to tell Invidious it is behind a proxy, so links to resources should be https:// # Used to tell Invidious it is behind a proxy, so links to resources should be https://
property https_only : Bool? property https_only : Bool?
property login_only : Bool?
# HMAC signing key for CSRF tokens and verifying pubsub subscriptions # HMAC signing key for CSRF tokens and verifying pubsub subscriptions
property hmac_key : String = "" property hmac_key : String = ""
# Domain to be used for links to resources on the site where an absolute URL is required # Domain to be used for links to resources on the site where an absolute URL is required

View File

@ -61,18 +61,6 @@ module Invidious::Routes::BeforeAll
env.response.headers["Strict-Transport-Security"] = "max-age=31536000; includeSubDomains; preload" env.response.headers["Strict-Transport-Security"] = "max-age=31536000; includeSubDomains; preload"
end end
return if {
"/sb/",
"/vi/",
"/s_p/",
"/yts/",
"/ggpht/",
"/api/manifest/",
"/videoplayback",
"/latest_version",
"/download",
}.any? { |r| env.request.resource.starts_with? r }
if env.request.cookies.has_key? "SID" if env.request.cookies.has_key? "SID"
sid = env.request.cookies["SID"].value sid = env.request.cookies["SID"].value
@ -100,6 +88,24 @@ module Invidious::Routes::BeforeAll
end end
end end
unregistered_path_whitelist = {"/", "/login", "/licenses", "/privacy"}
if CONFIG.login_only && !env.get?("user") && !unregistered_path_whitelist.includes?(env.request.path)
env.response.headers["Location"] = "/login"
haltf env, status_code: 302
end
return if {
"/sb/",
"/vi/",
"/s_p/",
"/yts/",
"/ggpht/",
"/api/manifest/",
"/videoplayback",
"/latest_version",
"/download",
}.any? { |r| env.request.resource.starts_with? r }
dark_mode = convert_theme(env.params.query["dark_mode"]?) || preferences.dark_mode.to_s dark_mode = convert_theme(env.params.query["dark_mode"]?) || preferences.dark_mode.to_s
thin_mode = env.params.query["thin_mode"]? || preferences.thin_mode.to_s thin_mode = env.params.query["thin_mode"]? || preferences.thin_mode.to_s
thin_mode = thin_mode == "true" thin_mode = thin_mode == "true"