class SSO::Server::Middleware::PassportDestruction
Public Class Methods
new(app)
click to toggle source
# File lib/sso/server/middleware/passport_destruction.rb, line 7 def initialize(app) @app = app end
Public Instance Methods
call(env)
click to toggle source
# File lib/sso/server/middleware/passport_destruction.rb, line 11 def call(env) request = Rack::Request.new(env) unless request.delete? && request.path.start_with?(passports_path) debug { "I'm not interested in this #{request.request_method.inspect} request to #{request.path.inspect} I only care for DELETE #{passports_path.inspect}" } return @app.call(env) end passport_id = request.path.to_s.split('/').last revocation = ::SSO::Server::Passports.logout passport_id: passport_id env['warden'].logout payload = { success: true, code: revocation.code } debug { "Revoked Passport with ID #{passport_id.inspect}" } [200, { 'Content-Type' => 'application/json' }, [payload.to_json]] end
json_code(code)
click to toggle source
# File lib/sso/server/middleware/passport_destruction.rb, line 29 def json_code(code) [200, { 'Content-Type' => 'application/json' }, [{ success: false, code: code }.to_json]] end
passports_path()
click to toggle source
# File lib/sso/server/middleware/passport_destruction.rb, line 33 def passports_path OmniAuth::Strategies::SSO.passports_path end