vaas 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: 86c4b8c8ed151fe77da284d60d07156dbc84b40346fcad1ef64162ef7a15cb14
4
- data.tar.gz: 1fdce2973ded2543f3ff4e808d8263371c7add9ea7b5bee6f62d146125ad7763
3
+ metadata.gz: e23bd7f42275d3abaadea284ae353797be04d87481168e2c405d60e91b5f3651
4
+ data.tar.gz: 256a204cc03536ab392903e4301d05b8acc26599510ebf7982ce317ef6918cbb
5
5
  SHA512:
6
- metadata.gz: bf6267e4f1c176b9c4dc3b760d8ec54fa475a73fef613d8c8220954cdadbc73f23a78baa529b338dd1a711051b8462471961443ea4c9ab94a69a8f2b3eb8a447
7
- data.tar.gz: 8fe1af11c62026f93bf03e30353b826f0f0d9c99d481b3f8494e5da59e155b2a599dc362f78c3fc8df6009d15566754adc55fdd86f80b377ac924472535a2e1d
6
+ metadata.gz: d2101b2769f8016e5881e7e4fbdd364da661a9a0d39322d359e95af2288f227d21a2302a46a2339f063c44e8714165754f18bb75d25b454988481454a9a512f9
7
+ data.tar.gz: 153593621130ced28b394d6033e842192b112ba0169d37ffba1596473c231543689f466ed0cba3c50217f4ec9382d10996decd9a18d2c3d9ee968e9bb6bb6b78
@@ -0,0 +1,50 @@
1
+ require 'vaas/client_credentials_grant_authenticator'
2
+ require 'vaas/resource_owner_password_grant_authenticator'
3
+ require 'vaas/vaas_main'
4
+ require 'async'
5
+
6
+
7
+ def main
8
+ client_id = "vaas-customer"
9
+ client_secret = ENV.fetch("CLIENT_SECRET")
10
+ user_name = ENV.fetch("VAAS_USER_NAME")
11
+ password = ENV.fetch("VAAS_PASSWORD")
12
+ token_url = ENV.fetch("TOKEN_URL") || "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token"
13
+ vaas_url = ENV.fetch("VAAS_URL") || "wss://gateway.production.vaas.gdatasecurity.de"
14
+ test_url = "https://gdata.de"
15
+
16
+ #If you got a username and password from us, you can use the ResourceOwnerPasswordAuthenticator like this
17
+ authenticator = VAAS::ResourceOwnerPasswordGrantAuthenticator.new(
18
+ client_id,
19
+ user_name,
20
+ password,
21
+ token_url
22
+ )
23
+ # You may use self registration and create a new username and password for the
24
+ # ResourceOwnerPasswordAuthenticator by yourself like the example above on https:#vaas.gdata.de/login
25
+
26
+ # Else if you got a client id and client secret from us, you can use the ClientCredentialsGrantAuthenticator like this
27
+ # authenticator = VAAS::ClientCredentialsGrantAuthenticator.new(
28
+ # client_id,
29
+ # client_secret,
30
+ # token_url
31
+ # )
32
+
33
+
34
+ vaas = VAAS::VaasMain.new(vaas_url)
35
+ token = authenticator.get_token
36
+
37
+ Async do
38
+ vaas.connect(token)
39
+
40
+ verdict = vaas.for_url(test_url)
41
+ puts "Verdict #{verdict.wait.sha256} is detected as #{verdict.wait.verdict}"
42
+
43
+ vaas.close
44
+ end
45
+ end
46
+
47
+
48
+ if __FILE__ == $0
49
+ main
50
+ end
@@ -4,17 +4,20 @@ require 'vaas/vaas_main'
4
4
 
5
5
  CLIENT_ID = ENV.fetch('CLIENT_ID')
6
6
  CLIENT_SECRET = ENV.fetch('CLIENT_SECRET')
7
+ VAAS_URL = ENV.fetch('VAAS_URL', "wss://gateway.production.vaas.gdatasecurity.de")
8
+ TOKEN_URL = ENV.fetch('TOKEN_URL', 'https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token')
9
+
7
10
  URL = ENV.fetch('URL')
8
11
 
9
12
  def main
10
13
  authenticator = VAAS::ClientCredentialsGrantAuthenticator.new(
11
14
  CLIENT_ID,
12
15
  CLIENT_SECRET,
13
- "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token"
16
+ TOKEN_URL
14
17
  )
15
18
 
16
19
  # create a vaas object and get a token to authenticate
17
- vaas = VAAS::VaasMain.new
20
+ vaas = VAAS::VaasMain.new(VAAS_URL)
18
21
  token = authenticator.get_token
19
22
 
20
23
  Async do
@@ -4,17 +4,20 @@ require 'vaas/vaas_main'
4
4
 
5
5
  CLIENT_ID = ENV.fetch('CLIENT_ID')
6
6
  CLIENT_SECRET = ENV.fetch('CLIENT_SECRET')
7
+ VAAS_URL = ENV.fetch('VAAS_URL', "wss://gateway.production.vaas.gdatasecurity.de")
8
+ TOKEN_URL = ENV.fetch('TOKEN_URL', 'https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token')
9
+
7
10
  URL = ENV.fetch('URL')
8
11
 
9
12
  def main
10
13
  authenticator = VAAS::ClientCredentialsGrantAuthenticator.new(
11
14
  CLIENT_ID,
12
15
  CLIENT_SECRET,
13
- "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token"
16
+ TOKEN_URL
14
17
  )
15
18
 
16
19
  # create a vaas object and get a token to authenticate
17
- vaas = VAAS::VaasMain.new
20
+ vaas = VAAS::VaasMain.new(VAAS_URL)
18
21
  token = authenticator.get_token
19
22
 
20
23
  Async do
@@ -7,7 +7,7 @@ module VAAS
7
7
 
8
8
  attr_accessor :client_id, :client_secret, :token_endpoint, :token
9
9
 
10
- def initialize(client_id, client_secret, token_endpoint)
10
+ def initialize(client_id, client_secret, token_endpoint = 'https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token')
11
11
  @client_id = client_id
12
12
  @client_secret = client_secret
13
13
  @token_endpoint = token_endpoint
@@ -27,6 +27,8 @@ module VAAS
27
27
  ensure
28
28
  client&.close
29
29
  end
30
+
31
+ raise VaasAuthenticationError if token.nil?
30
32
  token
31
33
  end
32
34
  end
@@ -0,0 +1,36 @@
1
+ require 'json'
2
+ require 'async'
3
+ require 'async/http/internet'
4
+
5
+ module VAAS
6
+ class ResourceOwnerPasswordGrantAuthenticator
7
+
8
+ attr_accessor :client_id, :token_endpoint, :token, :username, :password
9
+
10
+ def initialize(client_id, username, password, token_endpoint = 'https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token')
11
+ @client_id = client_id
12
+ @username = username
13
+ @password = password
14
+ @token_endpoint = token_endpoint
15
+ end
16
+
17
+ def get_token
18
+ Async do
19
+ client = Async::HTTP::Internet.new
20
+
21
+ header = [['content-type', 'application/x-www-form-urlencoded']]
22
+ body = ["grant_type=password&client_id=#{client_id}&username=#{username}&password=#{password}"]
23
+
24
+ response = client.post(token_endpoint, header, body)
25
+ self.token = JSON.parse(response.read)['access_token']
26
+ rescue => e
27
+ raise VaasAuthenticationError, e
28
+ ensure
29
+ client&.close
30
+ end
31
+
32
+ raise VaasAuthenticationError if token.nil?
33
+ token
34
+ end
35
+ end
36
+ end
data/lib/vaas/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module VAAS
2
- VERSION = '3.0.0'
2
+ VERSION = '3.1.0'
3
3
  end
data/vaas.gemspec CHANGED
@@ -13,6 +13,7 @@ Gem::Specification.new do |s|
13
13
  s.license = "MIT"
14
14
  s.require_paths = ["lib"]
15
15
  s.metadata = { "documentation_uri" => "https://github.com/GDATASoftwareAG/vaas/blob/main/ruby/README.md" }
16
+ s.required_ruby_version = '>= 3.1.1'
16
17
 
17
18
  s.add_dependency 'async', '~> 2.3.1'
18
19
  s.add_dependency 'async-http', '~> 0.59.4'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vaas
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
  - Allie Weitenkamp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-09 00:00:00.000000000 Z
11
+ date: 2023-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async
@@ -91,10 +91,12 @@ files:
91
91
  - ".vscode/launch.json"
92
92
  - Gemfile
93
93
  - README.md
94
+ - examples/authentication.rb
94
95
  - examples/example_with_reconnect.rb
95
96
  - examples/simple_example.rb
96
97
  - lib/vaas.rb
97
98
  - lib/vaas/client_credentials_grant_authenticator.rb
99
+ - lib/vaas/resource_owner_password_grant_authenticator.rb
98
100
  - lib/vaas/vaas_errors.rb
99
101
  - lib/vaas/vaas_main.rb
100
102
  - lib/vaas/vaas_verdict.rb
@@ -113,7 +115,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
113
115
  requirements:
114
116
  - - ">="
115
117
  - !ruby/object:Gem::Version
116
- version: '0'
118
+ version: 3.1.1
117
119
  required_rubygems_version: !ruby/object:Gem::Requirement
118
120
  requirements:
119
121
  - - ">="