padrino-warden 0.1.0 → 0.20.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +16 -19
- data/Gemfile +3 -21
- data/README.md +116 -0
- data/Rakefile +1 -43
- data/lib/padrino-warden.rb +0 -8
- data/lib/padrino/warden.rb +31 -116
- data/lib/padrino/warden/controller.rb +51 -0
- data/lib/padrino/warden/helpers.rb +55 -0
- data/lib/padrino/warden/version.rb +5 -0
- data/padrino-warden.gemspec +20 -52
- metadata +72 -63
- data/.document +0 -5
- data/README.rdoc +0 -82
- data/VERSION +0 -1
- data/spec/padrino-warden_spec.rb +0 -7
- data/spec/spec.opts +0 -1
- data/spec/spec_helper.rb +0 -9
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8d9b422afdc8f7b6a1c3977be0d498fcbf734ce6
|
4
|
+
data.tar.gz: 84796020957ca043466f3d99818e05ed4fa6e0c5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c84e76a573672d15ed6cf0ef581673913dab19fe10edf035468f0525c45e2f8f272e59c4e01d9309770c006c510429edb0baf21e0d56594714b822131f860f12
|
7
|
+
data.tar.gz: 11e020264e737d9bc3c88c8f0f2721894bd489d372c64e6fe9aeb93e78d717de48e630a8880c48888cae7e23935857360bd4a88cb591a6a3d2d61cbd0cf3c6d2
|
data/.gitignore
CHANGED
@@ -1,21 +1,18 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
*~
|
10
|
-
\#*
|
11
|
-
.\#*
|
12
|
-
|
13
|
-
## VIM
|
14
|
-
*.swp
|
15
|
-
|
16
|
-
## PROJECT::GENERAL
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
17
9
|
coverage
|
18
|
-
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
19
12
|
pkg
|
20
|
-
|
21
|
-
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.swp
|
data/Gemfile
CHANGED
@@ -1,22 +1,4 @@
|
|
1
|
-
source '
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
gem 'warden', '>= 0.10.3'
|
6
|
-
end
|
7
|
-
|
8
|
-
group :test do
|
9
|
-
gem 'rake'
|
10
|
-
gem 'jeweler', '~> 1.3.0'
|
11
|
-
gem 'bundler', '~> 0.9.7'
|
12
|
-
gem 'rspec', '~> 1.2.9', :require => 'spec'
|
13
|
-
gem 'yard', '>= 0.5.4'
|
14
|
-
gem 'rack-test', '~> 0.5.0', :require => 'rack/test'
|
15
|
-
gem 'rcov'
|
16
|
-
|
17
|
-
gem 'do_sqlite3', '~> 0.10.0'
|
18
|
-
gem 'dm-core', '~> 0.10.1'
|
19
|
-
gem 'bcrypt-ruby', :require => 'bcrypt'
|
20
|
-
gem 'haml'
|
21
|
-
gem 'rack-flash', '~> 0.1.1', :require => 'rack-flash'
|
22
|
-
end
|
3
|
+
# Specify your gem's dependencies in padrino-warden.gemspec
|
4
|
+
gemspec
|
data/README.md
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
# padrino-warden
|
2
|
+
|
3
|
+
A [Padrino](http://github.com/padrino/padrino-framework) module that provides authentication for your Padrino application through [Warden](http://github.com/hassox/warden).
|
4
|
+
|
5
|
+
Most of the code was adapted from [sinatra\_warden](http://github.com/jsmestad/sinatra_warden).
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
Currently padrino-warden uses +password+ as default authentication strategy. If you wish to change that consult
|
10
|
+
[Warden](http://github.com/hassox/warden).
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
class SampleApp < Padrino::Application
|
14
|
+
register Padrino::Warden
|
15
|
+
|
16
|
+
class User
|
17
|
+
attr_reader :name
|
18
|
+
def initialize(name)
|
19
|
+
@name=name
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.authenticate(a, b)
|
23
|
+
return User.new('john')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
Warden::Strategies.add(:password) do
|
28
|
+
def valid?
|
29
|
+
params["email"] || params["password"]
|
30
|
+
end
|
31
|
+
|
32
|
+
def authenticate!
|
33
|
+
u = User.authenticate(params["email"], params["password"])
|
34
|
+
u.nil? ? fail!("Could not log in") : success!(u)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
Warden::Manager.serialize_into_session do |user|
|
39
|
+
user.id
|
40
|
+
end
|
41
|
+
|
42
|
+
Warden::Manager.serialize_from_session do |id|
|
43
|
+
User.get(id)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
```
|
47
|
+
|
48
|
+
Run this to see your new routes:
|
49
|
+
|
50
|
+
`$ padrino rake routes`
|
51
|
+
|
52
|
+
You can now login at <http://localhost/sessions/login>
|
53
|
+
|
54
|
+
After login you can fiddle with *current\_user* for anything you need.
|
55
|
+
|
56
|
+
## Multi Sub-Apps
|
57
|
+
|
58
|
+
You UserApp(/user):
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
register Padrino::Warden
|
62
|
+
```
|
63
|
+
|
64
|
+
This will mount the sessions controller on it:
|
65
|
+
|
66
|
+
/user/sessions/...
|
67
|
+
|
68
|
+
You OtherApps:
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
register Padrino::Warden::Helpers
|
72
|
+
```
|
73
|
+
|
74
|
+
But you must apply the same options in your UserApp.
|
75
|
+
|
76
|
+
## Overriding warden manager defaults
|
77
|
+
|
78
|
+
```ruby
|
79
|
+
class SampleApp < Padrino::Application
|
80
|
+
register Padrino::Warden
|
81
|
+
|
82
|
+
Warden::Strategies.add(:token) do
|
83
|
+
def valid?
|
84
|
+
params["token"]
|
85
|
+
end
|
86
|
+
|
87
|
+
def authenticate!
|
88
|
+
...
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
set :warden_config do |manager|
|
93
|
+
manager.scope_defaults :api, strategies: [:token], store: false
|
94
|
+
end
|
95
|
+
end
|
96
|
+
```
|
97
|
+
|
98
|
+
## Note on Patches/Pull Requests
|
99
|
+
|
100
|
+
* Fork the project.
|
101
|
+
* Make your feature addition or bug fix.
|
102
|
+
* Add tests for it. This is important so I don't break it in a
|
103
|
+
future version unintentionally.
|
104
|
+
* Commit, do not mess with rakefile, version, or history.
|
105
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
106
|
+
* Send me a pull request. Bonus points for topic branches.
|
107
|
+
|
108
|
+
## Contributors
|
109
|
+
|
110
|
+
* Dotan Nahum (http://github.com/jondot)
|
111
|
+
|
112
|
+
For sinatra\_warden, thanks to: [Justin Smestad](http://github.com/jsmestad), [Daniel Neighman](http://github.com/hassox) and [Shane Hanna](http://github.com/shanna).
|
113
|
+
|
114
|
+
## Copyright
|
115
|
+
|
116
|
+
Copyright (c) 2010 Dotan Nahum (jondot). See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -1,43 +1 @@
|
|
1
|
-
require
|
2
|
-
require 'rake'
|
3
|
-
begin
|
4
|
-
require 'jeweler'
|
5
|
-
Jeweler::Tasks.new do |gem|
|
6
|
-
gem.name = "padrino-warden"
|
7
|
-
gem.summary = %Q{authentication system for using warden with Padrino, adopted from sinatra_warden}
|
8
|
-
gem.description = %Q{basic helpers and authentication methods for using warden with padrino also providing some hooks into Rack::Flash}
|
9
|
-
gem.email = "dotan@paracode.com"
|
10
|
-
gem.homepage = "http://github.com/jondot/padrino-warden"
|
11
|
-
gem.authors = ["Dotan Nahum"]
|
12
|
-
gem.add_dependency('warden', '>= 0.10.3')
|
13
|
-
end
|
14
|
-
Jeweler::GemcutterTasks.new
|
15
|
-
rescue LoadError
|
16
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
17
|
-
end
|
18
|
-
|
19
|
-
require 'spec/rake/spectask'
|
20
|
-
Spec::Rake::SpecTask.new(:spec) do |spec|
|
21
|
-
spec.libs << 'lib' << 'spec'
|
22
|
-
spec.spec_files = FileList['spec/**/*_spec.rb']
|
23
|
-
end
|
24
|
-
|
25
|
-
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
26
|
-
spec.libs << 'lib' << 'spec'
|
27
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
28
|
-
spec.rcov = true
|
29
|
-
end
|
30
|
-
|
31
|
-
task :spec => :check_dependencies
|
32
|
-
|
33
|
-
task :default => :spec
|
34
|
-
|
35
|
-
require 'rake/rdoctask'
|
36
|
-
Rake::RDocTask.new do |rdoc|
|
37
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
38
|
-
|
39
|
-
rdoc.rdoc_dir = 'rdoc'
|
40
|
-
rdoc.title = "padrino-warden #{version}"
|
41
|
-
rdoc.rdoc_files.include('README*')
|
42
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
43
|
-
end
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/padrino-warden.rb
CHANGED
@@ -1,10 +1,2 @@
|
|
1
1
|
require 'warden'
|
2
2
|
require File.join(File.dirname(__FILE__), 'padrino', 'warden')
|
3
|
-
|
4
|
-
Warden::Manager.before_failure do |env, opts|
|
5
|
-
# Sinatra is very sensitive to the request method
|
6
|
-
# since authentication could fail on any type of method, we need
|
7
|
-
# to set it for the failure app so it is routed to the correct block
|
8
|
-
env['REQUEST_METHOD'] = "POST"
|
9
|
-
|
10
|
-
end
|
data/lib/padrino/warden.rb
CHANGED
@@ -1,133 +1,48 @@
|
|
1
|
-
|
2
|
-
module Warden
|
3
|
-
module Helpers
|
4
|
-
|
5
|
-
# The main accessor to the warden middleware
|
6
|
-
def warden
|
7
|
-
request.env['warden']
|
8
|
-
end
|
1
|
+
require 'warden'
|
9
2
|
|
10
|
-
|
11
|
-
#
|
12
|
-
# @param [Symbol] the scope to retrieve session info for
|
13
|
-
def session_info(scope=nil)
|
14
|
-
scope ? warden.session(scope) : scope
|
15
|
-
end
|
16
|
-
|
17
|
-
# Check the current session is authenticated to a given scope
|
18
|
-
def authenticated?(scope=nil)
|
19
|
-
scope ? warden.authenticated?(scope) : warden.authenticated?
|
20
|
-
end
|
21
|
-
alias_method :logged_in?, :authenticated?
|
3
|
+
$:.unshift File.join( File.dirname(__FILE__), '..', '..' )
|
22
4
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
27
|
-
alias_method :login, :authenticate
|
28
|
-
|
29
|
-
# Terminate the current session
|
30
|
-
#
|
31
|
-
# @param [Symbol] the session scope to terminate
|
32
|
-
def logout(scopes=nil)
|
33
|
-
scopes ? warden.logout(scopes) : warden.logout
|
34
|
-
end
|
35
|
-
|
36
|
-
# Access the user from the current session
|
37
|
-
#
|
38
|
-
# @param [Symbol] the scope for the logged in user
|
39
|
-
def user(scope=nil)
|
40
|
-
scope ? warden.user(scope) : warden.user
|
41
|
-
end
|
42
|
-
alias_method :current_user, :user
|
43
|
-
|
44
|
-
# Store the logged in user in the session
|
45
|
-
#
|
46
|
-
# @param [Object] the user you want to store in the session
|
47
|
-
# @option opts [Symbol] :scope The scope to assign the user
|
48
|
-
# @example Set John as the current user
|
49
|
-
# user = User.find_by_name('John')
|
50
|
-
def user=(new_user, opts={})
|
51
|
-
warden.set_user(new_user, opts)
|
52
|
-
end
|
53
|
-
alias_method :current_user=, :user=
|
54
|
-
|
55
|
-
# Require authorization for an action
|
56
|
-
#
|
57
|
-
# @param [String] path to redirect to if user is unauthenticated
|
58
|
-
def authorize!(failure_path=nil)
|
59
|
-
unless authenticated?
|
60
|
-
session[:return_to] = request.path if options.auth_use_referrer
|
61
|
-
redirect(failure_path ? failure_path : options.auth_failure_path)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
end
|
5
|
+
require 'padrino/warden/version'
|
6
|
+
require 'padrino/warden/controller'
|
7
|
+
require 'padrino/warden/helpers'
|
66
8
|
|
9
|
+
module Padrino
|
10
|
+
module Warden
|
67
11
|
def self.registered(app)
|
68
|
-
app.helpers Helpers
|
69
|
-
|
70
12
|
# Enable Sessions
|
71
13
|
app.set :sessions, true
|
72
14
|
app.set :auth_failure_path, '/'
|
73
15
|
app.set :auth_success_path, '/'
|
16
|
+
|
74
17
|
# Setting this to true will store last request URL
|
75
18
|
# into a user's session so that to redirect back to it
|
76
19
|
# upon successful authentication
|
77
|
-
app.set :auth_use_referrer,
|
78
|
-
app.set :auth_error_message,
|
79
|
-
app.set :auth_success_message,
|
80
|
-
app.set :
|
20
|
+
app.set :auth_use_referrer, false
|
21
|
+
app.set :auth_error_message, "You have provided invalid credentials."
|
22
|
+
app.set :auth_success_message, "You have logged in successfully."
|
23
|
+
app.set :deauth_success_message, "You have logged out successfully."
|
24
|
+
# Custom map options and layout for the sessions controller
|
25
|
+
app.set :auth_login_template, 'sessions/login'
|
26
|
+
app.set :auth_login_path, 'sessions/login' unless app.respond_to?(:auth_login_path)
|
27
|
+
app.set :auth_unauthenticated_path,'/unauthenticated' unless app.respond_to?(:auth_unauthenticated_path)
|
28
|
+
app.set :auth_logout_path,'sessions/logout' unless app.respond_to?(:auth_logout_path)
|
29
|
+
app.set :auth_login_layout, true
|
81
30
|
# OAuth Specific Settings
|
82
31
|
app.set :auth_use_oauth, false
|
83
|
-
|
32
|
+
app.set :default_strategies, [:password] unless app.respond_to?(:default_strategies)
|
33
|
+
|
34
|
+
app.set :warden_failure_app, app
|
35
|
+
app.set :warden_default_scope, :session
|
36
|
+
app.set(:warden_config) { |manager| nil }
|
84
37
|
app.use ::Warden::Manager do |manager|
|
85
|
-
|
86
|
-
|
38
|
+
manager.scope_defaults :session, strategies: app.default_strategies
|
39
|
+
manager.default_scope = app.warden_default_scope
|
40
|
+
manager.failure_app = app.warden_failure_app
|
41
|
+
app.warden_config manager
|
87
42
|
end
|
88
|
-
|
89
|
-
app.controller :sessions do
|
90
|
-
post :unauthenticated do
|
91
|
-
status 401
|
92
|
-
warden.custom_failure! if warden.config.failure_app == self.class
|
93
|
-
env['x-rack.flash'][:error] = options.auth_error_message if defined?(Rack::Flash)
|
94
|
-
render options.auth_login_template
|
95
|
-
end
|
96
|
-
|
97
|
-
get :login do
|
98
|
-
if options.auth_use_oauth && !@auth_oauth_request_token.nil?
|
99
|
-
session[:request_token] = @auth_oauth_request_token.token
|
100
|
-
session[:request_token_secret] = @auth_oauth_request_token.secret
|
101
|
-
redirect @auth_oauth_request_token.authorize_url
|
102
|
-
else
|
103
|
-
render options.auth_login_template
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
get :oauth_callback do
|
108
|
-
if options.auth_use_oauth
|
109
|
-
authenticate
|
110
|
-
env['x-rack.flash'][:success] = options.auth_success_message if defined?(Rack::Flash)
|
111
|
-
redirect options.auth_success_path
|
112
|
-
else
|
113
|
-
redirect options.auth_failure_path
|
114
|
-
end
|
115
|
-
end
|
116
43
|
|
117
|
-
|
118
|
-
|
119
|
-
env['x-rack.flash'][:success] = options.auth_success_message if defined?(Rack::Flash)
|
120
|
-
redirect options.auth_use_referrer && session[:return_to] ? session.delete(:return_to) :
|
121
|
-
options.auth_success_path
|
122
|
-
end
|
123
|
-
|
124
|
-
get :logout do
|
125
|
-
authorize!
|
126
|
-
logout
|
127
|
-
env['x-rack.flash'][:success] = options.auth_success_message if defined?(Rack::Flash)
|
128
|
-
redirect options.auth_success_path
|
129
|
-
end
|
130
|
-
end
|
44
|
+
Controller.registered app
|
45
|
+
app.helpers Helpers
|
131
46
|
end
|
132
|
-
end
|
133
|
-
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Padrino
|
2
|
+
module Warden
|
3
|
+
module Controller
|
4
|
+
def self.registered(app)
|
5
|
+
app.controller :sessions do
|
6
|
+
%w(get put post delete head options patch link unlink).each do |method|
|
7
|
+
__send__ method, :unauthenticated, map: app.auth_unauthenticated_path do
|
8
|
+
status 401
|
9
|
+
warden.custom_failure! if warden.config.failure_app == self.class
|
10
|
+
flash.now[:error] = settings.auth_error_message if flash
|
11
|
+
render settings.auth_login_template , layout: settings.auth_login_layout
|
12
|
+
end
|
13
|
+
end
|
14
|
+
## /sessions/login
|
15
|
+
get :login , map: app.auth_login_path do
|
16
|
+
if settings.auth_use_oauth && !@auth_oauth_request_token.nil?
|
17
|
+
session[:request_token] = @auth_oauth_request_token.token
|
18
|
+
session[:request_token_secret] = @auth_oauth_request_token.secret
|
19
|
+
redirect @auth_oauth_request_token.authorize_url
|
20
|
+
else
|
21
|
+
render settings.auth_login_template , layout: settings.auth_login_layout
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
post :login , map: app.auth_login_path do
|
26
|
+
authenticate
|
27
|
+
flash[:success] = settings.auth_success_message if flash
|
28
|
+
redirect settings.auth_use_referrer && session[:return_to] ? session.delete(:return_to) :
|
29
|
+
settings.auth_success_path
|
30
|
+
end
|
31
|
+
|
32
|
+
get :logout ,map: app.auth_logout_path do
|
33
|
+
logout
|
34
|
+
flash[:success] = settings.deauth_success_message if flash
|
35
|
+
redirect settings.auth_success_path
|
36
|
+
end
|
37
|
+
|
38
|
+
get :oauth_callback do
|
39
|
+
if settings.auth_use_oauth
|
40
|
+
authenticate
|
41
|
+
flash[:success] = settings.auth_success_message if flash
|
42
|
+
redirect settings.auth_success_path
|
43
|
+
else
|
44
|
+
redirect settings.auth_failure_path
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Padrino
|
2
|
+
module Warden
|
3
|
+
module Helpers
|
4
|
+
# The main accessor to the warden middleware
|
5
|
+
def warden
|
6
|
+
request.env['warden']
|
7
|
+
end
|
8
|
+
|
9
|
+
# Return session info
|
10
|
+
#
|
11
|
+
# @param [Symbol] the scope to retrieve session info for
|
12
|
+
def session_info(scope=nil)
|
13
|
+
scope ? warden.session(scope) : scope
|
14
|
+
end
|
15
|
+
|
16
|
+
# Check the current session is authenticated to a given scope
|
17
|
+
def authenticated?(scope=nil)
|
18
|
+
scope ? warden.authenticated?(scope) : warden.authenticated?
|
19
|
+
end
|
20
|
+
alias_method :logged_in?, :authenticated?
|
21
|
+
|
22
|
+
# Authenticate a user against defined strategies
|
23
|
+
def authenticate(*args)
|
24
|
+
warden.authenticate!(*args)
|
25
|
+
end
|
26
|
+
alias_method :login, :authenticate
|
27
|
+
|
28
|
+
# Terminate the current session
|
29
|
+
#
|
30
|
+
# @param [Symbol] the session scope to terminate
|
31
|
+
def logout(scopes=nil)
|
32
|
+
scopes ? warden.logout(scopes) : warden.logout
|
33
|
+
end
|
34
|
+
|
35
|
+
# Access the user from the current session
|
36
|
+
#
|
37
|
+
# @param [Symbol] the scope for the logged in user
|
38
|
+
def user(scope=nil)
|
39
|
+
scope ? warden.user(scope) : warden.user
|
40
|
+
end
|
41
|
+
alias_method :current_user, :user
|
42
|
+
|
43
|
+
# Store the logged in user in the session
|
44
|
+
#
|
45
|
+
# @param [Object] the user you want to store in the session
|
46
|
+
# @option opts [Symbol] :scope The scope to assign the user
|
47
|
+
# @example Set John as the current user
|
48
|
+
# user = User.find_by_name('John')
|
49
|
+
def user=(new_user, opts={})
|
50
|
+
warden.set_user(new_user, opts)
|
51
|
+
end
|
52
|
+
alias_method :current_user=, :user=
|
53
|
+
end # helpers
|
54
|
+
end # Warden
|
55
|
+
end # Padrino
|
data/padrino-warden.gemspec
CHANGED
@@ -1,57 +1,25 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'padrino/warden/version'
|
5
5
|
|
6
|
-
Gem::Specification.new do |
|
7
|
-
|
8
|
-
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "padrino-warden"
|
8
|
+
spec.version = Padrino::Warden::VERSION
|
9
|
+
spec.authors = ["Dotan Nahum"]
|
10
|
+
spec.email = ["dotan@paracode.com"]
|
11
|
+
spec.description = %q{basic helpers and authentication methods for using warden with padrino also providing some hooks into Rack::Flash}
|
12
|
+
spec.summary = %q{authentication system for using warden with Padrino, adopted from sinatra_warden}
|
13
|
+
spec.homepage = "https://github.com/jondot/padrino-warden"
|
14
|
+
spec.license = "MIT"
|
9
15
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
s.email = %q{dotan@paracode.com}
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE",
|
17
|
-
"README.rdoc"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".document",
|
21
|
-
".gitignore",
|
22
|
-
"Gemfile",
|
23
|
-
"LICENSE",
|
24
|
-
"README.rdoc",
|
25
|
-
"Rakefile",
|
26
|
-
"VERSION",
|
27
|
-
"lib/padrino-warden.rb",
|
28
|
-
"lib/padrino/warden.rb",
|
29
|
-
"padrino-warden.gemspec",
|
30
|
-
"spec/padrino-warden_spec.rb",
|
31
|
-
"spec/spec.opts",
|
32
|
-
"spec/spec_helper.rb"
|
33
|
-
]
|
34
|
-
s.homepage = %q{http://github.com/jondot/padrino-warden}
|
35
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
36
|
-
s.require_paths = ["lib"]
|
37
|
-
s.rubygems_version = %q{1.3.6}
|
38
|
-
s.summary = %q{authentication system for using warden with Padrino, adopted from sinatra_warden}
|
39
|
-
s.test_files = [
|
40
|
-
"spec/padrino-warden_spec.rb",
|
41
|
-
"spec/spec_helper.rb"
|
42
|
-
]
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
43
20
|
|
44
|
-
|
45
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
46
|
-
s.specification_version = 3
|
21
|
+
spec.add_dependency 'warden', '>= 0.10.3'
|
47
22
|
|
48
|
-
|
49
|
-
|
50
|
-
else
|
51
|
-
s.add_dependency(%q<warden>, [">= 0.10.3"])
|
52
|
-
end
|
53
|
-
else
|
54
|
-
s.add_dependency(%q<warden>, [">= 0.10.3"])
|
55
|
-
end
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
spec.add_development_dependency "rake"
|
56
25
|
end
|
57
|
-
|
metadata
CHANGED
@@ -1,89 +1,98 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: padrino-warden
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
segments:
|
6
|
-
- 0
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
version: 0.1.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.20.0
|
10
5
|
platform: ruby
|
11
|
-
authors:
|
6
|
+
authors:
|
12
7
|
- Dotan Nahum
|
13
8
|
autorequire:
|
14
9
|
bindir: bin
|
15
10
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2014-12-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
21
14
|
name: warden
|
22
|
-
|
23
|
-
|
24
|
-
requirements:
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
25
17
|
- - ">="
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
segments:
|
28
|
-
- 0
|
29
|
-
- 10
|
30
|
-
- 3
|
18
|
+
- !ruby/object:Gem::Version
|
31
19
|
version: 0.10.3
|
32
20
|
type: :runtime
|
33
|
-
|
34
|
-
|
35
|
-
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.10.3
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: basic helpers and authentication methods for using warden with padrino
|
56
|
+
also providing some hooks into Rack::Flash
|
57
|
+
email:
|
58
|
+
- dotan@paracode.com
|
36
59
|
executables: []
|
37
|
-
|
38
60
|
extensions: []
|
39
|
-
|
40
|
-
|
41
|
-
-
|
42
|
-
- README.rdoc
|
43
|
-
files:
|
44
|
-
- .document
|
45
|
-
- .gitignore
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
46
64
|
- Gemfile
|
47
65
|
- LICENSE
|
48
|
-
- README.
|
66
|
+
- README.md
|
49
67
|
- Rakefile
|
50
|
-
- VERSION
|
51
68
|
- lib/padrino-warden.rb
|
52
69
|
- lib/padrino/warden.rb
|
70
|
+
- lib/padrino/warden/controller.rb
|
71
|
+
- lib/padrino/warden/helpers.rb
|
72
|
+
- lib/padrino/warden/version.rb
|
53
73
|
- padrino-warden.gemspec
|
54
|
-
|
55
|
-
|
56
|
-
-
|
57
|
-
|
58
|
-
homepage: http://github.com/jondot/padrino-warden
|
59
|
-
licenses: []
|
60
|
-
|
74
|
+
homepage: https://github.com/jondot/padrino-warden
|
75
|
+
licenses:
|
76
|
+
- MIT
|
77
|
+
metadata: {}
|
61
78
|
post_install_message:
|
62
|
-
rdoc_options:
|
63
|
-
|
64
|
-
require_paths:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
65
81
|
- lib
|
66
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
-
requirements:
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
68
84
|
- - ">="
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
-
requirements:
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
75
89
|
- - ">="
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
|
78
|
-
- 0
|
79
|
-
version: "0"
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
80
92
|
requirements: []
|
81
|
-
|
82
93
|
rubyforge_project:
|
83
|
-
rubygems_version:
|
94
|
+
rubygems_version: 2.2.2
|
84
95
|
signing_key:
|
85
|
-
specification_version:
|
96
|
+
specification_version: 4
|
86
97
|
summary: authentication system for using warden with Padrino, adopted from sinatra_warden
|
87
|
-
test_files:
|
88
|
-
- spec/padrino-warden_spec.rb
|
89
|
-
- spec/spec_helper.rb
|
98
|
+
test_files: []
|
data/.document
DELETED
data/README.rdoc
DELETED
@@ -1,82 +0,0 @@
|
|
1
|
-
= padrino-warden
|
2
|
-
|
3
|
-
A Padrino (http://github.com/padrino/padrino-framework) module that provides authentication for your Padrino application through Warden (http://github.com/hassox/warden).
|
4
|
-
|
5
|
-
Most of the code was adapted from sinatra_warden (http://github.com/jsmestad/sinatra_warden)
|
6
|
-
|
7
|
-
== Usage
|
8
|
-
|
9
|
-
Currently padrino-warden uses +password+ as default authentication strategy. If you wish to change that consult
|
10
|
-
Warden (http://github.com/hassox/warden).
|
11
|
-
|
12
|
-
class SampleApp < Padrino::Application
|
13
|
-
configure do
|
14
|
-
##
|
15
|
-
# Application-specific configuration options
|
16
|
-
#
|
17
|
-
end
|
18
|
-
|
19
|
-
register Padrino::Warden
|
20
|
-
|
21
|
-
|
22
|
-
class User
|
23
|
-
attr_reader :name
|
24
|
-
def initialize(name)
|
25
|
-
@name=name
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.authenticate(a, b)
|
29
|
-
return User.new('john')
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
Warden::Strategies.add(:password) do
|
34
|
-
def valid?
|
35
|
-
params["email"] || params["password"]
|
36
|
-
end
|
37
|
-
|
38
|
-
def authenticate!
|
39
|
-
u = User.authenticate(params["email"], params["password"])
|
40
|
-
u.nil? ? fail!("Could not log in") : success!(u)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
Warden::Manager.serialize_into_session do |user|
|
45
|
-
user.id
|
46
|
-
end
|
47
|
-
|
48
|
-
Warden::Manager.serialize_from_session do |id|
|
49
|
-
User.get(id)
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
Run this to see your new routes:
|
55
|
-
|
56
|
-
$ padrino rake routes
|
57
|
-
|
58
|
-
You can now login at
|
59
|
-
http://localhost/sessions/login
|
60
|
-
|
61
|
-
After login you can fiddle with +current_user+ for anything you need.
|
62
|
-
|
63
|
-
|
64
|
-
== Note on Patches/Pull Requests
|
65
|
-
|
66
|
-
* Fork the project.
|
67
|
-
* Make your feature addition or bug fix.
|
68
|
-
* Add tests for it. This is important so I don't break it in a
|
69
|
-
future version unintentionally.
|
70
|
-
* Commit, do not mess with rakefile, version, or history.
|
71
|
-
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
72
|
-
* Send me a pull request. Bonus points for topic branches.
|
73
|
-
|
74
|
-
== Contributors
|
75
|
-
|
76
|
-
* Dotan Nahum (http://github.com/jondot)
|
77
|
-
|
78
|
-
For sinatra_warden, thanks to: Justin Smestad (http://github.com/jsmestad), Daniel Neighman (http://github.com/hassox), Shane Hanna (http://github.com/shanna)
|
79
|
-
|
80
|
-
== Copyright
|
81
|
-
|
82
|
-
Copyright (c) 2010 Dotan Nahum (jondot). See LICENSE for details.
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.1.0
|
data/spec/padrino-warden_spec.rb
DELETED
data/spec/spec.opts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--color
|