unrestful 0.1.0 → 0.1.1
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/lib/unrestful/json_web_token.rb +10 -12
- data/lib/unrestful/version.rb +1 -1
- data/lib/unrestful.rb +17 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ea06dcfb3dd07a3173d8120b6dc5c2ec3a87fba445b5be74c9d5e142c7f9937
|
4
|
+
data.tar.gz: 4773606270b337a57aec74260d2d70ce59c2082d5fe6161f75070c389780a2e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efe932682b065e59166d6636f9999d2991fd357677e143917aa27a59ea06f82da56877448e2df7b6aaeedfc6d81c505fa1eca3eb43751445e404010d05181b7a
|
7
|
+
data.tar.gz: 733c67288e6690ef2e2b0720ff14ebd1d8d4143363f67575e5808cba7ba4f82bfff116976257f54c16f1e8fb021769ec8ddf2784dcb3a047c811a84d4d34a586
|
@@ -2,22 +2,20 @@
|
|
2
2
|
require 'net/http'
|
3
3
|
require 'uri'
|
4
4
|
|
5
|
-
module Unrestful
|
5
|
+
module Unrestful
|
6
6
|
class JsonWebToken
|
7
|
-
ISSUER = 'https://cloud66.eu.auth0.com/'
|
8
7
|
LEEWAY = 30
|
9
|
-
AUDIENCE = ['central.admin.api.v2.development']
|
10
8
|
|
11
9
|
def self.verify(token)
|
12
10
|
JWT.decode(token, nil,
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
11
|
+
true,
|
12
|
+
algorithm: 'RS256',
|
13
|
+
iss: Unrestful.configuration.issuer,
|
14
|
+
verify_iss: true,
|
15
|
+
aud: Unrestful.configuration.audience,
|
16
|
+
verify_aud: true) do |header|
|
17
|
+
jwks_hash[header['kid']]
|
18
|
+
end
|
21
19
|
end
|
22
20
|
|
23
21
|
def self.jwks_hash
|
@@ -33,4 +31,4 @@ module Unrestful
|
|
33
31
|
]
|
34
32
|
end
|
35
33
|
end
|
36
|
-
end
|
34
|
+
end
|
data/lib/unrestful/version.rb
CHANGED
data/lib/unrestful.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
require "unrestful/engine"
|
2
2
|
|
3
|
-
Dir[File.join(__dir__, 'unrestful', '*.rb')].each {
|
3
|
+
Dir[File.join(__dir__, 'unrestful', '*.rb')].each {|file| require file}
|
4
4
|
|
5
5
|
module Unrestful
|
6
6
|
def self.configure(options = {}, &block)
|
7
7
|
@config = Unrestful::Config.new(options)
|
8
|
-
|
8
|
+
block.call(@config) if block.present?
|
9
9
|
@config
|
10
10
|
end
|
11
11
|
|
@@ -13,13 +13,21 @@ module Unrestful
|
|
13
13
|
@config || Unrestful::Config.new({})
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
class Config
|
17
|
+
def initialize(options)
|
18
|
+
@options = options
|
19
|
+
end
|
20
|
+
|
21
|
+
def issuer
|
22
|
+
@options[:issuer] || ENV.fetch("ISSUER")
|
23
|
+
end
|
24
|
+
|
25
|
+
def audience
|
26
|
+
@options[:audience] || ENV.fetch("AUDIENCE")
|
27
|
+
end
|
20
28
|
|
21
|
-
|
22
|
-
|
29
|
+
def redis_address
|
30
|
+
@options[:redis_address] || ENV.fetch("REDIS_URL") {"redis://localhost:6379/1"}
|
31
|
+
end
|
23
32
|
end
|
24
|
-
end
|
25
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unrestful
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Khash Sajadi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|