touth 1.0.0 → 1.0.1

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: a982bb3f2804af9044cbc34c112d9e9169e2c060
4
- data.tar.gz: 69d657f673a36d5145ce472dd03f83ef005f2ede
3
+ metadata.gz: f6424a7f72477d07f75e3d86466f63b7309767e3
4
+ data.tar.gz: ba296cbb722b4d902d5727dcd954987fc50b1c70
5
5
  SHA512:
6
- metadata.gz: 01374f38683aafa8ea082f89e4a376fcf204ae116fa4416583f18480e7644250ec2e716dbd9c68be7f0d65dafa1a1f7866aa23850ac1d78301cfc4c10dee2615
7
- data.tar.gz: d43b3269705ba47bef2ec31a2ed958a5bcade63732cf27ff840f7cb2a835de0818357cfa34d21d44c726ce8846694e22b90811e4c6a398a5372410ac9104f298
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
- name = scope.to_s
9
+ scope = scope.to_s
10
+ name = scope.gsub('::', '_').underscore
10
11
 
11
12
  self.token_authentication_on = {
12
- model_class: name.camelize.constantize,
13
- current: nil,
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[:model_class].find(id)
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
- "#{access_token_id(expires_at)}#{[expires_at].pack('V')}".unpack('H*')[0]
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[0..0x1f], data[0x20..-1]
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
@@ -1,3 +1,3 @@
1
1
  module Touth
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
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.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-07-08 00:00:00.000000000 Z
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
data/lib/touth/engine.rb DELETED
@@ -1,6 +0,0 @@
1
- require 'rails/engine'
2
-
3
- module ActsAsTaggableOn
4
- class Engine < Rails::Engine
5
- end
6
- end