wizdog 0.2.0 → 0.2.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 411c507ab5ef2a1b51649964b5d72f73cddeab2a
4
- data.tar.gz: 93363c2f7870f3160cb99c6927ee873381ccc7d8
3
+ metadata.gz: b9e2e4e8884ccdd801328f1a8d14618491587495
4
+ data.tar.gz: 9c5fc3b1c4e7d3237ee029dac1ea1325371a1dc3
5
5
  SHA512:
6
- metadata.gz: 5f519556de05ea98e9caba468759cc7e700eaf299575a1d50fbcd8e5ba9bc33b6b8743d0a003517f91f6e1edfe26ed9bea56189d23825c381b8b8556386f9559
7
- data.tar.gz: 4548b5c9a007807268b055ad9af1df83daae8a58e556c807f6f9a1fc1784bdd3966bdb88ef62866ab3bd45ade9af6d4d2cdbdff09f4dbb401fb49049cdf049c9
6
+ metadata.gz: 36532dc5c62c5596207c70d8ce71689f1aa1ff74a026be27f1c1a0739a98d335f8dc83bafa968ae6acf11c99f31bbc577de1d1322718905b444b916effdb8e15
7
+ data.tar.gz: c009edab7db4301de04c468f8715650c803ac30d7e677426bde41c190de2822bd83342c73e86d7974e70449b95fa5fd1c70848233a18710ccedaf9a3e3469d77
@@ -26,7 +26,7 @@ module WizAuthc
26
26
  # private
27
27
  # def activate_wiz_auth
28
28
  # p self.session.to_s
29
- # WizAuthc::SecurityContext.init(self, Util::Account.new(self.session))
29
+ # WizAuthc::SecurityContext.init(self, Util::Account)
30
30
  # @current = WizAuthc::SecurityContext.current
31
31
  # end
32
32
  end
@@ -5,6 +5,24 @@ module WizAuthc
5
5
  class SecurityContext
6
6
  # @@ip = "0.0.0.0"
7
7
  # @@contexts = {}
8
+ attr_accessor :principal, :authenticated, :session
9
+
10
+ def initialize(principal, authenticated = nil, session = nil, ip = nil)
11
+ @principal = principal || nil
12
+ @authenticated = authenticated || false
13
+ @session = session
14
+ @ip = ip || "0.0.0.0"
15
+ @actived = false
16
+ end
17
+
18
+ def authenticated?
19
+ @authenticated
20
+ end
21
+
22
+ def user
23
+ @principal[:type].constantize.find(@principal[:identity])
24
+ end
25
+
8
26
  class << self
9
27
  def env
10
28
  Thread.current[:security_env_key]
@@ -20,7 +38,7 @@ module WizAuthc
20
38
 
21
39
  def current=(value)
22
40
  # Thread.current[:security_context_key] = value
23
- Thread.current[:security_contexts_key] = value
41
+ Thread.current[:security_contexts_key] = value
24
42
  end
25
43
 
26
44
  def session
@@ -35,17 +53,11 @@ module WizAuthc
35
53
  Thread.current[:security_contexts_key]
36
54
  end
37
55
 
38
- def init(env, current)
56
+ def init(env, klass)
39
57
  self.env = env
40
- self.current = current
58
+ self.current = klass.new(self.session)
41
59
  end
42
60
 
43
-
44
-
45
-
46
-
47
- #--------------------------
48
-
49
61
  def authenticate(realm, token)
50
62
  authc_info = realm.authenticate(token)
51
63
  # ctx = self.current
@@ -56,26 +68,6 @@ module WizAuthc
56
68
  # env.session[:security_contexts_key] = ctx
57
69
  self.current = ctx
58
70
  end
59
-
60
-
61
- end
62
-
63
- attr_accessor :principal, :authenticated, :session
64
-
65
- def initialize(principal, authenticated = nil, session = nil, ip = nil)
66
- @principal = principal || nil
67
- @authenticated = authenticated || false
68
- @session = session
69
- @ip = ip || "0.0.0.0"
70
- @actived = false
71
- end
72
-
73
- def authenticated?
74
- @authenticated
75
- end
76
-
77
- def user
78
- @principal[:type].constantize.find(@principal[:identity])
79
71
  end
80
72
  end
81
73
  end
@@ -1,3 +1,3 @@
1
1
  module Wizdog
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wizdog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - songgz