-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathauthentication.rb
More file actions
50 lines (39 loc) · 1.57 KB
/
Copy pathauthentication.rb
File metadata and controls
50 lines (39 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
require 'vaas/client_credentials_grant_authenticator'
require 'vaas/resource_owner_password_grant_authenticator'
require 'vaas/vaas_main'
require 'async'
def main
client_id = ENV.fetch("VAAS_CLIENT_ID")
client_secret = ENV.fetch("CLIENT_SECRET")
user_name = ENV.fetch("VAAS_USER_NAME")
password = ENV.fetch("VAAS_PASSWORD")
token_url = ENV.fetch("TOKEN_URL") || "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token"
vaas_url = ENV.fetch("VAAS_URL") || "wss://gateway.production.vaas.gdatasecurity.de"
test_url = "https://gdata.de"
#If you got a username and password from us, you can use the ResourceOwnerPasswordAuthenticator like this
authenticator = VAAS::ResourceOwnerPasswordGrantAuthenticator.new(
client_id,
user_name,
password,
token_url
)
# You may use self registration and create a new username and password for the
# ResourceOwnerPasswordAuthenticator by yourself like the example above on https:#vaas.gdata.de/login
# Else if you got a client id and client secret from us, you can use the ClientCredentialsGrantAuthenticator like this
# authenticator = VAAS::ClientCredentialsGrantAuthenticator.new(
# client_id,
# client_secret,
# token_url
# )
vaas = VAAS::VaasMain.new(vaas_url)
token = authenticator.get_token
Async do
vaas.connect(token)
verdict = vaas.for_url(test_url)
puts "Verdict #{verdict.wait.sha256} is detected as #{verdict.wait.verdict}"
vaas.close
end
end
if __FILE__ == $0
main
end