flipt_client 0.0.5 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dff4c9d668eeb7aaa9c83e157e008483db259418034753a443e8410c47a6e992
4
- data.tar.gz: 62b0d2b34fcd4e9d3f0967f8637a1e70a047fffc1e58a70683c93a4f69d9e32b
3
+ metadata.gz: 1cbfce772261a0e968cbcc2b0135b851e86dda4107abe8cac583a2c2cb23692c
4
+ data.tar.gz: ae3cad47961fabefe5abd90310a3f91a3e57d35dbd976e98b0a82939bfd988b3
5
5
  SHA512:
6
- metadata.gz: 159db6c69a4909f775c471c6375d46c1af745fe3388ef4bacecdda726c29cfa0416c3b7608c16f3db5157a5c6676b778d8a8818a4e8f14dd6a5a2fe818a2efa6
7
- data.tar.gz: 98ef4522ab570ced6c555c7be9d174e3a9817ae1c8fdd87b18f6678945d180e0d529a79247292e7f5709fd76bcb7767feeb434712dffc871da2f9427abab1e82
6
+ metadata.gz: edb56a32998775cc00ff7cbc54302978e40a1f0eae8f16b15684a872d3f713b73652e924391556d6a2683a2483059a8421cb98603bc724723dc9d095813deb61
7
+ data.tar.gz: 7d684bead44f7d8eae6091f46dfcfe1bcdb8d391cdaad9796f398ab96b902e71d7a04e87678d66c5fc7df215796620a069be770d764c05e1d2f6234ca911a16f
data/README.md CHANGED
@@ -33,7 +33,9 @@ require 'flipt_client'
33
33
  # {
34
34
  # "url": "http://localhost:8080",
35
35
  # "update_interval": 120,
36
- # "auth_token": "secret"
36
+ # "authentication": {
37
+ # "client_token": "secret"
38
+ # }
37
39
  # }
38
40
  #
39
41
  # You can replace the url with where your upstream Flipt instance points to, the update interval for how long you are willing
Binary file
Binary file
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Flipt
4
+ class AuthenticationStrategy
5
+ def strategy
6
+ raise NotImplementedError
7
+ end
8
+ end
9
+
10
+ class NoAuthentication < AuthenticationStrategy
11
+ def strategy
12
+ nil
13
+ end
14
+ end
15
+
16
+ class ClientTokenAuthentication < AuthenticationStrategy
17
+ def initialize(token)
18
+ @token = token
19
+ end
20
+
21
+ def strategy
22
+ {
23
+ client_token: @token
24
+ }
25
+ end
26
+ end
27
+
28
+ class JWTAuthentication < AuthenticationStrategy
29
+ def initialize(token)
30
+ @token = token
31
+ end
32
+
33
+ def strategy
34
+ {
35
+ jwt_token: @token
36
+ }
37
+ end
38
+ end
39
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Flipt
4
- VERSION = '0.0.5'
4
+ VERSION = '0.1.0'
5
5
  end
data/lib/flipt_client.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'flipt_client/version'
4
+ require 'flipt_client/models'
4
5
  require 'ffi'
5
6
  require 'json'
6
7
 
@@ -41,11 +42,18 @@ module Flipt
41
42
  # @param namespace [String] namespace
42
43
  # @param opts [Hash] options
43
44
  # @option opts [String] :url Flipt server url
44
- # @option opts [String] :auth_token Flipt api key
45
+ # @option opts [AuthenticationStrategy] :authentication strategy to authenticate with Flipt
45
46
  # @option opts [Integer] :update_interval interval in seconds to update the cache
46
47
  # @option opts [String] :reference reference to use for namespace data
47
48
  def initialize(namespace = 'default', opts = {})
48
49
  @namespace = namespace
50
+
51
+ # set default no auth if not provided
52
+ authentication = opts.fetch(:authentication, Flipt::NoAuthentication.new)
53
+ raise ArgumentError, "invalid authentication strategy" unless authentication && authentication.is_a?(Flipt::AuthenticationStrategy)
54
+
55
+ opts[:authentication] = authentication.strategy
56
+
49
57
  namespace_list = [namespace]
50
58
  ns = FFI::MemoryPointer.new(:pointer, namespace_list.size)
51
59
  namespace_list.each_with_index do |namespace, i|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flipt_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Flipt Devs
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-01-18 00:00:00.000000000 Z
11
+ date: 2024-01-25 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Flipt Client Evaluation SDK
14
14
  email:
@@ -30,6 +30,7 @@ files:
30
30
  - lib/ext/linux_x86_64/libfliptengine.rlib
31
31
  - lib/ext/linux_x86_64/libfliptengine.so
32
32
  - lib/flipt_client.rb
33
+ - lib/flipt_client/models.rb
33
34
  - lib/flipt_client/version.rb
34
35
  homepage: https://www.flipt.io
35
36
  licenses: