]> git.openstreetmap.org Git - chef.git/blob - cookbooks/overpass/templates/default/totp-filter.erb
nominatim v4: serve php from project directory
[chef.git] / cookbooks / overpass / templates / default / totp-filter.erb
1 #!/usr/bin/ruby
2
3 requrie "cgi"
4 require "rotp"
5
6 totp = ROTP::TOTP.new("<%= @totp_key %>", :interval => 3600)
7
8 STDIN.each_line do |header|
9   cookies = CGI::Cookie.parse(header)
10
11   if totp.verify(cookies["_osm_totp_token"], :drift_behind => 3600, :drift_ahead => 3600)
12     puts "1"
13   else
14     puts "0"
15   end
16 end
17
18 exit 0