gatekeeper 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,10 +1,77 @@
1
1
  = Gatekeeper
2
2
 
3
3
  Gatekeeper can connect any Rack-compatible application to a Hot Ink SSO server. It allows you to easily verify the identity of a user against Hot Ink's
4
- user information database. It makes some basic information about the user available to you application.
4
+ user information database. It makes some basic information about the user available to your application.
5
5
 
6
6
  Gatekeeper is largely a rewrite of Hancock-Client (http://github.com/atmos/hancock-client). The functionality is different but the spirit is the same.
7
7
 
8
+ == Installation
9
+
10
+ This is the easy part.
11
+
12
+ gem install gatekeeper --source http://gemcutter.org
13
+
14
+ == Using Gatekeeper
15
+
16
+ Gatekeeper is implemented in Sinatra, but it can authenticate any Rack-based application. That could be Rails, Sinatra, Rack whatever. You'll be
17
+ surprised how easy it is.
18
+
19
+ Simply add the following into your Rack stack, by simply placing it directly into your Sinatra app as middleware, or if you're building a Rack app,
20
+ add it to your stack in <tt>config.ru</tt>:
21
+
22
+ use Rack::Session::Cookie
23
+ use Gatekeeper::Middleware do |sso|
24
+ sso.sso_url = "http://your_sso_server.net/sso"
25
+ end
26
+
27
+ Be sure to use the session middleware when building a Rack app, or to <tt>enable :sessions</tt> when using Sinatra. Gatekeeper relies on sessions
28
+ to store authentication information. Also be sure to include the correct SSO server URL.
29
+
30
+ === With Rails
31
+
32
+ When using Gatekeeper with Rails, you should create a 'metal' Sinatra app to keep it in, then implement it as show above. It's pretty easy, just
33
+ run <tt>script/generate metal sso</tt>. Inside, you should have:
34
+
35
+ require(File.dirname(__FILE__) + "/../../config/environment") unless defined?(Rails)
36
+ require 'sinatra/base'
37
+ require 'logger'
38
+
39
+ class Sso < Sinatra::Base
40
+ use Gatekeeper::Middleware do |sso|
41
+ sso.sso_url = "http://your_sso_server.net/sso"
42
+ end
43
+ end
44
+
45
+ When using Rails, you should be sure *not* to <tt>enable sessions</tt> in your Sinatra metal. Rails takes care of the session. If you re-enable, you'll overwrite what Rails
46
+ has already found and your authentication will not work
47
+
48
+ === In your app
49
+
50
+ Gatekeeper puts the received user details in a hash accessible using session[:sso]. Things are a little more convenient using the helpers. To do
51
+ that, simply include Gatekeeper::Helpers::Authentication in your app. You can then use the following methods:
52
+
53
+ * current_user
54
+
55
+ Will return +nil+ or the current user's id, depending on whether or not the user is logged in.
56
+
57
+ * is_admin?
58
+
59
+ Is this user a Hot Ink admin? You may have some tasks that only admin users can do.
60
+
61
+ * is_manager_of?(hotink_account_id)
62
+
63
+ Will return true if the user is a manager of the account who's id you passed in.
64
+
65
+ Your app can use a simple +require_user+ method as a before filter to ensure that users are logged in, the most basic of which could look like this:
66
+
67
+ def require_user
68
+ unless current_user
69
+ redirect_to "/sso/login?return_to=#{request.request_uri}"
70
+ false # if you're using this as a Rails before filter, return false
71
+ end
72
+ end
73
+
74
+
8
75
  == Note on Patches/Pull Requests
9
76
 
10
77
  * Fork the project.
data/Rakefile CHANGED
@@ -10,6 +10,9 @@ begin
10
10
  gem.email = "chrisgdinn@gmail.com"
11
11
  gem.homepage = "http://github.com/chrisdinn/gatekeeper"
12
12
  gem.authors = ["Chris Dinn"]
13
+ gem.add_dependency 'ruby-openid', '>= 2.1.7'
14
+ gem.add_dependency 'rack-openid', '>= 0.2.1'
15
+ gem.add_dependency 'sinatra', '>= 0.9.2'
13
16
  gem.add_development_dependency "rspec", ">= 1.2.9"
14
17
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
18
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
data/gatekeeper.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{gatekeeper}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Chris Dinn"]
12
- s.date = %q{2010-01-12}
12
+ s.date = %q{2010-01-14}
13
13
  s.description = %q{Connects any Rack-compatible app to a Hot Ink single sign on server.}
14
14
  s.email = %q{chrisgdinn@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -48,11 +48,20 @@ Gem::Specification.new do |s|
48
48
  s.specification_version = 3
49
49
 
50
50
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
51
+ s.add_runtime_dependency(%q<ruby-openid>, [">= 2.1.7"])
52
+ s.add_runtime_dependency(%q<rack-openid>, [">= 0.2.1"])
53
+ s.add_runtime_dependency(%q<sinatra>, [">= 0.9.2"])
51
54
  s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
52
55
  else
56
+ s.add_dependency(%q<ruby-openid>, [">= 2.1.7"])
57
+ s.add_dependency(%q<rack-openid>, [">= 0.2.1"])
58
+ s.add_dependency(%q<sinatra>, [">= 0.9.2"])
53
59
  s.add_dependency(%q<rspec>, [">= 1.2.9"])
54
60
  end
55
61
  else
62
+ s.add_dependency(%q<ruby-openid>, [">= 2.1.7"])
63
+ s.add_dependency(%q<rack-openid>, [">= 0.2.1"])
64
+ s.add_dependency(%q<sinatra>, [">= 0.9.2"])
56
65
  s.add_dependency(%q<rspec>, [">= 1.2.9"])
57
66
  end
58
67
  end
data/lib/gatekeeper.rb CHANGED
@@ -1,13 +1,7 @@
1
- gem 'sinatra', '~>0.9.2'
2
1
  require 'sinatra/base'
3
-
4
- gem 'ruby-openid', '>=2.1.6'
5
2
  require 'openid'
6
3
  require 'openid/store/filesystem'
7
-
8
- gem 'rack-openid', '>=0.2'
9
4
  require 'rack/openid'
10
-
11
5
  require 'tmpdir'
12
6
 
13
7
  require File.dirname(__FILE__)+'/gatekeeper/helpers/rack'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gatekeeper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Dinn
@@ -9,9 +9,39 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-12 00:00:00 -05:00
12
+ date: 2010-01-14 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: ruby-openid
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.1.7
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: rack-openid
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.2.1
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: sinatra
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 0.9.2
44
+ version:
15
45
  - !ruby/object:Gem::Dependency
16
46
  name: rspec
17
47
  type: :development