#!/usr/bin/env ruby require 'openssl' require 'securerandom' require 'sinatra' Users = { "Athena" => "Passw0rd!" } Services = { "_TGS" => "eiqu@a5ahs8mooqu9Eng", "Mail" => "{FvM= ts next "Ticket expired\n" unless Time.now.to_i < (ts + ls) begin aun, aws, als, ats = decrypt(data["authenticator"], sk).split(?,) als = als.to_i ats = ats.to_i rescue OpenSSL::Cipher::CipherError next "Invalid session key\n" end next "Invalid authenticator\n" unless aun == un next "Invalid authenticator\n" unless aws == ws next "Invalid authenticator\n" unless Time.now.to_i >= ats next "Authenticator expired\n" unless Time.now.to_i < (ats + als) anc, svt = ticket(un, ws, data["service"]) "#{encrypt(anc, sk)},#{svt}" end