padrino-warden 0.20.1 → 0.20.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ee593e6a245f5c03c36bb809d7f3189a88821fc4
4
- data.tar.gz: 583fe62715c0ba71194dc6c42ac0fc6b923fc1ca
3
+ metadata.gz: cd3e07388156e676902ee11236c8a52131e9f34e
4
+ data.tar.gz: 491574a9e19190186b88d8e203932e759ae6963e
5
5
  SHA512:
6
- metadata.gz: f5729ac8622e272740ce8e26c1155ffc83dffec42c03ec6bf402eee878bf281e9c288ae93e8d2e1016423f806ae8c2f12d56a3184b3e651ddf64a423f6d264eb
7
- data.tar.gz: 047e444a3011ac5e76384b393198e7beb73ab1ea104acdcfc5c6a401156db53fb50bfc099b92d8eb1f83e979e1865e0f8e079520380ae530c6362fa6864ebd16
6
+ metadata.gz: 4b8599420dee012c4195cadbfe69d0018b193aa2259081db68210488e2e226c6a53ee262eaaff45725fcb61360ce98dab9f1c4235779f6f046cbb7e1c4b96cab
7
+ data.tar.gz: b5b1c86ec1c236f936487d59be0fdc39ac433639486563b97117670cd1f8181be6503e44efa802ee9a7a7f2aa3b7b4ae8333d41bc03472d9d3628d42fe7278e0
data/README.md CHANGED
@@ -87,6 +87,13 @@ end
87
87
 
88
88
  Your UserApp needs to be mounted first in Padrino! Cascading routes from the UserApp can cause exceptions, so don't use an app mounted to the root path ('/') as UserApp.
89
89
 
90
+ ## Configuration
91
+
92
+ There are some options you can override to customize padrino-warden to your
93
+ needs. Please consult the
94
+ [wiki](https://github.com/jondot/padrino-warden/wiki/Options) page to see all
95
+ of them.
96
+
90
97
 
91
98
  ## Overriding warden manager defaults
92
99
 
@@ -110,6 +117,10 @@ class SampleApp < Padrino::Application
110
117
  end
111
118
  ```
112
119
 
120
+ ## Changelog
121
+
122
+ Changelog is available on the [wiki](https://github.com/jondot/padrino-warden/wiki/Changelog).
123
+
113
124
  ## Note on Patches/Pull Requests
114
125
 
115
126
  * Fork the project.
@@ -123,9 +134,11 @@ end
123
134
  ## Contributors
124
135
 
125
136
  * Dotan Nahum (http://github.com/jondot)
137
+ * Michał Zając (http://github.com/Quintasan)
126
138
 
127
139
  For sinatra\_warden, thanks to: [Justin Smestad](http://github.com/jsmestad), [Daniel Neighman](http://github.com/hassox) and [Shane Hanna](http://github.com/shanna).
128
140
 
129
141
  ## Copyright
130
142
 
131
143
  Copyright (c) 2010 Dotan Nahum (jondot). See LICENSE for details.
144
+ Copyright (c) 2015 Michał Zając (Quintasan). See LICENSE for details.
@@ -9,30 +9,30 @@ require 'padrino/warden/helpers'
9
9
  module Padrino
10
10
  module Warden
11
11
  def self.registered(app, register_controller = true)
12
- # Enable Sessions
13
- app.set :sessions, true unless app.sessions
14
- app.set :auth_failure_path, '/'
15
- app.set :auth_success_path, '/'
12
+ # Enable sessions but allow the user to disable them explicitly
13
+ app.set :sessions, true unless app.respond_to?(:sessions)
14
+ app.set :auth_failure_path, '/' unless app.respond_to?(:auth_failure_path)
15
+ app.set :auth_success_path, '/' unless app.respond_to?(:auth_success_path)
16
16
 
17
- # Setting this to true will store last request URL
18
- # into a user's session so that to redirect back to it
19
- # upon successful authentication
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."
17
+ # set :auth_use_referrer to true to redirect a user back to an action
18
+ # protected by 'login'/'authenticate' after successful login
19
+ app.set :auth_use_referrer, false unless app.respond_to?(:auth_use_referrer)
20
+
21
+ app.set :auth_error_message, "You have provided invalid credentials." unless app.respond_to?(:auth_error_message)
22
+ app.set :auth_success_message, "You have logged in successfully." unless app.respond_to?(:auth_success_message)
23
+ app.set :deauth_success_message, "You have logged out successfully." unless app.respond_to?(:deauth_success_message)
24
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)
25
+ app.set :auth_login_template, 'sessions/login' unless app.respond_to?(:auth_login_template)
26
+ app.set :auth_login_path, 'sessions/login' unless app.respond_to?(:auth_login_path)
27
27
  app.set :auth_unauthenticated_path,'/unauthenticated' unless app.respond_to?(:auth_unauthenticated_path)
28
28
  app.set :auth_logout_path,'sessions/logout' unless app.respond_to?(:auth_logout_path)
29
- app.set :auth_login_layout, true
29
+ app.set :auth_login_layout, true unless app.respond_to?(:auth_login_layout)
30
30
  # OAuth Specific Settings
31
- app.set :auth_use_oauth, false
31
+ app.set :auth_use_oauth, false unless app.respond_to?(:auth_use_oauth)
32
32
  app.set :default_strategies, [:password] unless app.respond_to?(:default_strategies)
33
33
 
34
34
  app.set :warden_failure_app, app unless app.respond_to?(:warden_failure_app)
35
- app.set :warden_default_scope, :session
35
+ app.set :warden_default_scope, :session unless app.respond_to?(:warden_default_scope)
36
36
  app.set(:warden_config) { |manager| nil }
37
37
  app.use ::Warden::Manager do |manager|
38
38
  manager.scope_defaults :session, strategies: app.default_strategies
@@ -13,6 +13,7 @@ module Padrino
13
13
  end
14
14
  ## /sessions/login
15
15
  get :login , map: app.auth_login_path do
16
+ session.delete(:return_to)
16
17
  if settings.auth_use_oauth && !@auth_oauth_request_token.nil?
17
18
  session[:request_token] = @auth_oauth_request_token.token
18
19
  session[:request_token_secret] = @auth_oauth_request_token.secret
@@ -21,6 +21,8 @@ module Padrino
21
21
 
22
22
  # Authenticate a user against defined strategies
23
23
  def authenticate(*args)
24
+ session[:return_to] = request.fullpath if settings.auth_use_referrer and
25
+ env['REQUEST_METHOD'] == 'GET'
24
26
  warden.authenticate!(*args)
25
27
  end
26
28
  alias_method :login, :authenticate
@@ -1,5 +1,5 @@
1
1
  module Padrino
2
2
  module Warden
3
- VERSION = "0.20.1"
3
+ VERSION = "0.20.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: padrino-warden
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.1
4
+ version: 0.20.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dotan Nahum
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-02-25 00:00:00.000000000 Z
12
+ date: 2015-05-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: warden
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  version: '0'
94
94
  requirements: []
95
95
  rubyforge_project:
96
- rubygems_version: 2.4.4
96
+ rubygems_version: 2.4.6
97
97
  signing_key:
98
98
  specification_version: 4
99
99
  summary: authentication system for using warden with Padrino, adopted from sinatra_warden