sorcery-jwt 0.1.2 → 0.1.3

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
  SHA256:
3
- metadata.gz: '09f38060c81762c5e4233f380978caf87149304fb82b33005e7889f8897e26f8'
4
- data.tar.gz: 6749ca1dbbc5185e45366664cd2a6e164de26020220af1975a397141f4044629
3
+ metadata.gz: 83ffa69e0a5299c467710cc85a33bf9b7d77c8cd76a4677f6d9acedc7fcfd1c7
4
+ data.tar.gz: 642d06e047c425807c76a6483edaa3784c010f6c1e3af8328b7ef2004e7d5b36
5
5
  SHA512:
6
- metadata.gz: 12e0c09f0ef34229d4ba0ff3bf79f03c57edf466510a5c61faf10f9429b794a12283ae6cd183df6cb864d8afe38002f02d5ed9cae81cb359107ed3b7e858a7d0
7
- data.tar.gz: 9c544b7c7ead509c5af23f4dbe78ef82617607efca0a7d6e6afcce716b8a18ee348da6db9d96b84d0588d728342eccd1459a0216c9ff8f8003bf30c8a6ac9be0
6
+ metadata.gz: f22289c2e99ed9168613ff171583837587920869898a2a41e63104794f86cf0bf1298111d5de8f7a6abca8a46df8324770e0f26703346ec8d7194f39d4d4bb55
7
+ data.tar.gz: 8444ba0bf0598383d23d6c741ab20d5ac3e208508166d4f6b6e7fd7e61a2ea4b776ea56351cfa83430ca5824a18e1c446721538bb7b441aebbb59875e417ed98
@@ -16,7 +16,7 @@ module Sorcery
16
16
  @current_user = user_class.find_by(user)
17
17
  auto_login(@current_user) if @current_user
18
18
  @current_user
19
- rescue JWT::DecodeError
19
+ rescue JWT::DecodeError, JWT::ExpiredSignature
20
20
  @current_user = false
21
21
  end
22
22
 
@@ -32,6 +32,7 @@ module Sorcery
32
32
 
33
33
  def token
34
34
  return nil unless authorization_header
35
+
35
36
  authorization_header.split(" ").last
36
37
  end
37
38
 
@@ -1,5 +1,5 @@
1
1
  module Sorcery
2
2
  module Jwt
3
- VERSION = "0.1.2".freeze
3
+ VERSION = "0.1.3".freeze
4
4
  end
5
5
  end
@@ -11,10 +11,13 @@ module Sorcery
11
11
  attr_accessor :jwt_secret
12
12
  # Type of the algorithm used to encode JWTs. Corresponds to the options available in jwt/ruby-jwt.
13
13
  attr_accessor :jwt_algorithm
14
+ # How long the session should be valid for in seconds. Will be set as the exp claim in the token.
15
+ attr_accessor :session_expiry
14
16
  end
15
17
 
16
18
  base.sorcery_config.instance_eval do
17
19
  @defaults[:@jwt_algorithm] = "HS256"
20
+ @defaults[:@session_expiry] = Time.now.to_i + (3600 * 24 * 14)
18
21
 
19
22
  reset!
20
23
  end
@@ -27,7 +30,8 @@ module Sorcery
27
30
 
28
31
  module ClassMethods
29
32
  def issue_token(payload)
30
- JWT.encode(payload, @sorcery_config.jwt_secret, @sorcery_config.jwt_algorithm)
33
+ exp_payload = payload.merge(exp: @sorcery_config.session_expiry)
34
+ JWT.encode(exp_payload, @sorcery_config.jwt_secret, @sorcery_config.jwt_algorithm)
31
35
  end
32
36
 
33
37
  def decode_token(token)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sorcery-jwt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hayden Luckenbach
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-16 00:00:00.000000000 Z
11
+ date: 2019-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler