exvo-auth 0.12.2 → 0.13.0
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/.gitignore +4 -1
- data/README.md +155 -0
- data/exvo-auth.gemspec +9 -4
- data/lib/exvo_auth/autonomous/auth.rb +1 -1
- data/lib/exvo_auth/config.rb +59 -20
- data/lib/exvo_auth/controllers/base.rb +2 -2
- data/lib/exvo_auth/strategies/base.rb +2 -2
- data/lib/exvo_auth/version.rb +1 -1
- data/test/helper.rb +0 -1
- data/test/test_exvo_auth.rb +32 -5
- data/test/test_integration.rb +2 -1
- metadata +124 -127
- data/README.markdown +0 -108
data/.gitignore
CHANGED
data/README.md
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# OAuth2
|
|
2
|
+
|
|
3
|
+
* Get familiar with [OmniAuth by Intridea](http://github.com/intridea/omniauth). Read about OAuth2.
|
|
4
|
+
* Obtain `client_id` and `client_secret` for your app from Exvo.
|
|
5
|
+
* Install `exvo-auth` gem and add it to your Gemfile.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## Middleware configuration
|
|
10
|
+
|
|
11
|
+
The preferred way to configure the gem is via the ENV variables:
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
ENV['AUTH_CLIENT_ID'] = "foo"
|
|
15
|
+
ENV['AUTH_CLIENT_SECRET'] = "bar"
|
|
16
|
+
ENV['AUTH_DEBUG'] = true # [OPTIONAL] dumps all HTTP traffic to STDERR, useful during development
|
|
17
|
+
ENV['AUTH_REQUIRE_SSL'] = false # [OPTIONAL] disable SSL, useful in development (note that all apps API urls must be http, not https)
|
|
18
|
+
ENV['AUTH_HOST'] = "test.exvo.com" # [OPTIONAL] override the default auth host
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Then add this line to `config/application.rb`:
|
|
22
|
+
|
|
23
|
+
```ruby
|
|
24
|
+
config.middleware.use ExvoAuth::Middleware
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
But you can also set things directly in the `config/application.rb` file (before the middleware declaration):
|
|
28
|
+
|
|
29
|
+
```ruby
|
|
30
|
+
ExvoAuth::Config.client_id = "foo"
|
|
31
|
+
ExvoAuth::Config.client_secret = "bar"
|
|
32
|
+
ExvoAuth::Config.debug = true
|
|
33
|
+
ExvoAuth::Config.require_ssl = false
|
|
34
|
+
ExvoAuth::Config.host = "test.exvo.com"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
## Add routes
|
|
39
|
+
|
|
40
|
+
The following comes from Rails `config/routes.rb` file:
|
|
41
|
+
|
|
42
|
+
```ruby
|
|
43
|
+
match "/auth/failure" => "sessions#failure"
|
|
44
|
+
match "/auth/interactive/callback" => "sessions#create"
|
|
45
|
+
match "/auth/non_interactive/callback" => "sessions#create" # only if you use json-based login
|
|
46
|
+
match "/sign_out" => "sessions#destroy"
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Failure url is called whenever there's a failure (d'oh).
|
|
50
|
+
|
|
51
|
+
You can have separate callbacks for interactive and non-interactive callback routes but you can also route both callbacks to the same controller method like shown above.
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
## Include controller helpers into your application controller
|
|
55
|
+
|
|
56
|
+
```ruby
|
|
57
|
+
include ExvoAuth::Controllers::Rails # (or Merb)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
## Implement a sessions controller
|
|
62
|
+
|
|
63
|
+
Sample implementation (Rails):
|
|
64
|
+
|
|
65
|
+
```ruby
|
|
66
|
+
class SessionsController < ApplicationController
|
|
67
|
+
def create
|
|
68
|
+
sign_in_and_redirect!
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def destroy
|
|
72
|
+
sign_out_and_redirect!
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def failure
|
|
76
|
+
render :text => "Sorry!"
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
## Implement `#find_or_create_user_by_uid(uid)` in your Application Controller
|
|
83
|
+
|
|
84
|
+
This method will be called by `#current_user`. Previously we did this in `sessions_controller` but since the sharing sessions changes this controller will not be used in most cases because the session comes from another app through a shared cookie. This method should find user by uid or create it.
|
|
85
|
+
|
|
86
|
+
Exemplary implementation (Rails):
|
|
87
|
+
|
|
88
|
+
```ruby
|
|
89
|
+
def find_or_create_user_by_uid(uid)
|
|
90
|
+
User.find_or_create_by_uid(uid)
|
|
91
|
+
end
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Additional info (emails, etc) can be obtained using auth api (`/users/uid.json` path).
|
|
95
|
+
|
|
96
|
+
In short: you get `params[:auth]`. Do what you want to do with it: store the data, create session, etc.
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
## Sign up and sign in paths for use in links
|
|
100
|
+
|
|
101
|
+
```ruby
|
|
102
|
+
sign in path: "/auth/interactive"
|
|
103
|
+
sign up path: "/auth/interactive?x_sign_up=true" # this is OAuth2 custom param
|
|
104
|
+
sign in path with a return address: "/auth/interactive?state=url" # using OAuth2 state param
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
You have a handy methods available in controllers (and views in Rails): `sign_in_path` and `sign_up_path`.
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
## Read the source, there are few features not mentioned in this README
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
# Inter-Application Communication
|
|
114
|
+
|
|
115
|
+
You need to have "App Authorization" created by Exvo first.
|
|
116
|
+
|
|
117
|
+
Contact us and provide following details:
|
|
118
|
+
|
|
119
|
+
* `consumer_id` - Id of an app that will be a consumer (this is you)
|
|
120
|
+
* `provider_id` - Id of the provider app
|
|
121
|
+
* `scope` - The tag associated with the api you want to use in the provider app
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
## Consumer side
|
|
125
|
+
|
|
126
|
+
```ruby
|
|
127
|
+
consumer = ExvoAuth::Autonomous::Consumer.new(
|
|
128
|
+
:app_id => "this is client_id of the app you want to connect to"
|
|
129
|
+
)
|
|
130
|
+
consumer.get(*args) # interface is exactly the same like in HTTParty. All http methods are available (post, put, delete, head, options).
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
## Provider side
|
|
135
|
+
|
|
136
|
+
See `#authenticate_app_in_scope!(scope)` method in `ExvoAuth::Controllers::Rails` (or Merb). This method lets you create a before filter.
|
|
137
|
+
Scopes are used by providing app to check if a given consuming app should have access to a given resource inside a scope.
|
|
138
|
+
If scopes are empty, then provider app should not present any resources to consumer.
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
## Example of the before filter for provider controller:
|
|
142
|
+
|
|
143
|
+
```ruby
|
|
144
|
+
before_filter {|c| c.authenticate_app_in_scope!("payments") }
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
In provider controller, which is just a fancy name for API controller, you can use `#current_app_id` method to get the app_id of the app connecting.
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
# Dejavu - replay non-GET requests after authentication redirects
|
|
151
|
+
|
|
152
|
+
## Limitations:
|
|
153
|
+
|
|
154
|
+
* doesn't work with file uploads
|
|
155
|
+
* all request params become query params when replayed
|
data/exvo-auth.gemspec
CHANGED
|
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
|
|
|
7
7
|
s.platform = Gem::Platform::RUBY
|
|
8
8
|
s.authors = ["Jacek Becela"]
|
|
9
9
|
s.email = ["jacek.becela@gmail.com"]
|
|
10
|
-
s.homepage = "
|
|
10
|
+
s.homepage = "https://github.com/Exvo/Auth"
|
|
11
11
|
s.summary = "Sign in with Exvo account"
|
|
12
12
|
s.description = "Sign in with Exvo account"
|
|
13
13
|
|
|
@@ -19,9 +19,14 @@ Gem::Specification.new do |s|
|
|
|
19
19
|
s.add_dependency "activemodel", "~> 3.0.0"
|
|
20
20
|
s.add_dependency "actionpack", "~> 3.0.0"
|
|
21
21
|
|
|
22
|
-
s.add_development_dependency "mocha"
|
|
23
|
-
s.add_development_dependency "test-unit"
|
|
24
|
-
s.add_development_dependency "bundler"
|
|
22
|
+
s.add_development_dependency "mocha"
|
|
23
|
+
s.add_development_dependency "test-unit"
|
|
24
|
+
s.add_development_dependency "bundler"
|
|
25
|
+
s.add_development_dependency "rake"
|
|
26
|
+
s.add_development_dependency "guard"
|
|
27
|
+
s.add_development_dependency "guard-test"
|
|
28
|
+
s.add_development_dependency "rb-fsevent"
|
|
29
|
+
s.add_development_dependency "rb-inotify"
|
|
25
30
|
|
|
26
31
|
s.files = `git ls-files`.split("\n")
|
|
27
32
|
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
|
data/lib/exvo_auth/config.rb
CHANGED
|
@@ -1,56 +1,95 @@
|
|
|
1
1
|
module ExvoAuth::Config
|
|
2
2
|
def self.debug
|
|
3
|
-
@@debug
|
|
4
|
-
@@debug
|
|
3
|
+
@@debug ||= ENV['AUTH_DEBUG'] || false
|
|
5
4
|
end
|
|
6
5
|
|
|
7
6
|
def self.debug=(debug)
|
|
8
7
|
@@debug = debug
|
|
9
8
|
end
|
|
10
9
|
|
|
11
|
-
def self.host
|
|
12
|
-
@@host ||= '
|
|
10
|
+
def self.host
|
|
11
|
+
@@host ||= ENV['AUTH_HOST'] || default_opts[env.to_sym][:host]
|
|
13
12
|
end
|
|
14
|
-
|
|
15
|
-
def self.host=(host)
|
|
16
|
-
@@host = host
|
|
13
|
+
|
|
14
|
+
def self.host=(host)
|
|
15
|
+
@@host = host
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.uri
|
|
19
|
+
if host =~ /^http(s)*/
|
|
20
|
+
# Legacy compatibility, when `host` was incorrectly used as `uri`
|
|
21
|
+
host
|
|
22
|
+
else
|
|
23
|
+
require_ssl ? "https://#{host}" : "http://#{host}"
|
|
24
|
+
end
|
|
17
25
|
end
|
|
18
|
-
|
|
26
|
+
|
|
19
27
|
def self.callback_key
|
|
20
28
|
@@callback_key ||= '_callback'
|
|
21
29
|
end
|
|
22
|
-
|
|
30
|
+
|
|
23
31
|
def self.callback_key=(callback_key)
|
|
24
|
-
@@callback_key = callback_key
|
|
32
|
+
@@callback_key = callback_key
|
|
25
33
|
end
|
|
26
|
-
|
|
34
|
+
|
|
27
35
|
def self.client_id
|
|
28
|
-
@@client_id ||=
|
|
36
|
+
@@client_id ||= ENV['AUTH_CLIENT_ID']
|
|
29
37
|
end
|
|
30
|
-
|
|
38
|
+
|
|
31
39
|
def self.client_id=(client_id)
|
|
32
40
|
@@client_id = client_id
|
|
33
41
|
end
|
|
34
|
-
|
|
42
|
+
|
|
35
43
|
def self.client_secret
|
|
36
|
-
@@client_secret ||=
|
|
44
|
+
@@client_secret ||= ENV['AUTH_CLIENT_SECRET']
|
|
37
45
|
end
|
|
38
46
|
|
|
39
47
|
def self.client_secret=(client_secret)
|
|
40
48
|
@@client_secret = client_secret
|
|
41
49
|
end
|
|
42
|
-
|
|
50
|
+
|
|
43
51
|
def self.require_ssl
|
|
44
|
-
@@require_ssl
|
|
45
|
-
@@require_ssl
|
|
52
|
+
@@require_ssl ||= ENV['AUTH_REQUIRE_SSL'] || default_opts[env.to_sym][:require_ssl]
|
|
46
53
|
end
|
|
47
54
|
|
|
48
|
-
# Set this to false during development ONLY!
|
|
49
55
|
def self.require_ssl=(require_ssl)
|
|
50
56
|
@@require_ssl = require_ssl
|
|
51
57
|
end
|
|
52
|
-
|
|
58
|
+
|
|
59
|
+
def self.env
|
|
60
|
+
@@env ||= Rails.env if defined?(Rails)
|
|
61
|
+
@@env ||= Merb.env if defined?(Merb)
|
|
62
|
+
@@env
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def self.env=(env)
|
|
66
|
+
@@env = env
|
|
67
|
+
end
|
|
68
|
+
|
|
53
69
|
def self.cfs_id
|
|
54
70
|
"fb0e7bd5864aa0186630212d800af8a6"
|
|
55
71
|
end
|
|
72
|
+
|
|
73
|
+
private
|
|
74
|
+
|
|
75
|
+
def self.default_opts
|
|
76
|
+
{
|
|
77
|
+
:production => {
|
|
78
|
+
:host => 'auth.exvo.com',
|
|
79
|
+
:require_ssl => true
|
|
80
|
+
},
|
|
81
|
+
:staging => {
|
|
82
|
+
:host => 'staging.auth.exvo.com',
|
|
83
|
+
:require_ssl => false
|
|
84
|
+
},
|
|
85
|
+
:development => {
|
|
86
|
+
:host => 'auth.exvo.local',
|
|
87
|
+
:require_ssl => false
|
|
88
|
+
},
|
|
89
|
+
:test => {
|
|
90
|
+
:host => 'auth.exvo.local',
|
|
91
|
+
:require_ssl => false
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
end
|
|
56
95
|
end
|
|
@@ -20,7 +20,7 @@ module ExvoAuth::Controllers::Base
|
|
|
20
20
|
session[:user_uid] = request.env["rack.request.query_hash"]["auth"]["uid"]
|
|
21
21
|
|
|
22
22
|
url = if params[:state] == "popup"
|
|
23
|
-
ExvoAuth::Config.
|
|
23
|
+
ExvoAuth::Config.uri + "/close_popup.html"
|
|
24
24
|
elsif params[:state] # if not popup then an url
|
|
25
25
|
params[:state]
|
|
26
26
|
else
|
|
@@ -81,7 +81,7 @@ module ExvoAuth::Controllers::Base
|
|
|
81
81
|
end
|
|
82
82
|
|
|
83
83
|
def sign_out_url(return_to)
|
|
84
|
-
ExvoAuth::Config.
|
|
84
|
+
ExvoAuth::Config.uri + "/users/sign_out?" + Rack::Utils.build_query({ :return_to => return_to })
|
|
85
85
|
end
|
|
86
86
|
|
|
87
87
|
def non_interactive_sign_in_path(params = {})
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
class ExvoAuth::Strategies::Base < OmniAuth::Strategies::OAuth2
|
|
2
2
|
def initialize(app, name, options = {})
|
|
3
|
-
options[:site] ||= ExvoAuth::Config.
|
|
3
|
+
options[:site] ||= ExvoAuth::Config.uri
|
|
4
4
|
options[:client_id] ||= ExvoAuth::Config.client_id
|
|
5
5
|
options[:client_secret] ||= ExvoAuth::Config.client_secret
|
|
6
6
|
|
|
7
7
|
if options[:site].nil? || options[:client_id].nil? || options[:client_secret].nil?
|
|
8
|
-
raise(ArgumentError, "Please configure
|
|
8
|
+
raise(ArgumentError, "Please configure uri, client_id and client_secret")
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
super(app, name, options.delete(:client_id), options.delete(:client_secret), options)
|
data/lib/exvo_auth/version.rb
CHANGED
data/test/helper.rb
CHANGED
data/test/test_exvo_auth.rb
CHANGED
|
@@ -5,13 +5,13 @@ class TestExvoAuth < Test::Unit::TestCase
|
|
|
5
5
|
ExvoAuth::Config.client_id = "foo"
|
|
6
6
|
ExvoAuth::Config.client_secret = "bar"
|
|
7
7
|
end
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
test "consumer sanity" do
|
|
10
10
|
c = ExvoAuth::Autonomous::Consumer.new(:app_id => "baz")
|
|
11
11
|
authorization = { "access_token" => "qux", "url" => "https://foo/api" }
|
|
12
12
|
auth = stub(:get => { "authorization" => authorization })
|
|
13
13
|
c.expects(:auth).returns(auth)
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
assert_equal authorization, c.send(:authorization)
|
|
16
16
|
assert_equal authorization, c.send(:authorization) # second time from cache, without touching httparty
|
|
17
17
|
end
|
|
@@ -20,11 +20,11 @@ class TestExvoAuth < Test::Unit::TestCase
|
|
|
20
20
|
p = ExvoAuth::Autonomous::Provider.new(:app_id => "baz", :access_token => "qux")
|
|
21
21
|
auth = stub(:get => {"scope" => "qux quux"})
|
|
22
22
|
p.expects(:auth).returns(auth)
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
assert_equal ["qux", "quux"], p.scopes
|
|
25
25
|
assert_equal ["qux", "quux"], p.scopes # second time from cache, without touching httparty
|
|
26
26
|
end
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
test "integration of httparty interface with auth" do
|
|
29
29
|
c = ExvoAuth::Autonomous::Consumer.new(:app_id => "baz")
|
|
30
30
|
basement = mock("basement")
|
|
@@ -34,9 +34,36 @@ class TestExvoAuth < Test::Unit::TestCase
|
|
|
34
34
|
c.expects(:basement).at_least_once.returns(basement)
|
|
35
35
|
assert_true c.get("/bar")
|
|
36
36
|
end
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
test "basement includes httparty" do
|
|
39
39
|
c = ExvoAuth::Autonomous::Consumer.new(:app_id => "baz")
|
|
40
40
|
assert_true c.send(:basement).included_modules.include?(HTTParty)
|
|
41
41
|
end
|
|
42
|
+
|
|
43
|
+
test "host setting based on production environment" do
|
|
44
|
+
ExvoAuth::Config.host = nil # invalidate memoization
|
|
45
|
+
ExvoAuth::Config.expects(:env).returns('production')
|
|
46
|
+
assert_equal ExvoAuth::Config.host, 'auth.exvo.com'
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
test "host setting based on development environment" do
|
|
50
|
+
ExvoAuth::Config.host = nil # invalidate memoization
|
|
51
|
+
ExvoAuth::Config.expects(:env).returns('development')
|
|
52
|
+
assert_equal ExvoAuth::Config.host, 'auth.exvo.local'
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
test "ssl not being required by default in development environment" do
|
|
56
|
+
ExvoAuth::Config.require_ssl = nil # invalidate memoization
|
|
57
|
+
ExvoAuth::Config.expects(:env).returns('development')
|
|
58
|
+
assert_false ExvoAuth::Config.require_ssl
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
test "ENV setting overrides default auth host setting" do
|
|
62
|
+
ExvoAuth::Config.host = nil # invalidate memoization
|
|
63
|
+
host = 'test.exvo.com'
|
|
64
|
+
ENV['AUTH_HOST'] = host
|
|
65
|
+
ExvoAuth::Config.expects(:env).at_least(0)
|
|
66
|
+
assert_equal host, ExvoAuth::Config.host
|
|
67
|
+
ENV['AUTH_HOST'] = nil
|
|
68
|
+
end
|
|
42
69
|
end
|
data/test/test_integration.rb
CHANGED
|
@@ -2,10 +2,11 @@ require 'helper'
|
|
|
2
2
|
|
|
3
3
|
class TestIntegration < Test::Unit::TestCase
|
|
4
4
|
def setup
|
|
5
|
-
ExvoAuth::Config.host = "
|
|
5
|
+
ExvoAuth::Config.host = "staging.auth.exvo.com"
|
|
6
6
|
ExvoAuth::Config.client_id = "foo"
|
|
7
7
|
ExvoAuth::Config.client_secret = "bar"
|
|
8
8
|
ExvoAuth::Config.debug = true
|
|
9
|
+
ExvoAuth::Config.require_ssl = true
|
|
9
10
|
end
|
|
10
11
|
|
|
11
12
|
test "integration with staging.auth.exvo.com" do
|
metadata
CHANGED
|
@@ -1,148 +1,158 @@
|
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: exvo-auth
|
|
3
|
-
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
5
|
-
prerelease:
|
|
6
|
-
segments:
|
|
7
|
-
- 0
|
|
8
|
-
- 12
|
|
9
|
-
- 2
|
|
10
|
-
version: 0.12.2
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.13.0
|
|
5
|
+
prerelease:
|
|
11
6
|
platform: ruby
|
|
12
|
-
authors:
|
|
7
|
+
authors:
|
|
13
8
|
- Jacek Becela
|
|
14
9
|
autorequire:
|
|
15
10
|
bindir: bin
|
|
16
11
|
cert_chain: []
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
dependencies:
|
|
21
|
-
- !ruby/object:Gem::Dependency
|
|
12
|
+
date: 2011-11-03 00:00:00.000000000Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
22
15
|
name: oa-oauth
|
|
23
|
-
|
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
|
16
|
+
requirement: &83727760 !ruby/object:Gem::Requirement
|
|
25
17
|
none: false
|
|
26
|
-
requirements:
|
|
18
|
+
requirements:
|
|
27
19
|
- - ~>
|
|
28
|
-
- !ruby/object:Gem::Version
|
|
29
|
-
hash: 23
|
|
30
|
-
segments:
|
|
31
|
-
- 0
|
|
32
|
-
- 0
|
|
33
|
-
- 4
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
34
21
|
version: 0.0.4
|
|
35
22
|
type: :runtime
|
|
36
|
-
version_requirements: *id001
|
|
37
|
-
- !ruby/object:Gem::Dependency
|
|
38
|
-
name: httparty
|
|
39
23
|
prerelease: false
|
|
40
|
-
|
|
24
|
+
version_requirements: *83727760
|
|
25
|
+
- !ruby/object:Gem::Dependency
|
|
26
|
+
name: httparty
|
|
27
|
+
requirement: &83727530 !ruby/object:Gem::Requirement
|
|
41
28
|
none: false
|
|
42
|
-
requirements:
|
|
29
|
+
requirements:
|
|
43
30
|
- - ~>
|
|
44
|
-
- !ruby/object:Gem::Version
|
|
45
|
-
hash: 5
|
|
46
|
-
segments:
|
|
47
|
-
- 0
|
|
48
|
-
- 6
|
|
49
|
-
- 1
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
50
32
|
version: 0.6.1
|
|
51
33
|
type: :runtime
|
|
52
|
-
version_requirements: *id002
|
|
53
|
-
- !ruby/object:Gem::Dependency
|
|
54
|
-
name: activemodel
|
|
55
34
|
prerelease: false
|
|
56
|
-
|
|
35
|
+
version_requirements: *83727530
|
|
36
|
+
- !ruby/object:Gem::Dependency
|
|
37
|
+
name: activemodel
|
|
38
|
+
requirement: &83727300 !ruby/object:Gem::Requirement
|
|
57
39
|
none: false
|
|
58
|
-
requirements:
|
|
40
|
+
requirements:
|
|
59
41
|
- - ~>
|
|
60
|
-
- !ruby/object:Gem::Version
|
|
61
|
-
hash: 7
|
|
62
|
-
segments:
|
|
63
|
-
- 3
|
|
64
|
-
- 0
|
|
65
|
-
- 0
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
66
43
|
version: 3.0.0
|
|
67
44
|
type: :runtime
|
|
68
|
-
version_requirements: *id003
|
|
69
|
-
- !ruby/object:Gem::Dependency
|
|
70
|
-
name: actionpack
|
|
71
45
|
prerelease: false
|
|
72
|
-
|
|
46
|
+
version_requirements: *83727300
|
|
47
|
+
- !ruby/object:Gem::Dependency
|
|
48
|
+
name: actionpack
|
|
49
|
+
requirement: &83727070 !ruby/object:Gem::Requirement
|
|
73
50
|
none: false
|
|
74
|
-
requirements:
|
|
51
|
+
requirements:
|
|
75
52
|
- - ~>
|
|
76
|
-
- !ruby/object:Gem::Version
|
|
77
|
-
hash: 7
|
|
78
|
-
segments:
|
|
79
|
-
- 3
|
|
80
|
-
- 0
|
|
81
|
-
- 0
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
82
54
|
version: 3.0.0
|
|
83
55
|
type: :runtime
|
|
84
|
-
version_requirements: *id004
|
|
85
|
-
- !ruby/object:Gem::Dependency
|
|
86
|
-
name: mocha
|
|
87
56
|
prerelease: false
|
|
88
|
-
|
|
57
|
+
version_requirements: *83727070
|
|
58
|
+
- !ruby/object:Gem::Dependency
|
|
59
|
+
name: mocha
|
|
60
|
+
requirement: &83726880 !ruby/object:Gem::Requirement
|
|
89
61
|
none: false
|
|
90
|
-
requirements:
|
|
91
|
-
- -
|
|
92
|
-
- !ruby/object:Gem::Version
|
|
93
|
-
|
|
94
|
-
segments:
|
|
95
|
-
- 0
|
|
96
|
-
- 9
|
|
97
|
-
- 8
|
|
98
|
-
version: 0.9.8
|
|
62
|
+
requirements:
|
|
63
|
+
- - ! '>='
|
|
64
|
+
- !ruby/object:Gem::Version
|
|
65
|
+
version: '0'
|
|
99
66
|
type: :development
|
|
100
|
-
version_requirements: *id005
|
|
101
|
-
- !ruby/object:Gem::Dependency
|
|
102
|
-
name: test-unit
|
|
103
67
|
prerelease: false
|
|
104
|
-
|
|
68
|
+
version_requirements: *83726880
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: test-unit
|
|
71
|
+
requirement: &83726650 !ruby/object:Gem::Requirement
|
|
105
72
|
none: false
|
|
106
|
-
requirements:
|
|
107
|
-
- -
|
|
108
|
-
- !ruby/object:Gem::Version
|
|
109
|
-
|
|
110
|
-
segments:
|
|
111
|
-
- 2
|
|
112
|
-
- 1
|
|
113
|
-
- 0
|
|
114
|
-
version: 2.1.0
|
|
73
|
+
requirements:
|
|
74
|
+
- - ! '>='
|
|
75
|
+
- !ruby/object:Gem::Version
|
|
76
|
+
version: '0'
|
|
115
77
|
type: :development
|
|
116
|
-
|
|
117
|
-
|
|
78
|
+
prerelease: false
|
|
79
|
+
version_requirements: *83726650
|
|
80
|
+
- !ruby/object:Gem::Dependency
|
|
118
81
|
name: bundler
|
|
82
|
+
requirement: &83726440 !ruby/object:Gem::Requirement
|
|
83
|
+
none: false
|
|
84
|
+
requirements:
|
|
85
|
+
- - ! '>='
|
|
86
|
+
- !ruby/object:Gem::Version
|
|
87
|
+
version: '0'
|
|
88
|
+
type: :development
|
|
119
89
|
prerelease: false
|
|
120
|
-
|
|
90
|
+
version_requirements: *83726440
|
|
91
|
+
- !ruby/object:Gem::Dependency
|
|
92
|
+
name: rake
|
|
93
|
+
requirement: &83726230 !ruby/object:Gem::Requirement
|
|
121
94
|
none: false
|
|
122
|
-
requirements:
|
|
123
|
-
- -
|
|
124
|
-
- !ruby/object:Gem::Version
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
95
|
+
requirements:
|
|
96
|
+
- - ! '>='
|
|
97
|
+
- !ruby/object:Gem::Version
|
|
98
|
+
version: '0'
|
|
99
|
+
type: :development
|
|
100
|
+
prerelease: false
|
|
101
|
+
version_requirements: *83726230
|
|
102
|
+
- !ruby/object:Gem::Dependency
|
|
103
|
+
name: guard
|
|
104
|
+
requirement: &83726020 !ruby/object:Gem::Requirement
|
|
105
|
+
none: false
|
|
106
|
+
requirements:
|
|
107
|
+
- - ! '>='
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: '0'
|
|
110
|
+
type: :development
|
|
111
|
+
prerelease: false
|
|
112
|
+
version_requirements: *83726020
|
|
113
|
+
- !ruby/object:Gem::Dependency
|
|
114
|
+
name: guard-test
|
|
115
|
+
requirement: &83725810 !ruby/object:Gem::Requirement
|
|
116
|
+
none: false
|
|
117
|
+
requirements:
|
|
118
|
+
- - ! '>='
|
|
119
|
+
- !ruby/object:Gem::Version
|
|
120
|
+
version: '0'
|
|
131
121
|
type: :development
|
|
132
|
-
|
|
122
|
+
prerelease: false
|
|
123
|
+
version_requirements: *83725810
|
|
124
|
+
- !ruby/object:Gem::Dependency
|
|
125
|
+
name: rb-fsevent
|
|
126
|
+
requirement: &83725600 !ruby/object:Gem::Requirement
|
|
127
|
+
none: false
|
|
128
|
+
requirements:
|
|
129
|
+
- - ! '>='
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '0'
|
|
132
|
+
type: :development
|
|
133
|
+
prerelease: false
|
|
134
|
+
version_requirements: *83725600
|
|
135
|
+
- !ruby/object:Gem::Dependency
|
|
136
|
+
name: rb-inotify
|
|
137
|
+
requirement: &83725390 !ruby/object:Gem::Requirement
|
|
138
|
+
none: false
|
|
139
|
+
requirements:
|
|
140
|
+
- - ! '>='
|
|
141
|
+
- !ruby/object:Gem::Version
|
|
142
|
+
version: '0'
|
|
143
|
+
type: :development
|
|
144
|
+
prerelease: false
|
|
145
|
+
version_requirements: *83725390
|
|
133
146
|
description: Sign in with Exvo account
|
|
134
|
-
email:
|
|
147
|
+
email:
|
|
135
148
|
- jacek.becela@gmail.com
|
|
136
149
|
executables: []
|
|
137
|
-
|
|
138
150
|
extensions: []
|
|
139
|
-
|
|
140
151
|
extra_rdoc_files: []
|
|
141
|
-
|
|
142
|
-
files:
|
|
152
|
+
files:
|
|
143
153
|
- .gitignore
|
|
144
154
|
- Gemfile
|
|
145
|
-
- README.
|
|
155
|
+
- README.md
|
|
146
156
|
- Rakefile
|
|
147
157
|
- exvo-auth.gemspec
|
|
148
158
|
- lib/exvo-auth.rb
|
|
@@ -169,41 +179,28 @@ files:
|
|
|
169
179
|
- test/helper.rb
|
|
170
180
|
- test/test_exvo_auth.rb
|
|
171
181
|
- test/test_integration.rb
|
|
172
|
-
|
|
173
|
-
homepage: http://rubygems.org/gems/exvo-auth
|
|
182
|
+
homepage: https://github.com/Exvo/Auth
|
|
174
183
|
licenses: []
|
|
175
|
-
|
|
176
184
|
post_install_message:
|
|
177
185
|
rdoc_options: []
|
|
178
|
-
|
|
179
|
-
require_paths:
|
|
186
|
+
require_paths:
|
|
180
187
|
- lib
|
|
181
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
|
188
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
182
189
|
none: false
|
|
183
|
-
requirements:
|
|
184
|
-
- -
|
|
185
|
-
- !ruby/object:Gem::Version
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
- 0
|
|
189
|
-
version: "0"
|
|
190
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
190
|
+
requirements:
|
|
191
|
+
- - ! '>='
|
|
192
|
+
- !ruby/object:Gem::Version
|
|
193
|
+
version: '0'
|
|
194
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
191
195
|
none: false
|
|
192
|
-
requirements:
|
|
193
|
-
- -
|
|
194
|
-
- !ruby/object:Gem::Version
|
|
195
|
-
hash: 23
|
|
196
|
-
segments:
|
|
197
|
-
- 1
|
|
198
|
-
- 3
|
|
199
|
-
- 6
|
|
196
|
+
requirements:
|
|
197
|
+
- - ! '>='
|
|
198
|
+
- !ruby/object:Gem::Version
|
|
200
199
|
version: 1.3.6
|
|
201
200
|
requirements: []
|
|
202
|
-
|
|
203
201
|
rubyforge_project: exvo-auth
|
|
204
|
-
rubygems_version: 1.
|
|
202
|
+
rubygems_version: 1.8.10
|
|
205
203
|
signing_key:
|
|
206
204
|
specification_version: 3
|
|
207
205
|
summary: Sign in with Exvo account
|
|
208
206
|
test_files: []
|
|
209
|
-
|
data/README.markdown
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
#OAuth2
|
|
2
|
-
|
|
3
|
-
- Get familiar with OmniAuth by Intridea: http://github.com/intridea/omniauth. Read about OAuth2.
|
|
4
|
-
- Obtain client_id and client_secret for your app from Exvo.
|
|
5
|
-
- Install exvo-auth gem or add it to your Gemfile.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
##Configure middleware.
|
|
9
|
-
|
|
10
|
-
In Rails, the relevant lines could look like this:
|
|
11
|
-
|
|
12
|
-
ExvoAuth::Config.client_id = "foo"
|
|
13
|
-
ExvoAuth::Config.client_secret = "bar"
|
|
14
|
-
ExvoAuth::Config.debug = true # dumps all HTTP traffic to STDERR, useful during development.
|
|
15
|
-
config.middleware.use ExvoAuth::Middleware
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
##Add routes.
|
|
19
|
-
|
|
20
|
-
The following comes from Rails config/routes.rb file:
|
|
21
|
-
|
|
22
|
-
match "/auth/failure" => "sessions#failure"
|
|
23
|
-
match "/auth/interactive/callback" => "sessions#create"
|
|
24
|
-
match "/auth/non_interactive/callback" => "sessions#create" # only if you use json-based login
|
|
25
|
-
match "/sign_out" => "sessions#destroy"
|
|
26
|
-
|
|
27
|
-
Failure url is called whenever there's a failure (d'oh).
|
|
28
|
-
You can have separate callbacks for interactive and non-interactive
|
|
29
|
-
callback routes but you can also route both callbacks to the same controller method
|
|
30
|
-
like shown above.
|
|
31
|
-
|
|
32
|
-
##Include controller helpers into your application controller.
|
|
33
|
-
|
|
34
|
-
include ExvoAuth::Controllers::Rails (or Merb)
|
|
35
|
-
|
|
36
|
-
##Implement a sessions controller.
|
|
37
|
-
|
|
38
|
-
Sample implementation (Rails):
|
|
39
|
-
|
|
40
|
-
class SessionsController < ApplicationController
|
|
41
|
-
def create
|
|
42
|
-
sign_in_and_redirect!
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def destroy
|
|
46
|
-
sign_out_and_redirect!
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def failure
|
|
50
|
-
render :text => "Sorry!"
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
##Implement #find_or_create_user_by_uid(uid) in your Application Controller.
|
|
55
|
-
|
|
56
|
-
This method will be called by #current_user. Previously we did this in sessions_controller but since the sharing sessions changes this controller
|
|
57
|
-
will not be used in most cases because the session comes from another app through a shared cookie. This method should find user by uid or create it.
|
|
58
|
-
Additional info (emails, etc) can be obtained using auth api (/users/uid.json path).
|
|
59
|
-
|
|
60
|
-
In short: you get params[:auth]. Do what you want to do with it: store the data, create session, etc.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
##Sign up and sign in paths for use in links.
|
|
64
|
-
|
|
65
|
-
sign in path: "/auth/interactive"
|
|
66
|
-
sign up path: "/auth/interactive?x_sign_up=true" # this is OAuth2 custom param
|
|
67
|
-
sign in path with a return address: "/auth/interactive?state=url" # using OAuth2 state param
|
|
68
|
-
|
|
69
|
-
You have a handy methods available in controllers (and views in Rails): sign_in_path and sign_up_path.
|
|
70
|
-
|
|
71
|
-
##Read the source, there are few features not mentioned in this README.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
#Inter-Application Communication
|
|
75
|
-
|
|
76
|
-
You need to have "App Authorization" created by Exvo first.
|
|
77
|
-
Contact us and provide following details:
|
|
78
|
-
|
|
79
|
-
- consumer_id - Id of an app that will be a consumer (this is you)
|
|
80
|
-
- provider_id - Id of the provider app
|
|
81
|
-
- scope - The tag associated with the api you want to use in the provider app
|
|
82
|
-
|
|
83
|
-
##Consumer side
|
|
84
|
-
|
|
85
|
-
consumer = ExvoAuth::Autonomous::Consumer.new(
|
|
86
|
-
:app_id => "this is client_id of the app you want to connect to"
|
|
87
|
-
)
|
|
88
|
-
consumer.get(*args) - interface is exactly the same like in HTTParty. All http methods are available (post, put, delete, head, options).
|
|
89
|
-
|
|
90
|
-
##Provider side
|
|
91
|
-
|
|
92
|
-
See #authenticate_app_in_scope!(scope) method in ExvoAuth::Controllers::Rails (or Merb). This method lets you create a before filter.
|
|
93
|
-
Scopes are used by providing app to check if a given consuming app should have access to a given resource inside a scope.
|
|
94
|
-
If scopes are empty, then provider app should not present any resources to consumer.
|
|
95
|
-
|
|
96
|
-
##Example of the before filter for provider controller:
|
|
97
|
-
|
|
98
|
-
before_filter {|c| c.authenticate_app_in_scope!("payments") }
|
|
99
|
-
|
|
100
|
-
In provider controller which is just a fancy name for API controller you can use #current_app_id method to get the app_id of the app connecting.
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
#Dejavu - replay non-GET requests after authentication redirects
|
|
104
|
-
|
|
105
|
-
##Limitations:
|
|
106
|
-
|
|
107
|
-
- doesn't work with file uploads
|
|
108
|
-
- all request params become query params when replayed
|