exvo-auth 0.4.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/TODO ADDED
@@ -0,0 +1,3 @@
1
+ * Add a way for apps to talk to each other: ssl + basic auth with client_id and client_secret. An app would confirm
2
+ creds (of the connecting app) with Auth app using a speedy HEAD request.
3
+ * Benchmark the above to measure RTT footprint
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.3
1
+ 0.5.0
data/exvo-auth.gemspec CHANGED
@@ -5,22 +5,24 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{exvo-auth}
8
- s.version = "0.4.3"
8
+ s.version = "0.5.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jacek Becela"]
12
- s.date = %q{2010-07-12}
12
+ s.date = %q{2010-07-13}
13
13
  s.description = %q{Sign in with Exvo account}
14
14
  s.email = %q{jacek.becela@gmail.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
- "README"
17
+ "README",
18
+ "TODO"
18
19
  ]
19
20
  s.files = [
20
21
  ".gitignore",
21
22
  "LICENSE",
22
23
  "README",
23
24
  "Rakefile",
25
+ "TODO",
24
26
  "VERSION",
25
27
  "exvo-auth.gemspec",
26
28
  "lib/exvo-auth.rb",
@@ -1,4 +1,9 @@
1
1
  module ExvoAuth::Controllers::Base
2
+ def self.included(base)
3
+ raise "Please define a #root_url method in #{base.name} (or in routes)" unless base.method_defined? :root_url
4
+ end
5
+
6
+ # A before filter to protect your sensitive actions.
2
7
  def authenticate_user!
3
8
  if !signed_in?
4
9
  store_location!
@@ -9,7 +14,7 @@ module ExvoAuth::Controllers::Base
9
14
  if callback_value
10
15
  redirect_to non_interactive_sign_in_path(callback_key => callback_value)
11
16
  else
12
- redirect_to sign_in_path
17
+ redirect_to "/auth/interactive"
13
18
  end
14
19
  end
15
20
  end
@@ -17,15 +22,28 @@ module ExvoAuth::Controllers::Base
17
22
  # If there's no stored location then it's a popup login.
18
23
  # If there's a stored location then it's a redirect login
19
24
  # caused by #authenticate_user! method.
25
+ #
26
+ # Usually this method is called from your sessions#create.
20
27
  def sign_in_and_redirect!(user_id)
21
28
  session[:user_id] = user_id
22
- redirect_to stored_location || ExvoAuth::Config.host + "/close_popup.html"
29
+
30
+ url = if params[:state] == "popup"
31
+ ExvoAuth::Config.host + "/close_popup.html"
32
+ else
33
+ stored_location || root_url
34
+ end
35
+
36
+ redirect_to url
23
37
  end
24
38
 
25
- def sign_out_and_redirect!(url = sign_out_url)
39
+ # Redirect to sign_out_url, signs out and redirects back to root_path (by default).
40
+ # This method assumes you have a "root_url" method defined in your controller.
41
+ #
42
+ # Usuallly this method is called from your sessions#destroy.
43
+ def sign_out_and_redirect!(return_to = root_url)
26
44
  session.delete(:user_id)
27
45
  @current_user = nil
28
- redirect_to url
46
+ redirect_to sign_out_url(return_to)
29
47
  end
30
48
 
31
49
  def current_user
@@ -37,6 +55,8 @@ module ExvoAuth::Controllers::Base
37
55
  !!current_user
38
56
  end
39
57
 
58
+ protected
59
+
40
60
  def store_location!
41
61
  session[:return_to] = current_url
42
62
  end
@@ -45,16 +65,8 @@ module ExvoAuth::Controllers::Base
45
65
  session.delete(:return_to)
46
66
  end
47
67
 
48
- def sign_in_path
49
- "/auth/interactive"
50
- end
51
-
52
- def sign_up_path
53
- "/auth/interactive"
54
- end
55
-
56
- def sign_out_url
57
- ExvoAuth::Config.host + "/users/sign_out"
68
+ def sign_out_url(return_to)
69
+ ExvoAuth::Config.host + "/users/sign_out?" + Rack::Utils.build_query({ :return_to => return_to })
58
70
  end
59
71
 
60
72
  def non_interactive_sign_in_path(params = {})
@@ -10,10 +10,12 @@ module ExvoAuth::Controllers::Merb
10
10
  throw :halt unless signed_in?
11
11
  end
12
12
 
13
+ protected
14
+
13
15
  def redirect_to(*args)
14
16
  redirect(*args)
15
17
  end
16
-
18
+
17
19
  def find_user_by_id(id)
18
20
  User[id]
19
21
  end
@@ -2,10 +2,12 @@ module ExvoAuth::Controllers::Rails
2
2
  def self.included(base)
3
3
  base.send :include, ExvoAuth::Controllers::Base
4
4
  base.send :include, InstanceMethods
5
- base.helper_method :current_user, :signed_in?, :sign_in_path, :sign_up_path, :sign_out_url
5
+ base.helper_method :current_user, :signed_in?
6
6
  end
7
7
 
8
8
  module InstanceMethods
9
+ protected
10
+
9
11
  def find_user_by_id(id)
10
12
  User.find(id)
11
13
  end
@@ -4,6 +4,6 @@ class ExvoAuth::Strategies::Interactive < ExvoAuth::Strategies::Base
4
4
  end
5
5
 
6
6
  def request_phase(options = {})
7
- super(:scope => request["scope"])
7
+ super(:scope => request["scope"], :state => request["state"])
8
8
  end
9
9
  end
@@ -4,7 +4,7 @@ class ExvoAuth::Strategies::NonInteractive < ExvoAuth::Strategies::Base
4
4
  end
5
5
 
6
6
  def request_phase(options = {})
7
- redirect @client.non_interactive.authorize_url(:redirect_uri => callback_url, :scope => request["scope"])
7
+ redirect @client.non_interactive.authorize_url(:redirect_uri => callback_url, :scope => request["scope"], :state => request["state"])
8
8
  end
9
9
 
10
10
  def callback_url
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 4
8
- - 3
9
- version: 0.4.3
7
+ - 5
8
+ - 0
9
+ version: 0.5.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jacek Becela
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-07-12 00:00:00 +02:00
17
+ date: 2010-07-13 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -40,11 +40,13 @@ extensions: []
40
40
  extra_rdoc_files:
41
41
  - LICENSE
42
42
  - README
43
+ - TODO
43
44
  files:
44
45
  - .gitignore
45
46
  - LICENSE
46
47
  - README
47
48
  - Rakefile
49
+ - TODO
48
50
  - VERSION
49
51
  - exvo-auth.gemspec
50
52
  - lib/exvo-auth.rb