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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a72f2af5b6292b01574673437b1e1102ec301d6dadc818b56a3e5e2f98beeaf
4
- data.tar.gz: a8bb7550136979bb330de73d7f4b303121cf5e2685504b2ce9848f847c118527
3
+ metadata.gz: 4ea06dcfb3dd07a3173d8120b6dc5c2ec3a87fba445b5be74c9d5e142c7f9937
4
+ data.tar.gz: 4773606270b337a57aec74260d2d70ce59c2082d5fe6161f75070c389780a2e6
5
5
  SHA512:
6
- metadata.gz: 34dec6df9aae1c4fb211cfee6d8dd1069aad5f9938b1d3058e1095d5dd5e6026c1d4987402987041d93935d7fcdd1069100af2aa4e994f92253152e4e20b8c14
7
- data.tar.gz: 36b3738b1dc28431c44941665cb5c9c1e8c81df6540565a22bb2a82c3311507ad43616679e58c9df3acb98f75ee3d91c25b5ae0acff139db1d59d0fbdf3fb3f9
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
- true,
14
- algorithm: 'RS256',
15
- iss: ISSUER,
16
- verify_iss: true,
17
- aud: AUDIENCE,
18
- verify_aud: true) do |header|
19
- jwks_hash[header['kid']]
20
- end
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
@@ -1,3 +1,3 @@
1
1
  module Unrestful
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
data/lib/unrestful.rb CHANGED
@@ -1,11 +1,11 @@
1
1
  require "unrestful/engine"
2
2
 
3
- Dir[File.join(__dir__, 'unrestful', '*.rb')].each { |file| require file }
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
- class Config
17
- def initialize(options)
18
- @options = options
19
- end
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
- def redis_address
22
- @options[:redis_address] || ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" }
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.0
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-09 00:00:00.000000000 Z
11
+ date: 2019-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails