class CagedChef::ChefAuth
Public Class Methods
new(app, options = {})
click to toggle source
Calls superclass method
# File lib/caged_chef/chef_auth.rb, line 8 def initialize(app, options = {}) super(app) @app = app @options = options @key = @options[:key] end
Public Instance Methods
call(env)
click to toggle source
# File lib/caged_chef/chef_auth.rb, line 16 def call(env) @env = env @env[:request_headers] = signed_headers @app.call @env end
Private Instance Methods
key()
click to toggle source
# File lib/caged_chef/chef_auth.rb, line 34 def key OpenSSL::PKey::RSA.new(File.read(@key)) end
mixlib_headers()
click to toggle source
# File lib/caged_chef/chef_auth.rb, line 23 def mixlib_headers { http_method: @env[:method], path: @env[:url].path, body: @env[:body], host: @options[:host], user_id: @options[:user_id], timestamp: Time.now.utc.to_s } end
signed_headers()
click to toggle source
# File lib/caged_chef/chef_auth.rb, line 42 def signed_headers signing_object.sign key end
signing_object()
click to toggle source
# File lib/caged_chef/chef_auth.rb, line 38 def signing_object Mixlib::Authentication::SignedHeaderAuth.signing_object(mixlib_headers) end