pipa-authmagic 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -6,6 +6,7 @@ module Authmagic
|
|
6
6
|
|
7
7
|
def initialize(context)
|
8
8
|
@context = context
|
9
|
+
@context.config.authorization = Config.new(:allow_guest => false)
|
9
10
|
end
|
10
11
|
|
11
12
|
def enroll
|
@@ -15,17 +16,21 @@ module Authmagic
|
|
15
16
|
module ControllerClassMethods
|
16
17
|
private
|
17
18
|
def require_principal(opts = {}, &block)
|
19
|
+
allow_guest = opts.fetch(:allow_guest) { security_context.config.authorization.allow_guest }
|
18
20
|
before_filter opts do |controller|
|
19
|
-
controller.instance_eval
|
21
|
+
controller.instance_eval do
|
22
|
+
p = current_principal
|
23
|
+
deny_action! unless (p || allow_guest) && (!block || block.call(p))
|
24
|
+
end
|
20
25
|
end
|
21
26
|
end
|
22
27
|
|
23
|
-
def
|
24
|
-
require_principal(opts
|
28
|
+
def require_identified_principal(opts = {}, &block)
|
29
|
+
require_principal(opts.update(:allow_guest => true))
|
25
30
|
end
|
26
31
|
|
27
32
|
def require_login(opts = {})
|
28
|
-
|
33
|
+
require_identified_principal(opts)
|
29
34
|
end
|
30
35
|
end
|
31
36
|
|
@@ -45,7 +45,7 @@ module Authmagic
|
|
45
45
|
secran_salt = col_salt.type == :binary ? :random_bytes : :hex
|
46
46
|
|
47
47
|
principal.class_eval do
|
48
|
-
self.class.send(:define_method, :
|
48
|
+
self.class.send(:define_method, :authenticate_with_login_password) do |options|
|
49
49
|
conditions = case_sensitive ?
|
50
50
|
{login => options[login]} :
|
51
51
|
["lower(#{connection.quote_column_name(login)}) = lower(?)", options[login]]
|
@@ -88,7 +88,7 @@ module Authmagic
|
|
88
88
|
cfg = security_context.config.principal
|
89
89
|
login = cfg.fetch(:login_field, :login)
|
90
90
|
password = cfg.fetch(:password_field, :password)
|
91
|
-
p = security_context.principal.
|
91
|
+
p = security_context.principal.authenticate_with_login_password(
|
92
92
|
login => options[login] || params[sess][login],
|
93
93
|
password => options[password] || params[sess][password])
|
94
94
|
session[:current_principal_id] = p.id
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pipa-authmagic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Gunko
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-01-
|
12
|
+
date: 2009-01-31 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|