warrant 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8782e5ba0cc2c866761a7c4d906eebe324202b9ea12a14f50b0f250c62483c20
4
- data.tar.gz: cfe03ef0070f0e60d8c88f1a8e636c93eb7265d5a367e6f1d99cb787a2e0aff3
3
+ metadata.gz: eedc398b4f1277eabdabf8252acde068e1a1398f0b3752d217793ec1d22570b3
4
+ data.tar.gz: 035f98bda116c4177ead75b9895a86582b2b37fd7d04b1b2175e68f73c0adff5
5
5
  SHA512:
6
- metadata.gz: 7e7a48c244de2fa3a9e402682c3775f84e429e1330404dc1b06281dd5c689379cb974e47c6fc0fc0b8175d52edbaea34e893946c3bcbec029d7d579201e05ffc
7
- data.tar.gz: 966d6a67910a9d001f26a592fc226813b9d82acd61b2cb684c84fff8adc9e1b63e50970c366c217022f5bf5a57316d977f1d0736930c038a9af79171f99dd2f1
6
+ metadata.gz: b5d81834bffb0ac19ed371259e6b321ca23aa42a8ab0dd1bcf8c720fec168910ed8dcfe620942d17d4d399834593856080dbe802f786d273466db347089b10b4
7
+ data.tar.gz: 717cce9e98093c01c7412323894e7eb9f87742ae412eac1564e8e91184a3cea327dbb76ee7d5131196389c8df7e6b5a112ed24a6ccbd270f75a0277f2356b651
data/README.md CHANGED
@@ -44,13 +44,36 @@ You can also build the gem from source:
44
44
  require 'warrant'
45
45
  Warrant.api_key = 'api_test_f5dsKVeYnVSLHGje44zAygqgqXiLJBICbFzCiAg1E='
46
46
 
47
- # create a user
47
+ # Create a user
48
48
  Warrant::User.create(user_id: "user123")
49
49
 
50
- # check whether user slp951 has view access to report 7asm24
50
+ # Check whether user slp951 has view access to report 7asm24
51
51
  Warrant::Warrant.is_authorized?(object_type: "report", object_id: "7asm24", relation: "viewer", subject: { object_id: "user", object_id: "slp951" })
