jwt-auth 2.1.0 → 2.1.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: b41cd772fd3da17cae17a45c21f90686d17d0cfd
4
- data.tar.gz: 11722c972099efd07ea4bc4311fc57a6e3c45d88
3
+ metadata.gz: 42a50e3f1afb56c8a515e6e3db6c6dac43a9a252
4
+ data.tar.gz: 8e67ea27890271ccadf46286cad3db9bdccdaa4a
5
5
  SHA512:
6
- metadata.gz: e40395a5846af7338bc32bd9f9812d20b7fe2e9c19a5a33eda0ff2bddd0b3dfb7c742366ad5a6f7f455a0d66d1ebc04df7b7cd6da86f41538be362387555c507
7
- data.tar.gz: 954162e9bdb932df424d6812b574b0eaf5734802ed1f4dc42d46ace4a89288af4229926480501888c6dfe6481a99daf9dd7cb9c4cae596265ede5024002dd2a5
6
+ metadata.gz: 69f38d3381bbc286f861b69ab1b4ed8b8bfcd2f774c8404be269cf503d1694d89ae946222d0f07978d8d379b46a60901ed6f5057a32b731f764c2dc8967f3e61
7
+ data.tar.gz: 30e3db0cd10b4f2d668013939a48d17fb4f8681016843d1621551323a4d880d79e9beed7cc1dd8dec32a58536ef202854be60cb1335f1d6b22c1eb0e53468a05
@@ -28,4 +28,5 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency 'rubocop', '~> 0.48'
29
29
  spec.add_development_dependency 'rake', '~> 12.0'
30
30
  spec.add_development_dependency 'rspec', '~> 3.5'
31
+ spec.add_development_dependency 'rspec-rails', '~> 3.5'
31
32
  end
@@ -12,14 +12,14 @@ module JWT
12
12
  # Current user helper
13
13
  #
14
14
  def current_user
15
- token&.subject
15
+ jwt&.subject
16
16
  end
17
17
 
18
18
  ##
19
19
  # Authenticate a request
20
20
  #
21
21
  def authenticate_user
22
- raise JWT::Auth::UnauthorizedError unless token&.valid?
22
+ raise JWT::Auth::UnauthorizedError unless jwt&.valid?
23
23
 
24
24
  # Regenerate token (renews expiration date)
25
25
  add_token_to_response
@@ -29,9 +29,9 @@ module JWT
29
29
  # Add JWT header to response
30
30
  #
31
31
  def add_token_to_response
32
- return unless token&.valid?
33
- token.renew!
34
- response.headers['Authorization'] = "Bearer #{token.to_jwt}"
32
+ return unless jwt&.valid?
33
+ jwt.renew!
34
+ response.headers['Authorization'] = "Bearer #{jwt.to_jwt}"
35
35
  end
36
36
 
37
37
  protected
@@ -39,7 +39,7 @@ module JWT
39
39
  ##
40
40
  # Extract JWT from request
41
41
  #
42
- def token
42
+ def jwt
43
43
  return @token if @token
44
44
 
45
45
  header = request.env['HTTP_AUTHORIZATION']
@@ -2,6 +2,6 @@
2
2
 
3
3
  module JWT
4
4
  module Auth
5
- VERSION = '2.1.0'
5
+ VERSION = '2.1.1'
6
6
  end
7
7
  end
@@ -1,15 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'support/dummy_user'
3
+ require 'securerandom'
4
+
5
+ require 'rails_helper'
4
6
 
5
7
  RSpec.describe JWT::Auth do
6
8
  it 'configures correctly' do
7
9
  JWT::Auth.configure do |config|
8
- config.token_lifetime = 666
10
+ config.token_lifetime = 24.hours
9
11
  config.secret = 'mysecret'
10
12
  end
11
13
 
12
- expect(subject.token_lifetime).to eq 666
14
+ expect(subject.token_lifetime).to eq 24.hours
13
15
  expect(subject.secret).to eq 'mysecret'
14
16
  expect(subject.model).to eq DummyUser
15
17
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'jwt/auth'
4
+ require 'rails'
4
5
 
5
6
  # This file was generated by the `rspec --init` command. Conventionally, all
6
7
  # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'jwt/auth'
4
-
5
3
  class DummyUser
6
4
  include JWT::Auth::Authenticatable
7
5
 
@@ -3,14 +3,6 @@
3
3
  require 'support/dummy_user'
4
4
 
5
5
  RSpec.describe JWT::Auth::Token do
6
- before :each do
7
- JWT::Auth.configure do |config|
8
- config.token_lifetime = 24.hours
9
-
10
- config.secret = 'mysecret'
11
- end
12
- end
13
-
14
6
  let(:user) { DummyUser.new }
15
7
 
16
8
  describe 'properties' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jwt-auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Dejonckheere
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-19 00:00:00.000000000 Z
11
+ date: 2017-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jwt
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '3.5'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec-rails
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.5'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.5'
97
111
  description: Authentication middleware for Rails API that uses JWTs, without depending
98
112
  on Devise
99
113
  email: