From 0e98711e935070a3941e21a79e02729feec61592 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toni=20F=C3=B6rster?= Date: Mon, 13 Nov 2023 22:02:12 +0100 Subject: [PATCH] removed redirect_login --- config/config.example.yml | 10 --------- src/invidious/config.cr | 2 -- src/invidious/routes/before_all.cr | 35 +++++++++++++----------------- 3 files changed, 15 insertions(+), 32 deletions(-) diff --git a/config/config.example.yml b/config/config.example.yml index 1e9b1264..39c72785 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -252,16 +252,6 @@ https_only: false ## #private_instance: false -## -## Redirect request to the login page on private instances. Also requires -## login_enabled to be 'true', otherwise the server sends status code 401 -## and closes the connection. -## -## Accepted values: true, false -## Default: false -## -#redirect_login: false - ## ## Allow/Forbid Invidious (local) account creation. Invidious ## accounts allow users to subscribe to channels and to create diff --git a/src/invidious/config.cr b/src/invidious/config.cr index 3d907020..9ae26128 100644 --- a/src/invidious/config.cr +++ b/src/invidious/config.cr @@ -94,8 +94,6 @@ class Config property captcha_enabled : Bool = true # Only allow usage of the Invidious instance with an existing account property private_instance : Bool = false - # Redirected requests to the login page on a private instance. Requires login_enabled: true - property redirect_login : Bool = false property login_enabled : Bool = true property registration_enabled : Bool = true property statistics_enabled : Bool = false diff --git a/src/invidious/routes/before_all.cr b/src/invidious/routes/before_all.cr index cd2feda6..67bdc7af 100644 --- a/src/invidious/routes/before_all.cr +++ b/src/invidious/routes/before_all.cr @@ -99,31 +99,26 @@ module Invidious::Routes::BeforeAll "/feed/webhook/v1:", "/api/v1/videos/dQw4w9WgXcQ", "/api/v1/comments/jNQXAC9IVRw", - } + } if CONFIG.private_instance && !env.get?("user") && !unregistered_path_whitelist.any? { |r| env.request.path.starts_with? r } - if CONFIG.redirect_login && CONFIG.login_enabled - env.response.headers["Location"] = "/login" - haltf env, status_code: 302 - else - env.response.status_code = 401 - env.response.close - end + env.response.headers["Location"] = "/login" + haltf env, status_code: 302 end return if { - "/sb/", - "/vi/", - "/s_p/", - "/yts/", - "/ggpht/", - "/download", - "/licenses", - "/api/manifest/", - "/videoplayback", - "/latest_version", - "/opensearch.xml", - }.any? { |r| env.request.resource.starts_with? r } + "/sb/", + "/vi/", + "/s_p/", + "/yts/", + "/ggpht/", + "/download", + "/licenses", + "/api/manifest/", + "/videoplayback", + "/latest_version", + "/opensearch.xml", + }.any? { |r| env.request.resource.starts_with? r } 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