Class: Aker::Cas::RackProxyCallback
- Inherits:
-
Object
- Object
- Aker::Cas::RackProxyCallback
- Defined in:
- lib/aker/cas/rack_proxy_callback.rb
Overview
Rack code for handling the PGT callback part of the CAS proxy authentication protocol. The class itself is middleware; it can also generate an endpoint.
Behavior
As middleware, this class intercepts and handles two paths and passes all other requests down the chain. The paths are:
/receive_pgt: implements the PGT callback process per section 2.5.4 of the CAS protocol./retrieve_pgt: allows an application to retrieve the PGT for a PGTIOU. The PGTIOU is returned to the application as part of the CAS ticket validation process. It should be passed to/receive_pgtas thepgtIouquery parameter. Note that a given PGT may only be retrieved once.
As a full rack app, it handles the same two paths and returns 404 Not Found for all other requests.
Middleware vs. Application
It is only appropriate to use the class as middleware in a multithreaded or multiprocessing deployment. If your application only has one executor at a time, using this class as middleware will cause a deadlock during CAS authentication.
Based on
This class was heavily influenced by CasProxyCallbackController
in rubycas-client. That class has approximately the same
behavior, but is Rails-specific.
Constant Summary collapse
- RETRIEVE_PATH =
"/retrieve_pgt"- RECEIVE_PATH =
"/receive_pgt"
Class Method Summary collapse
-
.application(options = {}) ⇒ #call
Creates a rack application which responds as described in the class overview.
Instance Method Summary collapse
-
#call(env) ⇒ Array
Handles a single request in the manner specified in the class overview.
-
#initialize(app, options = {}) ⇒ RackProxyCallback
constructor
Create a new instance of the middleware.
Constructor Details
#initialize(app, options = {}) ⇒ RackProxyCallback
Create a new instance of the middleware.
53 54 55 56 57 |
# File 'lib/aker/cas/rack_proxy_callback.rb', line 53 def initialize(app, ={}) @app = app @store_filename = .delete(:store) or raise "Please specify a filename for the PGT store" end |
Class Method Details
.application(options = {}) ⇒ #call
Creates a rack application which responds as described in the class overview.
80 81 82 83 84 85 |
# File 'lib/aker/cas/rack_proxy_callback.rb', line 80 def self.application(={}) app = lambda { |env| [404, { "Content-Type" => "text/plain" }, ["Unknown resource #{env['PATH_INFO']}"]] } RackProxyCallback.new(app, ) end |
Instance Method Details
#call(env) ⇒ Array
Handles a single request in the manner specified in the class overview.
66 67 68 69 70 |
# File 'lib/aker/cas/rack_proxy_callback.rb', line 66 def call(env) return receive(env) if env["PATH_INFO"] == RECEIVE_PATH return retrieve(env) if env["PATH_INFO"] == RETRIEVE_PATH @app.call(env) end |