sinatra_warden 0.1.5.1 → 0.1.6

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/Gemfile CHANGED
@@ -1,22 +1,22 @@
1
1
  source "http://gemcutter.org"
2
2
 
3
- group :runtime do
4
- gem 'sinatra', '>= 0.9.4'
5
- gem 'warden', '>= 0.5.0'
6
- end
3
+ gem 'sinatra', '>= 0.9.4'
4
+ gem 'warden', '>= 0.5.3'
7
5
 
8
- group :test do
6
+ only :testing do
9
7
  gem 'rake'
10
- gem 'jeweler'
11
- gem 'bundler', '~> 0.9.7'
12
- gem 'rspec', '~> 1.2.9', :require => 'spec'
8
+ gem 'jeweler', '~> 1.3.0'
9
+ gem 'bundler'
10
+ gem 'rspec', '~> 1.2.9', :require_as => 'spec'
13
11
  gem 'yard'
14
- gem 'rack-test', '~> 0.5.0', :require => 'rack/test'
12
+ gem 'rack-test', '~> 0.5.0', :require_as => 'rack/test'
15
13
  gem 'rcov'
16
-
14
+
17
15
  gem 'do_sqlite3', '~> 0.10.0'
18
16
  gem 'dm-core', '~> 0.10.1'
19
- gem 'bcrypt-ruby', :require => 'bcrypt'
17
+ gem 'bcrypt-ruby', :require_as => 'bcrypt'
20
18
  gem 'haml'
21
- gem 'rack-flash', :require => 'rack/flash'
19
+ gem 'rack-flash', :require_as => 'rack/flash'
22
20
  end
21
+
22
+ disable_system_gems
data/README.rdoc CHANGED
@@ -27,10 +27,12 @@ Please read the wiki (http://wiki.github.com/jsmestad/sinatra_warden) for more i
27
27
 
28
28
  == Note on Patches/Pull Requests
29
29
 
30
+ We use bundler on this project and disable system gems. Contributers should do the following:
31
+
30
32
  $ git clone git://github.com/jsmestad/sinatra_warden.git
31
33
  $ cd sinatra_warden
32
- $ bundle install
33
- $ bundle exec rake
34
+ $ gem bundle
35
+ $ ./bin/rake
34
36
 
35
37
  * Fork the project.
36
38
  * Make your feature addition or bug fix.
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), 'vendor', 'gems', 'environment')
2
+ Bundler.require_env
1
3
  require 'rake'
2
4
  require 'bundler'
3
5
 
@@ -11,11 +13,13 @@ begin
11
13
  gem.homepage = "http://github.com/jsmestad/sinatra_warden"
12
14
  gem.authors = ["Justin Smestad", "Daniel Neighman"]
13
15
 
14
- bundle = Bundler::Definition.from_gemfile('Gemfile')
15
- bundle.dependencies.each do |dep|
16
- next unless dep.groups.include?(:runtime)
17
- gem.add_dependency(dep.name, dep.version_requirements.to_s)
16
+ manifest = Bundler::Environment.load(File.dirname(__FILE__) + '/Gemfile')
17
+ manifest.dependencies.each do |d|
18
+ next if d.only
19
+ gem.add_dependency(d.name, d.version)
18
20
  end
21
+
22
+ gem.executables = nil
19
23
  end
20
24
  Jeweler::GemcutterTasks.new
21
25
  rescue LoadError
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.5.1
1
+ 0.1.6
@@ -1,4 +1,3 @@
1
- require 'warden'
2
1
  require File.join(File.dirname(__FILE__), 'sinatra_warden', 'sinatra')
3
2
 
4
3
  Warden::Manager.before_failure do |env, opts|
@@ -33,6 +33,7 @@ module Sinatra
33
33
  def authorize!(failure_path=nil)
34
34
  redirect(failure_path ? failure_path : options.auth_failure_path) unless authenticated?
35
35
  end
36
+
36
37
  end
37
38
 
38
39
  def self.registered(app)
@@ -41,19 +42,37 @@ module Sinatra
41
42
  app.set :auth_failure_path, '/'
42
43
  app.set :auth_success_path, lambda { back }
43
44
 
44
- app.set :auth_error_message, "Could not log you in."
45
+ app.set :auth_error_message, "Could not log you in."
45
46
  app.set :auth_success_message, "You have logged in successfully."
46
47
  app.set :auth_use_erb, false
47
48
  app.set :auth_login_template, :login
49
+
50
+ # OAuth Specific Settings
51
+ app.set :auth_use_oauth, false
52
+ app.set :auth_oauth_authorize_url, nil
48
53
 
49
54
  app.post '/unauthenticated/?' do
50
55
  status 401
51
- flash[:error] = (env['warden'].message || options.auth_error_message) if defined?(Rack::Flash)
56
+ flash[:error] = options.auth_error_message if defined?(Rack::Flash)
52
57
  options.auth_use_erb ? erb(options.auth_login_template) : haml(options.auth_login_template)
53
58
  end
54
59
 
55
60
  app.get '/login/?' do
