usps-jwt_auth 0.0.11 → 0.1.0
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 +4 -4
- data/README.md +2 -2
- data/lib/usps/jwt_auth/concern.rb +8 -6
- data/lib/usps/jwt_auth/decode.rb +1 -1
- data/lib/usps/jwt_auth/encode.rb +4 -4
- data/lib/usps/jwt_auth/version.rb +1 -1
- data/lib/usps/jwt_auth.rb +13 -9
- data/tmp/keys/.keep +0 -0
- data/tmp/public_keys/.keep +0 -0
- metadata +17 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bef3a2f9487801b5701b5ceb1535b33b5230de5dfd94f5e48426de8a31a596c3
|
|
4
|
+
data.tar.gz: ead0edafff0f1989a2e843f730d8346f1c70dbae64629c63bddf46e0c157ab2c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1fb8f9881a6fe9e1a3aeaff5d3a0a9d37ee58b3d64cc4df5c3864cc0a96dee4f30201aa145d553e0317f7aaef8a88a3b22ba1027407e8c9550b4fbc90c8b6af9
|
|
7
|
+
data.tar.gz: c6f8302d87d93f65346e3135d740517b06f30f26ea6503b4d8375c4d0bb44f0fcc48d752fc61bb3e42549490be4b3c4e8104e40910fd3a3d25f1ad75d5f1b6f5
|
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
|
|
10
|
+
gem 'usps-jwt_auth', '>= 0.1.0'
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
data/lib/usps/jwt_auth/decode.rb
CHANGED
data/lib/usps/jwt_auth/encode.rb
CHANGED
|
@@ -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
|
-
|
|
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
|
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
|
-
|
|
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
|
|
4
|
+
version: 0.1.0
|
|
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:
|