]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/site_controller.rb
Reduce TOTP cookie expiry to one hour
[rails.git] / app / controllers / site_controller.rb
index 1a4c9f148425eef9621568d8d822fd0a49a1a916..42f04166284b9b65b270f5e070cc164cb49869a0 100644 (file)
@@ -13,6 +13,14 @@ class SiteController < ApplicationController
     unless STATUS == :database_readonly || STATUS == :database_offline
       session[:location] ||= OSM.ip_location(request.env["REMOTE_ADDR"])
     end
     unless STATUS == :database_readonly || STATUS == :database_offline
       session[:location] ||= OSM.ip_location(request.env["REMOTE_ADDR"])
     end
+
+    if defined?(TOTP_KEY)
+      cookies["_osm_totp_token"] = {
+        :value => ROTP::TOTP.new(TOTP_KEY, :interval => 3600).now,
+        :domain => ".openstreetmap.org",
+        :expires => 1.hour.from_now
+      }
+    end
   end
 
   def permalink
   end
 
   def permalink