flipt_client 1.0.0 → 1.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 +103 -0
- data/lib/ext/darwin_aarch64/libfliptengine.dylib +0 -0
- data/lib/ext/darwin_x86_64/libfliptengine.dylib +0 -0
- data/lib/ext/linux_aarch64/libfliptengine.so +0 -0
- data/lib/ext/linux_x86_64/libfliptengine.so +0 -0
- data/lib/ext/windows_x86_64/fliptengine.dll +0 -0
- data/lib/flipt_client/models.rb +101 -0
- data/lib/flipt_client/version.rb +1 -1
- data/lib/flipt_client.rb +9 -0
- 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: 02ba6911dc6076bbc0703d4c08a242ba24bb75ce82ce2fbce36822b51981c50e
|
4
|
+
data.tar.gz: fd4810c100d71063d4f61d8c4d752f07b616ac6f6d7ce4b31446d4360b766682
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb5e9dce20daa6f5bb0998a5b0a99635c23ac5d9d8ac76eb111bc7e87de4d9d730754bf9c3cc4be5f89f788c596c254153d0f31bf2137d28d086bc38516bfcd2
|
7
|
+
data.tar.gz: 569fbc3bf3dd29205881aaab465592891f37dbcd3112f12f54dc4e9ac6977c4e111fda0ac1e77474af0f879fc36bcc1ff4f98aaddd5a7ad07e1c4df2641f06b6
|
data/README.md
CHANGED
@@ -114,6 +114,7 @@ The `Flipt::Client` constructor accepts the following keyword arguments:
|
|
114
114
|
- `fetch_mode`: The fetch mode to use. Defaults to polling.
|
115
115
|
- `error_strategy`: The error strategy to use. Defaults to fail. See [Error Strategies](#error-strategies).
|
116
116
|
- `snapshot`: The snapshot to use when initializing the client. Defaults to no snapshot. See [Snapshotting](#snapshotting).
|
117
|
+
- `tls_config`: The TLS configuration for connecting to servers with custom certificates. See [TLS Configuration](#tls-configuration).
|
117
118
|
|
118
119
|
### Authentication
|
119
120
|
|
@@ -123,6 +124,108 @@ The `Flipt::Client` supports the following authentication strategies:
|
|
123
124
|
- [Client Token Authentication](https://docs.flipt.io/authentication/using-tokens)
|
124
125
|
- [JWT Authentication](https://docs.flipt.io/authentication/using-jwts)
|
125
126
|
|
127
|
+
### TLS Configuration
|
128
|
+
|
129
|
+
The `Flipt::Client` supports configuring TLS settings for secure connections to Flipt servers. This is useful when:
|
130
|
+
|
131
|
+
- Connecting to Flipt servers with self-signed certificates
|
132
|
+
- Using custom Certificate Authorities (CAs)
|
133
|
+
- Implementing mutual TLS authentication
|
134
|
+
- Testing with insecure connections (development only)
|
135
|
+
|
136
|
+
#### Basic TLS with Custom CA Certificate
|
137
|
+
|
138
|
+
```ruby
|
139
|
+
# Using a CA certificate file
|
140
|
+
tls_config = Flipt::TlsConfig.with_ca_cert_file('/path/to/ca.pem')
|
141
|
+
|
142
|
+
client = Flipt::Client.new(
|
143
|
+
url: 'https://flipt.example.com',
|
144
|
+
tls_config: tls_config
|
145
|
+
)
|
146
|
+
```
|
147
|
+
|
148
|
+
```ruby
|
149
|
+
# Using CA certificate data directly
|
150
|
+
ca_cert_data = File.read('/path/to/ca.pem')
|
151
|
+
tls_config = Flipt::TlsConfig.with_ca_cert_data(ca_cert_data)
|
152
|
+
|
153
|
+
client = Flipt::Client.new(
|
154
|
+
url: 'https://flipt.example.com',
|
155
|
+
tls_config: tls_config
|
156
|
+
)
|
157
|
+
```
|
158
|
+
|
159
|
+
#### Mutual TLS Authentication
|
160
|
+
|
161
|
+
```ruby
|
162
|
+
# Using certificate and key files
|
163
|
+
tls_config = Flipt::TlsConfig.with_mutual_tls('/path/to/client.pem', '/path/to/client.key')
|
164
|
+
|
165
|
+
client = Flipt::Client.new(
|
166
|
+
url: 'https://flipt.example.com',
|
167
|
+
tls_config: tls_config
|
168
|
+
)
|
169
|
+
```
|
170
|
+
|
171
|
+
```ruby
|
172
|
+
# Using certificate and key data directly
|
173
|
+
client_cert_data = File.read('/path/to/client.pem')
|
174
|
+
client_key_data = File.read('/path/to/client.key')
|
175
|
+
|
176
|
+
tls_config = Flipt::TlsConfig.with_mutual_tls_data(client_cert_data, client_key_data)
|
177
|
+
|
178
|
+
client = Flipt::Client.new(
|
179
|
+
url: 'https://flipt.example.com',
|
180
|
+
tls_config: tls_config
|
181
|
+
)
|
182
|
+
```
|
183
|
+
|
184
|
+
#### Advanced TLS Configuration
|
185
|
+
|
186
|
+
```ruby
|
187
|
+
# Full TLS configuration with all options
|
188
|
+
tls_config = Flipt::TlsConfig.new(
|
189
|
+
ca_cert_file: '/path/to/ca.pem',
|
190
|
+
client_cert_file: '/path/to/client.pem',
|
191
|
+
client_key_file: '/path/to/client.key',
|
192
|
+
insecure_skip_verify: false
|
193
|
+
)
|
194
|
+
|
195
|
+
client = Flipt::Client.new(
|
196
|
+
url: 'https://flipt.example.com',
|
197
|
+
tls_config: tls_config
|
198
|
+
)
|
199
|
+
```
|
200
|
+
|
201
|
+
#### Development Mode (Insecure)
|
202
|
+
|
203
|
+
**⚠️ WARNING: Only use this in development environments!**
|
204
|
+
|
205
|
+
```ruby
|
206
|
+
# Skip certificate verification (NOT for production)
|
207
|
+
tls_config = Flipt::TlsConfig.insecure
|
208
|
+
|
209
|
+
client = Flipt::Client.new(
|
210
|
+
url: 'https://localhost:8443',
|
211
|
+
tls_config: tls_config
|
212
|
+
)
|
213
|
+
```
|
214
|
+
|
215
|
+
#### TLS Configuration Options
|
216
|
+
|
217
|
+
The `TlsConfig` class supports the following options:
|
218
|
+
|
219
|
+
- `ca_cert_file`: Path to custom CA certificate file (PEM format)
|
220
|
+
- `ca_cert_data`: Raw CA certificate content (PEM format) - takes precedence over `ca_cert_file`
|
221
|
+
- `insecure_skip_verify`: Skip certificate verification (development only)
|
222
|
+
- `client_cert_file`: Client certificate file for mutual TLS (PEM format)
|
223
|
+
- `client_key_file`: Client private key file for mutual TLS (PEM format)
|
224
|
+
- `client_cert_data`: Raw client certificate content (PEM format) - takes precedence over `client_cert_file`
|
225
|
+
- `client_key_data`: Raw client private key content (PEM format) - takes precedence over `client_key_file`
|
226
|
+
|
227
|
+
> **Note**: When both file paths and data are provided, the data fields take precedence. For example, if both `ca_cert_file` and `ca_cert_data` are set, `ca_cert_data` will be used.
|
228
|
+
|
126
229
|
### Error Strategies
|
127
230
|
|
128
231
|
The client supports the following error strategies:
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/lib/flipt_client/models.rb
CHANGED
@@ -41,6 +41,107 @@ module Flipt
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
+
# TlsConfig provides configuration for TLS connections to Flipt servers
|
45
|
+
class TlsConfig
|
46
|
+
attr_reader :ca_cert_file, :ca_cert_data, :insecure_skip_verify,
|
47
|
+
:client_cert_file, :client_key_file, :client_cert_data, :client_key_data
|
48
|
+
|
49
|
+
# Initialize TLS configuration
|
50
|
+
#
|
51
|
+
# @param ca_cert_file [String, nil] Path to CA certificate file (PEM format)
|
52
|
+
# @param ca_cert_data [String, nil] Raw CA certificate content (PEM format)
|
53
|
+
# @param insecure_skip_verify [Boolean, nil] Skip certificate verification (development only)
|
54
|
+
# @param client_cert_file [String, nil] Path to client certificate file (PEM format)
|
55
|
+
# @param client_key_file [String, nil] Path to client key file (PEM format)
|
56
|
+
# @param client_cert_data [String, nil] Raw client certificate content (PEM format)
|
57
|
+
# @param client_key_data [String, nil] Raw client key content (PEM format)
|
58
|
+
def initialize(ca_cert_file: nil, ca_cert_data: nil, insecure_skip_verify: nil,
|
59
|
+
client_cert_file: nil, client_key_file: nil,
|
60
|
+
client_cert_data: nil, client_key_data: nil)
|
61
|
+
@ca_cert_file = ca_cert_file
|
62
|
+
@ca_cert_data = ca_cert_data
|
63
|
+
@insecure_skip_verify = insecure_skip_verify
|
64
|
+
@client_cert_file = client_cert_file
|
65
|
+
@client_key_file = client_key_file
|
66
|
+
@client_cert_data = client_cert_data
|
67
|
+
@client_key_data = client_key_data
|
68
|
+
|
69
|
+
validate_files!
|
70
|
+
end
|
71
|
+
|
72
|
+
# Create TLS config for insecure connections (development only)
|
73
|
+
# WARNING: Only use this in development environments
|
74
|
+
#
|
75
|
+
# @return [TlsConfig] TLS config with certificate verification disabled
|
76
|
+
def self.insecure
|
77
|
+
new(insecure_skip_verify: true)
|
78
|
+
end
|
79
|
+
|
80
|
+
# Create TLS config with CA certificate file
|
81
|
+
#
|
82
|
+
# @param ca_cert_file [String] Path to CA certificate file
|
83
|
+
# @return [TlsConfig] TLS config with custom CA certificate
|
84
|
+
def self.with_ca_cert_file(ca_cert_file)
|
85
|
+
new(ca_cert_file: ca_cert_file)
|
86
|
+
end
|
87
|
+
|
88
|
+
# Create TLS config with CA certificate data
|
89
|
+
#
|
90
|
+
# @param ca_cert_data [String] CA certificate content in PEM format
|
91
|
+
# @return [TlsConfig] TLS config with custom CA certificate
|
92
|
+
def self.with_ca_cert_data(ca_cert_data)
|
93
|
+
new(ca_cert_data: ca_cert_data)
|
94
|
+
end
|
95
|
+
|
96
|
+
# Create TLS config for mutual TLS with certificate files
|
97
|
+
#
|
98
|
+
# @param client_cert_file [String] Path to client certificate file
|
99
|
+
# @param client_key_file [String] Path to client key file
|
100
|
+
# @return [TlsConfig] TLS config with mutual TLS
|
101
|
+
def self.with_mutual_tls(client_cert_file, client_key_file)
|
102
|
+
new(client_cert_file: client_cert_file, client_key_file: client_key_file)
|
103
|
+
end
|
104
|
+
|
105
|
+
# Create TLS config for mutual TLS with certificate data
|
106
|
+
#
|
107
|
+
# @param client_cert_data [String] Client certificate content in PEM format
|
108
|
+
# @param client_key_data [String] Client key content in PEM format
|
109
|
+
# @return [TlsConfig] TLS config with mutual TLS
|
110
|
+
def self.with_mutual_tls_data(client_cert_data, client_key_data)
|
111
|
+
new(client_cert_data: client_cert_data, client_key_data: client_key_data)
|
112
|
+
end
|
113
|
+
|
114
|
+
# Convert to hash for JSON serialization
|
115
|
+
# @return [Hash] TLS configuration as hash
|
116
|
+
def to_h
|
117
|
+
hash = {}
|
118
|
+
hash[:ca_cert_file] = @ca_cert_file if @ca_cert_file
|
119
|
+
hash[:ca_cert_data] = @ca_cert_data if @ca_cert_data
|
120
|
+
hash[:insecure_skip_verify] = @insecure_skip_verify unless @insecure_skip_verify.nil?
|
121
|
+
hash[:client_cert_file] = @client_cert_file if @client_cert_file
|
122
|
+
hash[:client_key_file] = @client_key_file if @client_key_file
|
123
|
+
hash[:client_cert_data] = @client_cert_data if @client_cert_data
|
124
|
+
hash[:client_key_data] = @client_key_data if @client_key_data
|
125
|
+
hash
|
126
|
+
end
|
127
|
+
|
128
|
+
private
|
129
|
+
|
130
|
+
def validate_files!
|
131
|
+
validate_file_exists(@ca_cert_file, 'CA certificate file') if @ca_cert_file
|
132
|
+
validate_file_exists(@client_cert_file, 'Client certificate file') if @client_cert_file
|
133
|
+
validate_file_exists(@client_key_file, 'Client key file') if @client_key_file
|
134
|
+
end
|
135
|
+
|
136
|
+
def validate_file_exists(file_path, description)
|
137
|
+
return if file_path.nil? || file_path.strip.empty?
|
138
|
+
|
139
|
+
return if File.exist?(file_path)
|
140
|
+
|
141
|
+
raise ValidationError, "#{description} does not exist: #{file_path}"
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
44
145
|
# VariantEvaluationResponse
|
45
146
|
# @attr_reader [String] flag_key
|
46
147
|
# @attr_reader [Boolean] match
|
data/lib/flipt_client/version.rb
CHANGED
data/lib/flipt_client.rb
CHANGED
@@ -65,12 +65,14 @@ module Flipt
|
|
65
65
|
# Note: Streaming is currently only supported when using the SDK with Flipt Cloud or Flipt v2.
|
66
66
|
# @option opts [Symbol] :error_strategy error strategy to use for the client (:fail or :fallback).
|
67
67
|
# @option opts [String] :snapshot snapshot to use when initializing the client
|
68
|
+
# @option opts [TlsConfig] :tls_config TLS configuration for connecting to servers with custom certificates
|
68
69
|
def initialize(**opts)
|
69
70
|
@namespace = opts.fetch(:namespace, 'default')
|
70
71
|
|
71
72
|
opts[:authentication] = validate_authentication(opts.fetch(:authentication, NoAuthentication.new))
|
72
73
|
opts[:fetch_mode] = validate_fetch_mode(opts.fetch(:fetch_mode, :polling))
|
73
74
|
opts[:error_strategy] = validate_error_strategy(opts.fetch(:error_strategy, :fail))
|
75
|
+
opts[:tls_config] = validate_tls_config(opts.fetch(:tls_config, nil))
|
74
76
|
|
75
77
|
@engine = self.class.initialize_engine(opts.to_json)
|
76
78
|
ObjectSpace.define_finalizer(self, self.class.finalize(@engine))
|
@@ -223,6 +225,13 @@ module Flipt
|
|
223
225
|
|
224
226
|
raise ValidationError, 'invalid error strategy'
|
225
227
|
end
|
228
|
+
|
229
|
+
def validate_tls_config(tls_config)
|
230
|
+
return nil if tls_config.nil?
|
231
|
+
return tls_config.to_h if tls_config.is_a?(TlsConfig)
|
232
|
+
|
233
|
+
raise ValidationError, 'invalid tls_config: must be TlsConfig instance'
|
234
|
+
end
|
226
235
|
end
|
227
236
|
|
228
237
|
# Deprecation shim for EvaluationClient
|
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: 1.
|
4
|
+
version: 1.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: 2025-06-
|
11
|
+
date: 2025-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Flipt Client Evaluation SDK
|
14
14
|
email:
|