56
- options.auth_use_erb ? erb(options.auth_login_template) : haml(options.auth_login_template)
61
+ if options.auth_use_oauth && !options.auth_oauth_authorize_url.nil?
62
+ redirect options.auth_oauth_authorize_url
63
+ else
64
+ options.auth_use_erb ? erb(options.auth_login_template) : haml(options.auth_login_template)
65
+ end
66
+ end
67
+
68
+ app.get '/oauth_callback/?' do
69
+ if options.auth_use_oauth
70
+ env['warden'].authenticate!
71
+ flash[:success] = options.auth_success_message if defined?(Rack::Flash)
72
+ redirect options.auth_success_path
73
+ else
74
+ redirect options.auth_failure_path
75
+ end
57
76
  end
58
77
 
59
78
  app.post '/login/?' do
@@ -5,14 +5,13 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sinatra_warden}
8
- s.version = "0.1.5.1"
8
+ s.version = "0.1.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Justin Smestad", "Daniel Neighman"]
12
- s.date = %q{2010-03-02}
12
+ s.date = %q{2009-12-16}
13
13
  s.description = %q{basic helpers and authentication methods for using warden with sinatra also providing some hooks into Rack::Flash}
14
14
  s.email = %q{justin.smestad@gmail.com}
15
- s.executables = ["autospec", "css2sass", "edit_json.rb", "haml", "html2haml", "jeweler", "prettify_json.rb", "rackup", "rake", "rcov", "rubyforge", "sass", "spec", "yard-graph", "yardoc", "yri"]
16
15
  s.extra_rdoc_files = [
17
16
  "LICENSE",
18
17
  "README.rdoc"
@@ -55,14 +54,14 @@ Gem::Specification.new do |s|
55
54
 
56
55
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
57
56
  s.add_runtime_dependency(%q<sinatra>, [">= 0.9.4"])
58
- s.add_runtime_dependency(%q<warden>, [">= 0.5.0"])
57
+ s.add_runtime_dependency(%q<warden>, [">= 0.5.3"])
59
58
  else
60
59
  s.add_dependency(%q<sinatra>, [">= 0.9.4"])
61
- s.add_dependency(%q<warden>, [">= 0.5.0"])
60
+ s.add_dependency(%q<warden>, [">= 0.5.3"])
62
61
  end
63
62
  else
64
63
  s.add_dependency(%q<sinatra>, [">= 0.9.4"])
65
- s.add_dependency(%q<warden>, [">= 0.5.0"])
64
+ s.add_dependency(%q<warden>, [">= 0.5.3"])
66
65
  end
67
66
  end
68
67
 
@@ -5,6 +5,6 @@ Warden::Strategies.add(:password) do
5
5
 
6
6
  def authenticate!
7
7
  u = User.authenticate(params['email'], params['password'])
8
- u.nil? ? fail!("Could not log you in.") : success!(u)
8
+ u.nil? ? fail!("Could not log in") : success!(u)
9
9
  end
10
10
  end
@@ -5,7 +5,6 @@ class TestingLogin < Sinatra::Base
5
5
  set :sessions, true
6
6
 
7
7
  set :auth_success_path, '/welcome'
8
-
9
8
  get '/dashboard' do
10
9
  authorize!('/login')
11
10
  "My Dashboard"
@@ -125,4 +125,28 @@ describe "Sinatra::Warden" do
125
125
 
126
126
  end
127
127
 
128
+ context "OAuth support" do
129
+ context "when enabled" do
130
+ before(:each) do
131
+ #TestingLogin.set(:auth_use_oauth, true)
132
+ #@app = app
133
+ end
134
+
135
+ it "should redirect to authorize_url" do
136
+ pending
137
+ get '/login'
138
+ follow_redirect!
139
+ last_request.url.should == "http://twitter.com/oauth/authorize"
140
+ end
141
+
142
+ it "should redirect to a custom authorize_url, if set" do
143
+ pending
144
+ get '/login'
145
+ follow_redirect!
146
+ last_request.url.should == "http://facebook.com"
147
+ end
148
+
149
+ end
150
+ end
151
+
128
152
  end
data/spec/spec_helper.rb CHANGED
@@ -1,8 +1,10 @@
1
- Bundler.require(:default, :runtime, :test)
2
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
3
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
3
 
5
4
  ENV['RACK_ENV'] ||= 'test'
5
+ project_root = File.expand_path(File.dirname(__FILE__))
6
+ require File.join(project_root, '..', 'vendor', 'gems', 'environment')
7
+ Bundler.require_env(:testing)
6
8
 
7
9
  require 'sinatra_warden'
8
10
  require 'spec'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra_warden
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5.1
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Smestad
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2010-03-02 00:00:00 -07:00
13
+ date: 2009-12-16 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -31,27 +31,12 @@ dependencies:
31
31
  requirements:
32
32
  - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: 0.5.0
34
+ version: 0.5.3
35
35
  version:
36
36
  description: basic helpers and authentication methods for using warden with sinatra also providing some hooks into Rack::Flash
37
37
  email: justin.smestad@gmail.com
38
- executables:
39
- - autospec
40
- - css2sass
41
- - edit_json.rb
42
- - haml
43
- - html2haml
44
- - jeweler
45
- - prettify_json.rb
46
- - rackup
47
- - rake
48
- - rcov
49
- - rubyforge
50
- - sass
51
- - spec
52
- - yard-graph
53
- - yardoc
54
- - yri
38
+ executables: []
39
+
55
40
  extensions: []
56
41
 
57
42
  extra_rdoc_files: