libriciel 0.1.2 → 0.1.3
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/lib/libriciel/version.rb +1 -1
- data/lib/libriciel.rb +34 -6
- 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: 25d59cf10cefb65f3ff969ac6d14543f9360a3e4226d8bfdb5f77648ef9b4033
|
4
|
+
data.tar.gz: 9f6029ed8be0b7985ebfecd34f5187327192c0c4f809865333ae426218fec878
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cc25a0c0dacd66878e8923474db829c59cc84838d5efe02b6f496c6f9f7036734a64c52b607972a7f8fd23a0da2067f3c8e08ece8292f7b053ea92779b3d643
|
7
|
+
data.tar.gz: 425e7231941de2786b4cc5c8bb7951654af5b94bc9a092b9115751cf008ac38282180d294596da9a103918561e8f52224d98c0884b5a3059a1b63dd809fadf0b
|
data/lib/libriciel/version.rb
CHANGED
data/lib/libriciel.rb
CHANGED
@@ -9,10 +9,31 @@ module Libriciel
|
|
9
9
|
|
10
10
|
# Class ApiXivo to use Xivo Api
|
11
11
|
class ApiXivo
|
12
|
-
# Génération du token permettant l'authent ADMIN (ATTENTION) pour l'api Xivo
|
13
|
-
def self.token_generate(user, pass)
|
14
12
|
|
15
|
-
|
13
|
+
def self.token_validation(token)
|
14
|
+
url = URI("https://xivo.libriciel.fr:9497/0.1/token/#{token}")
|
15
|
+
|
16
|
+
http = Net::HTTP.new(url.host, url.port)
|
17
|
+
http.use_ssl = true
|
18
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
19
|
+
|
20
|
+
request = Net::HTTP::Head.new(url)
|
21
|
+
request["content-type"] = 'application/json'
|
22
|
+
request["cache-control"] = 'no-cache'
|
23
|
+
|
24
|
+
response = http.request(request)
|
25
|
+
|
26
|
+
if response.message == "NO CONTENT"
|
27
|
+
return true
|
28
|
+
|
29
|
+
else
|
30
|
+
return false
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Génération du token permettant l'authent ADMIN (ATTENTION) pour l'api Xivo
|
36
|
+
def self.token_generate(base64_enc)
|
16
37
|
url = URI("https://xivo.libriciel.fr:9497/0.1/token")
|
17
38
|
|
18
39
|
http = Net::HTTP.new(url.host, url.port)
|
@@ -21,13 +42,20 @@ module Libriciel
|
|
21
42
|
|
22
43
|
request = Net::HTTP::Post.new(url)
|
23
44
|
request["content-type"] = 'application/json'
|
24
|
-
request["authorization"] = "Basic #{
|
45
|
+
request["authorization"] = "Basic #{base64_enc}"
|
25
46
|
request["cache-control"] = 'no-cache'
|
26
47
|
|
27
|
-
request.body = "{\n \"backend\": \"xivo_admin\",\n \"expiration\":
|
48
|
+
request.body = "{\n \"backend\": \"xivo_admin\",\n \"expiration\": 100\n}"
|
28
49
|
|
29
50
|
response = http.request(request)
|
30
|
-
|
51
|
+
reponse_parsing = JSON.parse(response.read_body)
|
52
|
+
|
53
|
+
if !reponse_parsing.include?("data")
|
54
|
+
puts reponse_parsing["reason"]
|
55
|
+
exit 223
|
56
|
+
else
|
57
|
+
token = reponse_parsing['data']['token']
|
58
|
+
end
|
31
59
|
|
32
60
|
return token
|
33
61
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libriciel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Axel CHEVRIER
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|