Sha256: 13d232e6b5d388ce849892b1f3e1c329a60cdecfa2463c9aa39fe6a1729f36f1
Contents?: true
Size: 927 Bytes
Versions: 1
Compression:
Stored size: 927 Bytes
Contents
module TentD class API class AuthenticationLookup < Middleware def action(env) return env unless env['HTTP_AUTHORIZATION'] env['hmac'] = Hash[env['HTTP_AUTHORIZATION'].scan(/([a-z]+)="([^"]+)"/i)] mac_key_id = env['hmac']['id'] env.potential_auth = case mac_key_id.to_s[0,1] when 's' TentD::Model::Follower.first(:mac_key_id => mac_key_id) when 'a' TentD::Model::App.first(:mac_key_id => mac_key_id) when 'u' TentD::Model::AppAuthorization.first(:mac_key_id => mac_key_id) end env.potential_auth = Model::Following.first(:mac_key_id => mac_key_id) unless env.potential_auth if env.potential_auth env.hmac.secret = env.potential_auth.mac_key env.hmac.algorithm = env.potential_auth.mac_algorithm else env.hmac = nil end env end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tentd-0.0.1 | lib/tentd/api/authentication_lookup.rb |