rack-rpx 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/examples/login-app.rb +2 -2
- data/examples/views/login.haml +1 -1
- data/lib/rack-rpx.rb +15 -23
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/examples/login-app.rb
CHANGED
@@ -6,9 +6,9 @@ require 'lib/rack-rpx'
|
|
6
6
|
|
7
7
|
use Rack::Session::Cookie
|
8
8
|
|
9
|
-
use Rack::Rpx, :
|
9
|
+
use Rack::Rpx, :port => '9393',
|
10
10
|
:api_key => '5b17163d199813f86e51fc3282ffc4298a40cc44',
|
11
|
-
:callback_path => 'login_completed'
|
11
|
+
:callback_path => '/login_completed'
|
12
12
|
|
13
13
|
helpers do
|
14
14
|
include Rack::Rpx::Methods
|
data/examples/views/login.haml
CHANGED
@@ -5,5 +5,5 @@
|
|
5
5
|
RPXNOW.language_preference = 'en';
|
6
6
|
|
7
7
|
|
8
|
-
%a.rpxnow{ :href => "
|
8
|
+
%a.rpxnow{ :href => login_widget_url("olokun"), :onclick => "return false;" }
|
9
9
|
Sign In
|
data/lib/rack-rpx.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
%w(rubygems net/http net/https rack json).each { |gem| require gem }
|
2
|
-
|
3
2
|
module Rack #:nodoc:
|
4
3
|
|
5
4
|
# Rack Middleware for integrating RPX Now into your application
|
@@ -8,26 +7,17 @@ module Rack #:nodoc:
|
|
8
7
|
#
|
9
8
|
class Rpx
|
10
9
|
OPTIONS = {
|
11
|
-
:login_path
|
12
|
-
:callback_path
|
13
|
-
:
|
14
|
-
:
|
15
|
-
:rack_session
|
10
|
+
:login_path => '/login',
|
11
|
+
:callback_path => '/login_completed',
|
12
|
+
:host => 'localhost',
|
13
|
+
:port => '80',
|
14
|
+
:rack_session => 'rack.session'
|
16
15
|
}
|
17
|
-
|
18
|
-
def login_path
|
19
|
-
OPTIONS[:login_path]
|
20
|
-
end
|
21
|
-
|
22
|
-
def callback_path
|
23
|
-
OPTIONS[:callback_path]
|
24
|
-
end
|
25
|
-
|
16
|
+
|
26
17
|
# Helper methods intended to be included in your Rails controller or
|
27
18
|
# in your Sinatra helpers block
|
28
19
|
module Methods
|
29
|
-
|
30
|
-
RPX_LOGIN_URL = "https://#{RPX_API_URL}"
|
20
|
+
RPX_LOGIN_URL = "https://rpxnow.com/api/v2/auth_info"
|
31
21
|
|
32
22
|
# This is *the* method you want to call.
|
33
23
|
#
|
@@ -47,23 +37,25 @@ module Rack #:nodoc:
|
|
47
37
|
raise LoginFailedError, 'Cannot log in. Try another account!' unless json['stat'] == 'ok'
|
48
38
|
json
|
49
39
|
end
|
40
|
+
|
41
|
+
def login_widget_url(app_name)
|
42
|
+
"https://#{app_name}.rpxnow.com/openid/v2/signin?token_url=#{callback_url}"
|
43
|
+
end
|
50
44
|
|
51
45
|
|
52
|
-
def
|
53
|
-
|
46
|
+
def callback_url
|
47
|
+
"http://#{OPTIONS[:host]}:#{OPTIONS[:port]}#{OPTIONS[:callback_path]}"
|
54
48
|
end
|
55
|
-
|
56
49
|
end
|
57
50
|
|
58
51
|
def initialize app, *args
|
59
52
|
@app = app
|
60
53
|
arg_options = args.pop
|
61
|
-
|
62
|
-
OPTIONS.merge! arg_options
|
54
|
+
OPTIONS.merge! arg_options
|
63
55
|
end
|
64
56
|
|
65
57
|
def call env
|
66
|
-
@app.call(env)
|
58
|
+
@app.call(env)
|
67
59
|
end
|
68
60
|
end
|
69
61
|
end
|