From 5dbfa7fe2a37fe6dbeb4dece50af83e12804752e Mon Sep 17 00:00:00 2001 From: jendiamond Date: Tue, 14 Nov 2023 16:39:28 -0800 Subject: [PATCH] change the 3 day authentication to 1 year --- app/controllers/application_controller.rb | 14 +++++++++----- app/views/catalog/_index.html.erb | 4 ++-- app/views/catalog/_index_gallery.html.erb | 2 +- app/views/shared/header/_header_navbar.html.erb | 2 +- spec/controllers/application_controller_spec.rb | 16 ++++++++-------- 5 files changed, 21 insertions(+), 17 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 3a32e9fa..8db287e2 100755 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -37,9 +37,9 @@ def display_banner? end def sinai_authn_check - return true if [version_path].include?(request.path) || sinai_authenticated_3day? + return true if [version_path].include?(request.path) || sinai_authenticated_1year? if ENV['SINAI_ID_BYPASS'] # skip auth in development - cookies[:sinai_authenticated_3day] = 'true' + cookies[:sinai_authenticated_1year] = 'true' return true end # check_document_paths @@ -69,6 +69,10 @@ def sinai_authenticated_3day? cookies[:sinai_authenticated_3day] end + def sinai_authenticated_1year? + cookies[:sinai_authenticated_1year] + end + def ucla_token? # does the request have a querystring containing a param named token and, if so, was it previously written to the database? return true if params[:token].present? && SinaiToken.find_by(sinai_token: params[:token]) @@ -83,14 +87,14 @@ def ucla_token? end def set_auth_cookies - cookies[:sinai_authenticated_3day] = { + cookies[:sinai_authenticated_1year] = { value: create_encrypted_string.unpack('H*')[0].upcase, - expires: Time.zone.now + 3.days, + expires: Time.zone.now + 1.year, domain: ENV['DOMAIN'] } cookies[:initialization_vector] = { value: cipher_iv.unpack('H*')[0].upcase, - expires: Time.zone.now + 3.days, + expires: Time.zone.now + 1.year, domain: ENV['DOMAIN'] } end diff --git a/app/views/catalog/_index.html.erb b/app/views/catalog/_index.html.erb index 0e26d6ce..0895c6b6 100644 --- a/app/views/catalog/_index.html.erb +++ b/app/views/catalog/_index.html.erb @@ -6,7 +6,7 @@ <%# THUMBNAIL %> <% if presenter(document).thumbnail.exists? && tn = presenter(document).thumbnail.thumbnail_tag({}, counter: document_counter_with_offset(document_counter)) %> <%# Thumnail NOT logged in %> - <% if !cookies[:sinai_authenticated_3day] %> + <% if !cookies[:sinai_authenticated_1year] %>