]> git.openstreetmap.org Git - rails.git/blob - vendor/gems/rots-0.2.1/lib/rots/identity_page_app.rb
Merge branch 'master' into openstreetbugs
[rails.git] / vendor / gems / rots-0.2.1 / lib / rots / identity_page_app.rb
1 require 'rack/request'
2 require 'rack/response'
3 require 'rack/utils'
4 require 'openid'
5
6 class Rots::IdentityPageApp 
7   
8   def initialize(config, server_options)
9     @server_options = server_options
10     @config = config
11   end
12   
13   def call(env)
14     @request = Rack::Request.new(env)
15     Rack::Response.new do |response|
16       response.write <<-HERE
17 <html>
18   <head>
19   <link rel="openid2.provider" href="#{op_endpoint}" />
20   <link rel="openid.server" href="#{op_endpoint}" />
21   </head>
22   <body>
23     <h1>This is #{@config['identity']} identity page</h1>
24   </body>
25 </html>
26       HERE
27     end.finish
28   end
29   
30   def op_endpoint
31     "http://%s:%d/server/%s" % [@request.host, 
32                            @request.port, 
33                            (@request.params['openid.success'] ? '?openid.success=true' : '')]
34   end
35   
36 end