52
52
  ```
53
53
 
54
+ ## Configuring the API and Authorize Endpoints
55
+ ---
56
+ The API and Authorize endpoints the SDK makes requests to is configurable via the `Warrant.api_base` and `Warrant.authorize_endpoint` attributes:
57
+
58
+ ```ruby
59
+ require 'warrant'
60
+
61
+ # Set api and authorize endpoints to http://localhost:8000
62
+ Warrant.api_base = 'http://localhost:8000'
63
+ Warrant.authorize_endpoint = 'http://localhost:8000'
64
+ ```
65
+
66
+ ## Configuring SSL
67
+ ---
68
+ By default, the SDK will attempt to use SSL when making requests to the API. This setting is configurable via the `Warrant.use_ssl` attribute:
69
+
70
+ ```ruby
71
+ require 'warrant'
72
+
73
+ # Disable ssl
74
+ Warrant.use_ssl = false
75
+ ```
76
+
54
77
 
55
78
  We’ve used a random API key in these code examples. Replace it with your [actual publishable API keys](https://app.warrant.dev) to
56
79
  test this code through your own Warrant account.
@@ -4,21 +4,21 @@ module Warrant
4
4
  # @!visibility private
5
5
  class APIOperations
6
6
  class << self
7
- def post(uri, params = {}, use_ssl = true)
7
+ def post(uri, params = {})
8
8
  http = Net::HTTP.new(uri.host, uri.port)
9
- http.use_ssl = use_ssl
9
+ http.use_ssl = ::Warrant.config.use_ssl
10
10
  headers = {
11
- "Authorization": "ApiKey #{::Warrant.config.api_key}",
12
11
  "User-Agent": "warrant-ruby/#{VERSION}"
13
12
  }
13
+ headers["Authorization"] = "ApiKey #{::Warrant.config.api_key}" unless ::Warrant.config.api_key.empty?
14
14
  http.post(uri.path, params.to_json, headers)
15
15
  end
16
16
 
17
17
  def delete(uri, params = {})
18
18
  http = Net::HTTP.new(uri.host, uri.port)
19
- http.use_ssl = true
19
+ http.use_ssl = ::Warrant.config.use_ssl
20
20
  request = Net::HTTP::Delete.new(uri.path)
21
- request["Authorization"] = "ApiKey #{::Warrant.config.api_key}"
21
+ request["Authorization"] = "ApiKey #{::Warrant.config.api_key}" unless ::Warrant.config.api_key.empty?
22
22
  request["User-Agent"] = "warrant-ruby/#{VERSION}"
23
23
 
24
24
  http.request(request, params.to_json)
@@ -26,11 +26,11 @@ module Warrant
26
26
 
27
27
  def get(uri, params = {})
28
28
  http = Net::HTTP.new(uri.host, uri.port)
29
- http.use_ssl = true
29
+ http.use_ssl = ::Warrant.config.use_ssl
30
30
  headers = {
31
- "Authorization": "ApiKey #{::Warrant.config.api_key}",
32
31
  "User-Agent": "warrant-ruby/#{VERSION}"
33
32
  }
33
+ headers["Authorization"] = "ApiKey #{::Warrant.config.api_key}" unless ::Warrant.config.api_key.empty?
34
34
 
35
35
  unless params.empty?
36
36
  normalized_params = Util.normalize_params(params.compact)
@@ -42,11 +42,11 @@ module Warrant
42
42
 
43
43
  def put(uri, params = {})
44
44
  http = Net::HTTP.new(uri.host, uri.port)
45
- http.use_ssl = true
45
+ http.use_ssl = ::Warrant.config.use_ssl
46
46
  headers = {
47
- "Authorization": "ApiKey #{::Warrant.config.api_key}",
48
47
  "User-Agent": "warrant-ruby/#{VERSION}"
49
48
  }
49
+ headers["Authorization"] = "ApiKey #{::Warrant.config.api_key}" unless ::Warrant.config.api_key.empty?
50
50
  http.put(uri.path, params.to_json, headers)
51
51
  end
52
52
 
@@ -413,7 +413,7 @@ module Warrant
413
413
 
414
414
  def self.edge_authorize?(params = {})
415
415
  request_url = URI.parse("#{::Warrant.config.authorize_endpoint}/v2/authorize")
416
- res = APIOperations.post(request_url, Util.normalize_params(params), request_url.scheme === "https")
416
+ res = APIOperations.post(request_url, Util.normalize_params(params))
417
417
  res_json = JSON.parse(res.body)
418
418
 
419
419
  case res
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Warrant
4
- VERSION = "3.0.0"
4
+ VERSION = "3.1.0"
5
5
  end
@@ -3,14 +3,16 @@
3
3
  module Warrant
4
4
  # @!visibility private
5
5
  class WarrantConfiguration
6
- attr_accessor :api_key, :api_base, :authorize_endpoint
6
+ attr_accessor :api_key, :api_base, :authorize_endpoint, :use_ssl
7
7
 
8
8
  attr_reader :self_service_dash_url_base
9
9
 
10
10
  def initialize
11
+ @api_key = ""
11
12
  @api_base = "https://api.warrant.dev"
12
13
  @authorize_endpoint = "https://api.warrant.dev"
13
14
  @self_service_dash_url_base = "https://self-serve.warrant.dev"
15
+ @use_ssl = true
14
16
  end
15
17
  end
16
18
  end
data/lib/warrant.rb CHANGED
@@ -31,6 +31,6 @@ module Warrant
31
31
 
32
32
  attr_reader :config
33
33
 
34
- def_delegators :@config, :api_key, :api_key=, :api_base, :api_base=, :authorize_endpoint, :authorize_endpoint=
34
+ def_delegators :@config, :api_key, :api_key=, :api_base, :api_base=, :authorize_endpoint, :authorize_endpoint=, :use_ssl, :use_ssl=
35
35
  end
36
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: warrant
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Warrant
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-15 00:00:00.000000000 Z
11
+ date: 2023-03-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby library for the Warrant API at https://warrant.dev.
14
14
  email: hello@warrant.dev
@@ -50,7 +50,7 @@ metadata:
50
50
  source_code_uri: https://github.com/warrant-dev/warrant-ruby
51
51
  changelog_uri: https://github.com/warrant-dev/warrant-ruby/CHANGELOG.md
52
52
  documentation_uri: https://docs.warrant.dev/
53
- post_install_message:
53
+ post_install_message:
54
54
  rdoc_options: []
55
55
  require_paths:
56
56
  - lib
@@ -65,8 +65,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
65
  - !ruby/object:Gem::Version
66
66
  version: '0'
67
67
  requirements: []
68
- rubygems_version: 3.2.32
69
- signing_key:
68
+ rubygems_version: 3.2.33
69
+ signing_key:
70
70
  specification_version: 4
71
71
  summary: Warrant Ruby Library
72
72
  test_files: []