rack-federated-auth 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7a3b9cc3294b257b22d3bc26964624ce7a3fbdad
4
+ data.tar.gz: f54a181b05159635c8627196edd040874b00f592
5
+ SHA512:
6
+ metadata.gz: d75b156e61b55edd7349c63ed336fcf715751521020289304df7ce7e5eb6f0566d0f8cc073eb4c649dbe97ba36c3ac477a41b90597ca7a0075b4396e1c17c05f
7
+ data.tar.gz: 804dc05c88f395981706e32d994c0b6a6915eef04a6ac26c62c818fb23e966d6d9ea97b9bc8c6459f7a7d57ee8556d6248f6cf9b679f64a6ea237a07154a4df9
data/README.md CHANGED
@@ -12,7 +12,7 @@ Add it to your gemfile
12
12
 
13
13
  gem "rack-federated-auth"
14
14
 
15
- Use it in your Rack application
15
+ To Use it in your Rack application
16
16
 
17
17
  ``` ruby
18
18
  class MyApp < Sinatra::Base
@@ -29,6 +29,27 @@ class MyApp < Sinatra::Base
29
29
  end
30
30
  ```
31
31
 
32
+ To Use it in your Rails application, add the following to your config/application.rb
33
+
34
+ This example uses the google-openid provider, which also requires the 'omniauth-openid' gem
35
+
36
+ ``` ruby
37
+ require 'omniauth-openid'
38
+ require 'openid/store/filesystem'
39
+
40
+ config.middleware.insert_before(ActionDispatch::Static, Rack::Session::Cookie, :secret => ENV['SESSION_SECRET'])
41
+
42
+ config.middleware.insert_after(Rack::Session::Cookie, OmniAuth::Builder) do
43
+ provider :open_id, :store => OpenID::Store::Filesystem.new('/tmp')
44
+ end
45
+
46
+ config.middleware.insert_after(OmniAuth::Builder, RackFederatedAuth::Authentication) do |config|
47
+ config.email_filter = /yourdomain\.com$/
48
+ config.auth_url = "/auth/open_id?openid_url=www.google.com/accounts/o8/id"
49
+ end
50
+ ```
51
+
52
+
32
53
  The gem handles forwarding users to the authentication URL if they haven't authenticated,
33
54
  receiving the authentication callback, and setting the user's session so authentication isn't
34
55
  required before each page request.
@@ -10,6 +10,7 @@ module RackFederatedAuth
10
10
  attr_accessor :auth_url
11
11
  attr_accessor :success_url
12
12
  attr_accessor :failure_url
13
+ attr_accessor :public_path_regexes
13
14
 
14
15
  # Set up federated authentication
15
16
  #
@@ -25,11 +26,12 @@ module RackFederatedAuth
25
26
  @auth_scope = "authorized"
26
27
  @email_filter = /.*/
27
28
  @failure_message = "Authentication failed. Click <a href='#{@auth_url}'>here</a> to try again"
28
-
29
+
29
30
  @auth_prefix = "/auth"
30
31
  @auth_url = nil
31
32
  @success_url = '/'
32
33
  @failure_url = nil
34
+ @public_path_regexes = []
33
35
 
34
36
  yield self if block_given?
35
37
 
@@ -66,13 +68,13 @@ module RackFederatedAuth
66
68
  end
67
69
 
68
70
  private
69
-
71
+
70
72
  def authenticate!
71
73
  puts "New #{params[:service]} auth: #{request.env['omniauth.auth']}"
72
74
  begin
73
75
  if request.env['omniauth.auth']['info']['email'].match(@email_filter)
74
76
  puts "email matches filter, redirecting to #{@success_url}"
75
- session[@auth_scope] = true
77
+ session[@auth_scope] = true
76
78
  redirect @success_url
77
79
  else
78
80
  puts "email doesn't match filter, redirecting to #{@failure_url}"
@@ -86,7 +88,7 @@ module RackFederatedAuth
86
88
  end
87
89
 
88
90
  def authenticated?
89
- !session[@auth_scope].nil? and session[@auth_scope]
91
+ public_path_regexes.any? { |regex| request.path =~ regex } || (!session[@auth_scope].nil? && session[@auth_scope])
90
92
  end
91
93
  end
92
94
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = "rack-federated-auth"
5
- gem.version = "0.2.2"
5
+ gem.version = "0.3.0"
6
6
  gem.authors = ["Ryan Michael"]
7
7
  gem.email = ["kerinin@gmail.com"]
8
8
  gem.description = "Provides a simple authentication middleware to lock down Rack-based apps"
metadata CHANGED
@@ -1,68 +1,60 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-federated-auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
5
- prerelease:
4
+ version: 0.3.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Ryan Michael
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-08-09 00:00:00.000000000 Z
11
+ date: 2013-08-22 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: omniauth
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: sinatra
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: shoulda
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rdoc
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ~>
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ~>
76
67
  - !ruby/object:Gem::Version
@@ -78,7 +69,6 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: bundler
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ~>
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ~>
92
81
  - !ruby/object:Gem::Version
@@ -112,27 +101,26 @@ files:
112
101
  - test/test_rack-federated-auth.rb
113
102
  homepage: http://github.com/otherinbox/rack-federated_auth
114
103
  licenses: []
104
+ metadata: {}
115
105
  post_install_message:
116
106
  rdoc_options: []
117
107
  require_paths:
118
108
  - lib
119
109
  required_ruby_version: !ruby/object:Gem::Requirement
120
- none: false
121
110
  requirements:
122
- - - ! '>='
111
+ - - '>='
123
112
  - !ruby/object:Gem::Version
124
113
  version: '0'
125
114
  required_rubygems_version: !ruby/object:Gem::Requirement
126
- none: false
127
115
  requirements:
128
- - - ! '>='
116
+ - - '>='
129
117
  - !ruby/object:Gem::Version
130
118
  version: '0'
131
119
  requirements: []
132
120
  rubyforge_project:
133
- rubygems_version: 1.8.23
121
+ rubygems_version: 2.0.3
134
122
  signing_key:
135
- specification_version: 3
123
+ specification_version: 4
136
124
  summary: Omniauth middleware
137
125
  test_files:
138
126
  - test/helper.rb