diff options
| author | Omar Roth <omarroth@hotmail.com> | 2018-11-15 16:41:43 -0600 |
|---|---|---|
| committer | Omar Roth <omarroth@hotmail.com> | 2018-11-15 16:41:43 -0600 |
| commit | bf867c3fcf347b3425b52ecd1da8850d2526199b (patch) | |
| tree | ad44a0d385645aa5f5fb6d9a8dc1e257f659dddd /src | |
| parent | 6db235becfb10baf9f2624b8ccd375fda8cc7216 (diff) | |
| download | invidious-bf867c3fcf347b3425b52ecd1da8850d2526199b.tar.gz invidious-bf867c3fcf347b3425b52ecd1da8850d2526199b.tar.bz2 invidious-bf867c3fcf347b3425b52ecd1da8850d2526199b.zip | |
Add cookie sharing with subdomains
Diffstat (limited to 'src')
| -rw-r--r-- | src/invidious.cr | 18 | ||||
| -rw-r--r-- | src/invidious/helpers/helpers.cr | 1 |
2 files changed, 15 insertions, 4 deletions
diff --git a/src/invidious.cr b/src/invidious.cr index 8c558ccf..87480e12 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -846,8 +846,13 @@ post "/login" do |env| secure = false end - env.response.cookies["SID"] = HTTP::Cookie.new(name: "SID", value: sid, expires: Time.now + 2.years, - secure: secure, http_only: true) + if CONFIG.domain + env.response.cookies["SID"] = HTTP::Cookie.new(name: "SID", domain: ".#{CONFIG.domain}", value: sid, expires: Time.now + 2.years, + secure: secure, http_only: true) + else + env.response.cookies["SID"] = HTTP::Cookie.new(name: "SID", value: sid, expires: Time.now + 2.years, + secure: secure, http_only: true) + end else error_message = "Invalid username or password" next templated "error" @@ -891,8 +896,13 @@ post "/login" do |env| secure = false end - env.response.cookies["SID"] = HTTP::Cookie.new(name: "SID", value: sid, expires: Time.now + 2.years, - secure: secure, http_only: true) + if CONFIG.domain + env.response.cookies["SID"] = HTTP::Cookie.new(name: "SID", domain: ".#{CONFIG.domain}", value: sid, expires: Time.now + 2.years, + secure: secure, http_only: true) + else + env.response.cookies["SID"] = HTTP::Cookie.new(name: "SID", value: sid, expires: Time.now + 2.years, + secure: secure, http_only: true) + end end env.redirect referer diff --git a/src/invidious/helpers/helpers.cr b/src/invidious/helpers/helpers.cr index 92a2e1b1..aa9c0433 100644 --- a/src/invidious/helpers/helpers.cr +++ b/src/invidious/helpers/helpers.cr @@ -16,6 +16,7 @@ class Config hmac_key: String?, full_refresh: Bool, geo_bypass: Bool, + domain: String?, }) end |
