pdnd-ruby-client 0.1.3 → 0.1.5
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/.rubocop.yml +6 -0
- data/CHANGELOG.md +8 -0
- data/README.md +25 -0
- data/lib/pdnd-ruby-client/jwt_generator.rb +15 -2
- data/lib/pdnd-ruby-client/token_manager.rb +2 -1
- data/lib/pdnd-ruby-client/version.rb +1 -1
- metadata +1 -2
- data/tmp/pdnd_token.json +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 660cc1080b8f2bc1c4ac275f087c21231b67f4cdb90b2b9e9ac990ddb4bb07e3
|
4
|
+
data.tar.gz: 3563e84b27cf58a55b9f69f627e95ab3385bbf276195c93a7c27669f81a8a63c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef0baca7c1b0f3cbd059d625bbd184069187fd972254c88d457c31796117faac292473b66c13c04a138560a7bdaf90da8d9083d5b0f6515a2b79609b59a2a598
|
7
|
+
data.tar.gz: 79f8d4179d2c22d1b29666571cc7f2c2fe2b07b28319d05d003de4a2a7d3458ef69dabf525fc75937d42873d7f87a44bf8c78fb9bc6fc1e6e126797e0ebd7a0e
|
data/.rubocop.yml
CHANGED
@@ -125,6 +125,10 @@ Metrics/CollectionLiteralLength: # new in 1.47
|
|
125
125
|
Enabled: true
|
126
126
|
Metrics/AbcSize:
|
127
127
|
Enabled: false
|
128
|
+
Metrics/ClassLength:
|
129
|
+
Enabled: false
|
130
|
+
Metrics/MethodLength:
|
131
|
+
Enabled: false
|
128
132
|
Naming/FileName:
|
129
133
|
Enabled: false
|
130
134
|
Naming/BlockForwarding: # new in 1.24
|
@@ -281,6 +285,8 @@ Style/SingleLineDoEndBlock: # new in 1.57
|
|
281
285
|
Enabled: true
|
282
286
|
Style/StringChars: # new in 1.12
|
283
287
|
Enabled: true
|
288
|
+
Style/StringLiterals:
|
289
|
+
Enabled: false
|
284
290
|
Style/SuperArguments: # new in 1.64
|
285
291
|
Enabled: true
|
286
292
|
Style/SuperWithArgsParentheses: # new in 1.58
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v0.1.5](https://github.com/isprambiente/pdnd-ruby-client/tree/v0.1.5) (2025-08-14)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/isprambiente/pdnd-ruby-client/compare/v0.1.4...v0.1.5)
|
6
|
+
|
7
|
+
## [v0.1.4](https://github.com/isprambiente/pdnd-ruby-client/tree/v0.1.4) (2025-08-05)
|
8
|
+
|
9
|
+
[Full Changelog](https://github.com/isprambiente/pdnd-ruby-client/compare/v0.1.3...v0.1.4)
|
10
|
+
|
3
11
|
## [v0.1.3](https://github.com/isprambiente/pdnd-ruby-client/tree/v0.1.3) (2025-07-28)
|
4
12
|
|
5
13
|
[Full Changelog](https://github.com/isprambiente/pdnd-ruby-client/compare/v0.1.2...v0.1.3)
|
data/README.md
CHANGED
@@ -58,6 +58,31 @@ puts body
|
|
58
58
|
|
59
59
|
```
|
60
60
|
|
61
|
+
## Passa la chiave privata manualmente (disponibile dalla v.0.1.4)
|
62
|
+
```ruby
|
63
|
+
require "pdnd-ruby-client"
|
64
|
+
|
65
|
+
# Inizializza la configurazione
|
66
|
+
# Load the configuration from the specified JSON file and environment key.
|
67
|
+
config = PDND::ConfigLoader.load("configs/sample.json")
|
68
|
+
jwt = PDND::JWTGenerator.new(config)
|
69
|
+
# Inserisci tutta la chiave privata.
|
70
|
+
# La chiave privata passata manualmente ha la priorità
|
71
|
+
# rispetto a quella inserita nel config file json.
|
72
|
+
jwt.priv_key = "-----BEGIN PRIVATE KEY-----"
|
73
|
+
token, exp = jwt.generate_token
|
74
|
+
client = PDND::Client.new(config)
|
75
|
+
client.token = token
|
76
|
+
client.token_exp = exp
|
77
|
+
client.api_url="https://www.tuogateway.example.it/indirizzo/della/api"
|
78
|
+
client.filters="id=1234"
|
79
|
+
code, body = client.request_api
|
80
|
+
|
81
|
+
# Stampa il risultato
|
82
|
+
puts body
|
83
|
+
|
84
|
+
```
|
85
|
+
|
61
86
|
## Leggi e Salva il token
|
62
87
|
|
63
88
|
```ruby
|
@@ -26,7 +26,7 @@ module PDND
|
|
26
26
|
# generator = PDND::JWTGenerator.new(config)
|
27
27
|
# token, exp = generator.generate_token
|
28
28
|
class JWTGenerator
|
29
|
-
attr_accessor :env, :config, :debug, :issuer, :client_id, :priv_key_path,
|
29
|
+
attr_accessor :env, :config, :debug, :issuer, :client_id, :priv_key, :priv_key_path,
|
30
30
|
:purpose_id, :kid, :endpoint, :audience, :assertion,
|
31
31
|
:token, :token_exp
|
32
32
|
|
@@ -65,6 +65,7 @@ module PDND
|
|
65
65
|
def assign_config_values(config)
|
66
66
|
@issuer = config[:issuer]
|
67
67
|
@client_id = config[:clientId]
|
68
|
+
@priv_key = config[:privKey]
|
68
69
|
@priv_key_path = config[:privKeyPath]
|
69
70
|
@kid = config[:kid]
|
70
71
|
@purpose_id = config[:purposeId]
|
@@ -84,7 +85,19 @@ module PDND
|
|
84
85
|
# @return [OpenSSL::PKey::RSA] Chiave privata RSA
|
85
86
|
# @raise [PDND::ConfigError] Se la chiave è invalida o il file non esiste
|
86
87
|
def load_private_key
|
87
|
-
|
88
|
+
key = nil
|
89
|
+
|
90
|
+
if @priv_key.to_s.strip != ""
|
91
|
+
key = @priv_key
|
92
|
+
debug_log('✅ Priv Key acquisita manualmente', '**********')
|
93
|
+
elsif @priv_key_path.to_s.strip != ""
|
94
|
+
key = File.read(@priv_key_path)
|
95
|
+
debug_log('✅ Priv Key acquisita da file', '**********')
|
96
|
+
else
|
97
|
+
raise PDND::ConfigError, "❌ Nessuna chiave privata o percorso fornito"
|
98
|
+
end
|
99
|
+
|
100
|
+
OpenSSL::PKey::RSA.new(key)
|
88
101
|
rescue OpenSSL::PKey::RSAError => e
|
89
102
|
raise PDND::ConfigError, "❌ Chiave privata non valida: #{e.message}"
|
90
103
|
rescue Errno::ENOENT => e
|
@@ -20,6 +20,7 @@ module PDND
|
|
20
20
|
data = JSON.parse(File.read(@path))
|
21
21
|
@token = data['token']
|
22
22
|
@exp = data['exp']
|
23
|
+
[@token, @exp]
|
23
24
|
end
|
24
25
|
|
25
26
|
def save(token, exp)
|
@@ -29,7 +30,7 @@ module PDND
|
|
29
30
|
end
|
30
31
|
|
31
32
|
def valid?
|
32
|
-
@token && @exp && Time.now.to_i < @exp.to_i
|
33
|
+
@token.present? && @exp.present? && (Time.now.to_i < Time.new(@exp).to_i)
|
33
34
|
end
|
34
35
|
end
|
35
36
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pdnd-ruby-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francesco Loreti
|
@@ -110,7 +110,6 @@ files:
|
|
110
110
|
- lib/pdnd-ruby-client/version.rb
|
111
111
|
- sig/pdnd-ruby-client.rbs
|
112
112
|
- tmp/.gitkeep
|
113
|
-
- tmp/pdnd_token.json
|
114
113
|
homepage: https://github.com/isprambiente/pdnd-ruby-client
|
115
114
|
licenses:
|
116
115
|
- MIT
|
data/tmp/pdnd_token.json
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"token":"eyJhbGciOiJSUzI1NiIsInVzZSI6InNpZyIsInR5cCI6ImF0K2p3dCIsImtpZCI6Ijk0MzJjMTZiLTdhYWUtNDlkZi1iOWM0LWVhNjFiNTU2NjUyYiJ9.eyJqdGkiOiJlM2RjNDg2MS00NDkwLTRmMmItODQ3OC1mOThkMTM1YWRkNjUiLCJpc3MiOiJpbnRlcm9wLnBhZ29w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