Class: Rack::Pubcookie::Auth
- Inherits:
-
Object
- Object
- Rack::Pubcookie::Auth
- Defined in:
- lib/rack/pubcookie/auth.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, login_server, host, appid, keyfile, granting_cert, opts = {}) ⇒ Auth
constructor
A new instance of Auth.
Methods included from DES
Methods included from AES
Constructor Details
#initialize(app, login_server, host, appid, keyfile, granting_cert, opts = {}) ⇒ Auth
Returns a new instance of Auth.
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rack/pubcookie/auth.rb', line 12 def initialize app, login_server, host, appid, keyfile, granting_cert, opts = {} @app = app @login_server = login_server @host = host @appid = appid @keyfile = keyfile @granting = OpenSSL::X509::Certificate.new(::File.read(granting_cert)) ::File.open(@keyfile, 'rb'){ |f| @key = f.read.bytes.to_a } @options = opts @options[:expires_after] = 24 * 3600 # 24 hrs end |
Instance Method Details
#call(env) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/rack/pubcookie/auth.rb', line 26 def call env request = Rack::Request.new env if request.path == '/auth/pubcookie' response = Rack::Response.new login_page_html else request.env['REMOTE_USER'] = extract_username request status, headers, body = @app.call(request.env) response = Rack::Response.new body, status, headers if !request.params['pubcookie_g'].nil? && request.params['pubcookie_g'] != request.['pubcookie_g'] response. 'pubcookie_g', :path => '/', :secure => true, :value => request.params['pubcookie_g'] end end response.finish end |