Class: IAuthU::Server
- Inherits:
-
Object
- Object
- IAuthU::Server
- Defined in:
- lib/iauthu/server.rb
Overview
IAuthU::Server provides a ready-to-run iTunes U (tm) authentication server. You can use
Server.build {} to easily construct and configure your authentication server:
server = Server.build {
run :webrick, :port => 9292
site {
url "https://deimos.apple.com/WebObjects/Core.woa/Browse/foo.edu"
shared_secret "SHARED-SECRET"
}
auth {
use IAuthU::Authenticator::Open
}
}
Defined Under Namespace
Classes: Builder
Instance Attribute Summary collapse
-
#auth ⇒ Object
Returns the value of attribute auth.
-
#login_page ⇒ Object
Returns the value of attribute login_page.
-
#port ⇒ Object
Returns the value of attribute port.
-
#runner ⇒ Object
Returns the value of attribute runner.
-
#site ⇒ Object
Returns the value of attribute site.
Class Method Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize ⇒ Server
constructor
A new instance of Server.
- #logger ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize ⇒ Server
Returns a new instance of Server.
36 37 38 39 40 |
# File 'lib/iauthu/server.rb', line 36 def initialize @runner = Rack::Handler::WEBrick @port = 9292 @login_page = login_form end |
Instance Attribute Details
#auth ⇒ Object
Returns the value of attribute auth.
41 42 43 |
# File 'lib/iauthu/server.rb', line 41 def auth @auth end |
#login_page ⇒ Object
Returns the value of attribute login_page.
41 42 43 |
# File 'lib/iauthu/server.rb', line 41 def login_page @login_page end |
#port ⇒ Object
Returns the value of attribute port.
41 42 43 |
# File 'lib/iauthu/server.rb', line 41 def port @port end |
#runner ⇒ Object
Returns the value of attribute runner.
41 42 43 |
# File 'lib/iauthu/server.rb', line 41 def runner @runner end |
#site ⇒ Object
Returns the value of attribute site.
41 42 43 |
# File 'lib/iauthu/server.rb', line 41 def site @site end |
Class Method Details
Instance Method Details
#call(env) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/iauthu/server.rb', line 54 def call(env) req = Rack::Request.new(env) user, pass = req.POST["username"], req.POST["password"] # if user && pass # logged_in, result = login(user, pass) # else # logged_in = false # end # result = login_page unless logged_in # res = Rack::Response.new # res.write result # res.finish unless req.POST["username"] && req.POST["password"] Rack::Response.new.finish do |res| res.write login_page end else Rack::Response.new.finish do |res| logged_in, result = login(req.POST["username"], req.POST["password"]) #puts result res.write result end end end |
#logger ⇒ Object
43 44 45 |
# File 'lib/iauthu/server.rb', line 43 def logger CONFIG[:logger] end |
#run ⇒ Object
47 48 49 50 51 52 |
# File 'lib/iauthu/server.rb', line 47 def run raise "Site config is required" unless @site raise "Auth config is required" unless @auth logger.info "Running IAuthU with: #{@runner}" @runner.run(Rack::ShowExceptions.new(Rack::Lint.new(self)), :Port => @port) end |