andrewfun 0.0.6 → 0.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/andrewfun.rb +34 -1
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ffa1cbf3e32801797776cb6b62469ff95a2fede1da6491c55e63517ef40f5f4e
4
- data.tar.gz: '0292b37b31087fba650e967b60a947b1d99be933767f4eb53df947bb55da180a'
3
+ metadata.gz: a66364fa6ea8fa0e38f3f9b63642e125eb6bfcd9b6525384dafc975d01834d06
4
+ data.tar.gz: 18c817c7cd0c7ba359bf6c8ac74e7458c3976ddb73d2bbdc55dde50ca21d25f2
5
5
  SHA512:
6
- metadata.gz: d43aa135c87618e20d7ff68e48e0362c8ae22b81286b1eea7b5a96d0543cf9e26779973e368fc11eaafedee18052f214dd75e317eeed9244f748d5118cfbf875
7
- data.tar.gz: 4d98dda546e0a25771fe2acc4d1ef0de5b6c6f37fa76c182daf8cdcedadbd935c2e8c584d8ce66e002a9c08d743dd24d493d6fbfe7daa0bfcb699cfba4d1f96f
6
+ metadata.gz: 4e74cfa47501a38fbd7de20de662c62e597dd50e7d06a45eb662870ef71dda3166c91112449f46aeb39fd22d9d76a0887445544f6ddf9919a2d6c2e10440bf5f
7
+ data.tar.gz: bea473da9d2a62ce2fc465b25abb6411b090891e9267371c0cd5bd46e7c4cd993b7e84946dfd91f5d4cc12af954cb55f1445aa9ef7399713a333a4ba83bae953
data/lib/andrewfun.rb CHANGED
@@ -6,6 +6,9 @@ class Andrewfun
6
6
  response = HTTParty.get(url)
7
7
  authorizationResponse = JSON.parse(response.body)
8
8
  puts authorizationResponse["authorized"]
9
+ otp = request.headers["HTTP_OTP"]
10
+ humantoken = request.headers["HTTP_HUMANTOKEN"]
11
+ devicetoken = request.headers["HTTP_DEVICE_TOKEN"]
9
12
  ip = request.remote_ip
10
13
  if ip == "::1" || ip == "127.0.0.1"
11
14
  puts "here"
@@ -15,9 +18,39 @@ class Andrewfun
15
18
  parsedIpData = JSON.parse(realIpData.body)
16
19
  ip = parsedIpData["ip"]
17
20
  end
18
- token = request.headers["HTTP_TOKEN"]
21
+ possibletoken = request.headers["HTTP_TOKEN"].split("Bearer ")
22
+ token = request.headers["HTTP_TOKEN"] || possibletoken
23
+ headers = {
24
+ "method" => request.method,
25
+ "ip" => ip,
26
+ "token" => token,
27
+ "api" => request.original_url
28
+ }
29
+
30
+ if devicetoken != nil
31
+ headers["device_token"] = devicetoken
32
+ end
33
+
34
+ if otp != nil
35
+ headers["otp"] = otp
36
+ end
37
+
38
+ if humantoken != nil
39
+ headers["humantoken"] = humantoken
40
+ end
41
+
42
+
19
43
  puts token
44
+ puts devicetoken
45
+ puts humantoken
46
+ puts otp
20
47
  puts ip
48
+ puts headers
49
+ authorizedMessage = HTTParty.get(url, :headers => headers)
50
+ authorizationResult = JSON.parse(authorizedMessage.body)
51
+ if authorizationResult["authorized"] != true
52
+ render json: authorizationResult, status: 401
53
+ end
21
54
  end
22
55
 
23
56
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: andrewfun
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - andrew van beek