usps-jwt_auth 0.0.11 → 0.0.12

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
  SHA256:
3
- metadata.gz: a36f3269684dc5286fbe71b28953e0809717b406ebc1b84475d824a060f76e88
4
- data.tar.gz: d92c305138d13c156e53fd44396b2765614d25f922e4ab5788d387ac00f3dce1
3
+ metadata.gz: '08b2986886329a7add9ad0cb47b90a1daaa870b2ade79072c20e650dbef455b7'
4
+ data.tar.gz: c52a9a66374742a3fedd25149b4b7394c2568c9c6eaca89f4c3259f9e184707d
5
5
  SHA512:
6
- metadata.gz: 3efc7c11f38825234c4f1e8c24f29315c846666caebf31c70dc3d997e80b18612c9acbbbe81718c93c7e03bc9e63e7a040bd965757a5b92ab2c025a8ee888c8b
7
- data.tar.gz: b8d45fbdf7eca6e014768790caf2f10c0f184eb32bdd0dd45cc7b6ec7a62ca1f13a5686d378899d8b5092f669605b50b2560fb1b281960ef273f8c1f41e4b1b7
6
+ metadata.gz: 87346a7fb222c2a4348623971b3e095db84780e2580317901677bfd2e972a2fed15a3abdd9810c153dd0ca1997a64c41f5f6aff2021ad277119ddfe463d371c3
7
+ data.tar.gz: 7c0055bf8e118d80e333e28c7e5a5a0f49955f066fe7a177c8882e6db7207519a95a639ac130dfa036e11f73e1a5c6bdf3cdef687ea427863b653e9a9b54395b
data/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  Add the gem to your Gemfile:
8
8
 
9
9
  ```ruby
10
- gem 'usps-jwt_auth', '>= 0.0.11'
10
+ gem 'usps-jwt_auth', '>= 0.0.12'
11
11
  ```
12
12
 
13
13
  Then run the install task:
@@ -27,7 +27,7 @@ Usps::JwtAuth.configure do |config|
27
27
  config.jwt = {
28
28
  audience: ENV.fetch('JWT_AUDIENCE'),
29
29
  issuer_base: ENV.fetch('JWT_ISSUER_BASE', 'usps:1'),
30
- issuers: ENV.fetch('JWT_ISSUERS', 'admin:1').split(','),
30
+ issuers: ENV.fetch('JWT_ISSUERS', 'admin:1').split(',')
31
31
  }
32
32
  end
33
33
  ```
@@ -5,12 +5,14 @@ module Usps
5
5
  # Controller helpers for handling JWT authentication
6
6
  #
7
7
  module Concern
8
- extend ActiveSupport::Concern
9
-
10
- included do
11
- helper_method :current_user
12
- helper_method :jwt_user
13
- helper_method :user_signed_in?
8
+ if defined?(ActiveSupport::Concern)
9
+ extend ActiveSupport::Concern
10
+
11
+ included do
12
+ helper_method :current_user
13
+ helper_method :jwt_user
14
+ helper_method :user_signed_in?
15
+ end
14
16
  end
15
17
 
16
18
  private
@@ -9,7 +9,7 @@ module Usps
9
9
  required_claims: %w[iss exp],
10
10
  verify_iss: true,
11
11
  verify_aud: true,
12
- algorithm: 'RS512'
12
+ algorithm: JwtAuth::ALGORITHM
13
13
  }.freeze
14
14
 
15
15
  def self.decode(token, audience: [], issuer: nil)
@@ -23,7 +23,7 @@ module Usps
23
23
  end
24
24
 
25
25
  def encode(data)
26
- JWT.encode(payload(data), private_key, ALGORITHM)
26
+ JWT.encode(payload(data), private_key, JwtAuth::ALGORITHM)
27
27
  end
28
28
 
29
29
  def public_key
@@ -37,7 +37,7 @@ module Usps
37
37
  private
38
38
 
39
39
  def expires_at
40
- DateTime.now.to_i + @expiration_time
40
+ ::Time.now.to_i + @expiration_time
41
41
  end
42
42
 
43
43
  def payload(data)
@@ -61,13 +61,13 @@ module Usps
61
61
  def store_private_key
62
62
  path = "#{JwtAuth.configuration.keys_path}/#{fingerprint}"
63
63
  File.open(path, 'w+') { |f| f.puts(private_key) }
64
- FileUtils.chmod(0o600, path)
64
+ ::FileUtils.chmod(0o600, path)
65
65
  end
66
66
 
67
67
  def store_public_key
68
68
  path = "#{JwtAuth.configuration.public_keys_path}/#{fingerprint}.pub"
69
69
  File.open(path, 'w+') { |f| f.puts(public_key) }
70
- FileUtils.chmod(0o644, path)
70
+ ::FileUtils.chmod(0o644, path)
71
71
  end
72
72
 
73
73
  def generate_private_key
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Usps
4
4
  module JwtAuth
5
- VERSION = '0.0.11'
5
+ VERSION = '0.0.12'
6
6
  end
7
7
  end
data/lib/usps/jwt_auth.rb CHANGED
@@ -1,20 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'jwt'
4
-
5
- # Internal requires
6
- require_relative 'jwt_auth/version'
7
- require_relative 'jwt_auth/config'
8
- require_relative 'jwt_auth/encode'
9
- require_relative 'jwt_auth/decode'
10
- require_relative 'jwt_auth/concern'
11
-
12
- require 'usps/jwt_auth/railtie' if defined?(Rails)
4
+ require 'active_support/ordered_options'
5
+ require 'fileutils'
13
6
 
14
7
  module Usps
15
8
  # Unified configuration for handling JWT Authentication
16
9
  #
17
10
  module JwtAuth
11
+ ALGORITHM = 'RS512'
12
+
18
13
  class << self
19
14
  def configuration
20
15
  @configuration ||= Config.new
@@ -35,3 +30,12 @@ module Usps
35
30
  end
36
31
  end
37
32
  end
33
+
34
+ # Internal requires
35
+ require_relative 'jwt_auth/version'
36
+ require_relative 'jwt_auth/config'
37
+ require_relative 'jwt_auth/encode'
38
+ require_relative 'jwt_auth/decode'
39
+ require_relative 'jwt_auth/concern'
40
+
41
+ require 'usps/jwt_auth/railtie' if defined?(Rails)
data/tmp/keys/.keep ADDED
File without changes
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: usps-jwt_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander
@@ -9,6 +9,20 @@ bindir: bin
9
9
  cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: fileutils
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '1.7'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '1.7'
12
26
  - !ruby/object:Gem::Dependency
13
27
  name: jwt
14
28
  requirement: !ruby/object:Gem::Requirement
@@ -42,6 +56,8 @@ files:
42
56
  - lib/usps/jwt_auth/railtie.rb
43
57
  - lib/usps/jwt_auth/version.rb
44
58
  - sig/usps_jwt/auth.rbs
59
+ - tmp/keys/.keep
60
+ - tmp/public_keys/.keep
45
61
  homepage: https://www.usps.org
46
62
  licenses: []
47
63
  metadata: