summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOmar Roth <omarroth@hotmail.com>2018-07-21 21:28:10 -0500
committerOmar Roth <omarroth@hotmail.com>2018-07-21 21:28:10 -0500
commite49dadbb65797a59e983bbee16886e6084e852de (patch)
tree293630803f725e6d7806b265081a3a8aca34824e /src
parent30929a95749919181d2f8bb5e273efd908a2e355 (diff)
downloadinvidious-e49dadbb65797a59e983bbee16886e6084e852de.tar.gz
invidious-e49dadbb65797a59e983bbee16886e6084e852de.tar.bz2
invidious-e49dadbb65797a59e983bbee16886e6084e852de.zip
Add option to redirect to HTTPS links even if ssl isn't enabled
Diffstat (limited to 'src')
-rw-r--r--src/invidious.cr12
-rw-r--r--src/invidious/helpers.cr1
2 files changed, 7 insertions, 6 deletions
diff --git a/src/invidious.cr b/src/invidious.cr
index 0525652d..566686c2 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -861,7 +861,7 @@ post "/login" do |env|
host = URI.parse(env.request.headers["Host"]).host
login.cookies.each do |cookie|
- if Kemal.config.ssl
+ if Kemal.config.ssl || CONFIG.https_only
cookie.secure = true
else
cookie.secure = false
@@ -924,7 +924,7 @@ post "/login" do |env|
sid = Base64.encode(Random::Secure.random_bytes(50))
PG_DB.exec("UPDATE users SET id = $1 WHERE email = $2", sid, email)
- if Kemal.config.ssl
+ if Kemal.config.ssl || CONFIG.https_only
secure = true
else
secure = false
@@ -951,7 +951,7 @@ post "/login" do |env|
PG_DB.exec("INSERT INTO users VALUES (#{args})", user_array)
- if Kemal.config.ssl
+ if Kemal.config.ssl || CONFIG.https_only
secure = true
else
secure = false
@@ -1180,7 +1180,7 @@ get "/feed/private" do |env|
videos.sort_by! { |video| video.author }.reverse!
end
- if Kemal.config.ssl
+ if Kemal.config.ssl || CONFIG.https_only
scheme = "https://"
else
scheme = "http://"
@@ -1459,7 +1459,7 @@ get "/api/manifest/dash/id/:id" do |env|
url = url.rchop("</BaseURL>")
if local
- if Kemal.config.ssl
+ if Kemal.config.ssl || CONFIG.https_only
scheme = "https://"
end
scheme ||= "http://"
@@ -1484,7 +1484,7 @@ get "/api/manifest/dash/id/:id" do |env|
if local
adaptive_fmts.each do |fmt|
- if Kemal.config.ssl
+ if Kemal.config.ssl || CONFIG.https_only
scheme = "https://"
end
scheme ||= "http://"
diff --git a/src/invidious/helpers.cr b/src/invidious/helpers.cr
index 2172b032..ef56da1a 100644
--- a/src/invidious/helpers.cr
+++ b/src/invidious/helpers.cr
@@ -42,6 +42,7 @@ class Config
dbname: String,
),
dl_api_key: String?,
+ https_only: Bool?,
})
end