warden-jwt_auth 0.3.2 → 0.3.3

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: e5ef370e2769321525a4f8d75188c541befe14f8
4
- data.tar.gz: 719f327eca349ce320832fb46ca2057893feb2fc
3
+ metadata.gz: 707c2b046b0c4685a5c98b18456c305c1fafd23b
4
+ data.tar.gz: 82f98685925f55704ec296b24c0bfe08636951b4
5
5
  SHA512:
6
- metadata.gz: ba697509f99e66bdc16a8eb7c4b3575ffefe7cc122e4ebf7ebc5a807eefbc2f6f5667e79b724b517b2b6078c731c3c3b955b7feadc71127b0d942664e4c29d68
7
- data.tar.gz: 9b292cca9927bda28c92decf5170ef0f7c0f040e88770fb126591370c1b22fe49e9e27a8783e2844d0b81eda4dfb01d4811ffdff1822a6fa34402a647323f128
6
+ metadata.gz: bb23f8f0bca81024fdab60bceaeb5235eb06da768641ff212d84aadb8b9aa557adf6c70f5fa3ed53ccb43eb0287da33b1a5edfbb3282d46b9c3f7a5707e194e1
7
+ data.tar.gz: 2035526baabad186a0bb3aadb09ab3379ca0fab48a341b14071de57e5c9a794981596887d3a006376530e7bc861d743d5dd8f5119bd6a93587051367305582b7
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
+ ## [0.3.3] - 2017-12-31
8
+ ### Fixed
9
+ - Check it is not a html request when disallowing fetching from session
10
+
7
11
  ## [0.3.2] - 2017-12-23
8
12
  ### Fixed
9
13
  - Do not couple `aud_header` env value to the setting
data/README.md CHANGED
@@ -24,7 +24,7 @@ If what you need is a JWT authentication library for [devise](https://github.com
24
24
  ## Installation
25
25
 
26
26
  ```ruby
27
- gem 'warden-jwt_auth', '~> 0.3.2'
27
+ gem 'warden-jwt_auth', '~> 0.3.3'
28
28
  ```
29
29
 
30
30
  And then execute:
@@ -56,6 +56,16 @@ module Warden
56
56
  env_name = ('HTTP_' + JWTAuth.config.aud_header.upcase).tr('-', '_')
57
57
  env[env_name]
58
58
  end
59
+
60
+ # Returns whether `text/html` is within `Accept` header values
61
+ #
62
+ # @param env [Hash] Rack env
63
+ # @return [Boolean]
64
+ def self.html_request?(env)
65
+ accept = env['HTTP_ACCEPT']
66
+ return false unless accept
67
+ accept.include?('text/html')
68
+ end
59
69
  end
60
70
  end
61
71
  end
@@ -18,11 +18,12 @@ module Warden
18
18
  new.send(:prepare_token, user, auth, opts)
19
19
  end
20
20
 
21
- # Sign out a JWT scope if it comes from the session.
21
+ # Sign out a JWT scope if it comes from the session unless it is an HTML
22
+ # request
22
23
  #
23
24
  # If a user is meant to be authenticated via JWT, then if it is fetched
24
- # from the session it must be something not intended to happen and a
25
- # security threat.
25
+ # from the session during an API request it must be something not intended
26
+ # to happen and a security threat.
26
27
  #
27
28
  # Workaround until https://github.com/hassox/warden/pull/118 is fixed
28
29
  def self.after_fetch(_user, auth, opts)
@@ -38,9 +39,11 @@ module Warden
38
39
  add_token_to_env(user, scope, env)
39
40
  end
40
41
 
42
+ # :reek:FeatureEnvy
41
43
  def logout_scope(auth, opts)
44
+ env = auth.env
42
45
  scope = opts[:scope]
43
- return unless jwt_scope?(scope)
46
+ return if !jwt_scope?(scope) || EnvHelper.html_request?(env)
44
47
  auth.logout(scope)
45
48
  end
46
49
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Warden
4
4
  module JWTAuth
5
- VERSION = '0.3.2'
5
+ VERSION = '0.3.3'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: warden-jwt_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marc Busqué
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-23 00:00:00.000000000 Z
11
+ date: 2017-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-configurable