touth 1.0.0 → 1.0.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 +4 -4
- data/lib/touth.rb +0 -3
- data/lib/touth/action_controller_support.rb +5 -4
- data/lib/touth/acts_as_token_authenticatable.rb +2 -2
- data/lib/touth/version.rb +1 -1
- metadata +2 -3
- data/lib/touth/engine.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6424a7f72477d07f75e3d86466f63b7309767e3
|
4
|
+
data.tar.gz: ba296cbb722b4d902d5727dcd954987fc50b1c70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fd354d81d7ac6b1c873d31241bc6043cfca190febe0d2d3acca887371463e6cec7ad74e8d3dbbaba1fff7097dd5296ee88288a9a14ca60f499004ea334fc773
|
7
|
+
data.tar.gz: 8eadb69151befd9645955bfad92273eb2c1178afdd1f491e5f1b4cb8bd97924b0ef6c0a3b67cc8564b878057aa7a1b8e369311cdce3c32ff27dbdfef0d81f25a
|
data/lib/touth.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
require 'active_support'
|
2
2
|
|
3
|
-
require_relative 'touth/engine' if defined? Rails
|
4
|
-
|
5
3
|
|
6
4
|
# Touth
|
7
5
|
#-----------------------------------------------
|
@@ -71,4 +69,3 @@ ActiveSupport.on_load(:action_controller) do
|
|
71
69
|
extend Touth::ActionControllerSupport::ClassMethods
|
72
70
|
include Touth::ActionControllerSupport::InstanceMethods
|
73
71
|
end
|
74
|
-
|
@@ -6,11 +6,12 @@ module Touth
|
|
6
6
|
mattr_accessor :token_authentication_on
|
7
7
|
|
8
8
|
def token_authentication_for(scope)
|
9
|
-
|
9
|
+
scope = scope.to_s
|
10
|
+
name = scope.gsub('::', '_').underscore
|
10
11
|
|
11
12
|
self.token_authentication_on = {
|
12
|
-
|
13
|
-
current:
|
13
|
+
class: scope.camelize.constantize,
|
14
|
+
current: nil,
|
14
15
|
}
|
15
16
|
|
16
17
|
before_action :authenticate_entity_from_token!
|
@@ -41,7 +42,7 @@ module Touth
|
|
41
42
|
id = token_authentication_header[:id]
|
42
43
|
|
43
44
|
model = id.present? \
|
44
|
-
&& self.class.token_authentication_on[:
|
45
|
+
&& self.class.token_authentication_on[:class].find(id)
|
45
46
|
|
46
47
|
unless model
|
47
48
|
return token_authentication_error! :no_entity
|
@@ -4,13 +4,13 @@ module Touth
|
|
4
4
|
def access_token(lifetime = Touth.access_token_lifetime)
|
5
5
|
expires_at = Time.now.to_i + lifetime
|
6
6
|
|
7
|
-
|
7
|
+
[access_token_id(expires_at), [expires_at].pack('V')].join.unpack('H*')[0]
|
8
8
|
end
|
9
9
|
|
10
10
|
def valid_access_token?(token)
|
11
11
|
begin
|
12
12
|
data = [token].pack 'H*'
|
13
|
-
token_id, timestamp = data
|
13
|
+
token_id, timestamp = data.unpack 'A32A*'
|
14
14
|
expires_at = timestamp.unpack('V')[0]
|
15
15
|
|
16
16
|
access_token_id(expires_at) == token_id && Time.now.to_i < expires_at
|
data/lib/touth/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: touth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuki Iwanaga
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -74,7 +74,6 @@ files:
|
|
74
74
|
- lib/touth/action_controller_support.rb
|
75
75
|
- lib/touth/active_record_support.rb
|
76
76
|
- lib/touth/acts_as_token_authenticatable.rb
|
77
|
-
- lib/touth/engine.rb
|
78
77
|
- lib/touth/version.rb
|
79
78
|
- touth.gemspec
|
80
79
|
homepage: https://github.com/creasty/touth
|