grape_simple_auth 0.1.2 → 0.2.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: aa27a75038f3c3f703c22b7a3e2e28693b3d84d55eb10de0b98f8d950d13c7b0
4
- data.tar.gz: 56d458627aebd0603c17d318c645aa2123a2d745eecd68030f412b8e5ec660ae
3
+ metadata.gz: f47da796f0828ec0357808048ef324c1a84ffc6f57a19443e2e6f475a433592f
4
+ data.tar.gz: a8b89fe30828854bbcbc7b69c2b0521f1f7049ae5e0e4e1cc5db56863f3b53df
5
5
  SHA512:
6
- metadata.gz: d45a62cd7c1da9c1798f2e2c048acb646f17c4b518152dbe202757802ee7dbbbaa1746769b05db8b59b915bf818cb32bb5675c490ef2eb49fcde86de48b0ebcd
7
- data.tar.gz: 4976109572f04fbac0ef46d666d09c74b9ea38e4fb4a064ca75315e078b5213e3eeddeb52c8fd7d49603a4d9a87126f813aaa5f4ba1165889b4beda9a33b9eee
6
+ metadata.gz: dbbe3ada101559255920abd3fb2407fd815ed24845ac38691847db99488a65ac9322f00308ac49bc950832c71d74ead749e5626f6d32aac8e6c26ffbab56f251
7
+ data.tar.gz: b42b148b85ca250b0dacda4e78800743fb98d52b1a71114eb70dadd7f48c59f118c20d79403f50ab02a2d58775c15a4d853d83cd6417f83d71b9b4adb69142d0
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- grape_simple_auth (0.1.1)
5
- grape (~> 0)
6
- httparty (~> 0)
4
+ grape_simple_auth (0.1.2)
5
+ grape (~> 1.1.0)
6
+ httparty (~> 0.16.3)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
@@ -25,17 +25,13 @@ GEM
25
25
  thread_safe (~> 0.3, >= 0.3.1)
26
26
  diff-lcs (1.3)
27
27
  equalizer (0.0.11)
28
- grape (0.19.2)
28
+ grape (1.1.0)
29
29
  activesupport
30
30
  builder
31
- hashie (>= 2.1.0)
32
- multi_json (>= 1.3.2)
33
- multi_xml (>= 0.5.2)
34
31
  mustermann-grape (~> 1.0.0)
35
32
  rack (>= 1.3.0)
36
33
  rack-accept
37
34
  virtus (>= 1.0.0)
38
- hashie (3.6.0)
39
35
  httparty (0.16.3)
40
36
  mime-types (~> 3.0)
41
37
  multi_xml (>= 0.5.2)
@@ -46,7 +42,6 @@ GEM
46
42
  mime-types-data (~> 3.2015)
47
43
  mime-types-data (3.2018.0812)
48
44
  minitest (5.11.3)
49
- multi_json (1.13.1)
50
45
  multi_xml (0.6.0)
51
46
  mustermann (1.0.3)
52
47
  mustermann-grape (1.0.0)
@@ -22,6 +22,7 @@ module GrapeSimpleAuth
22
22
  define_setting :url, "http://localhost:4000"
23
23
  define_setting :verify_endpoint, "/v1/valid_token/verify"
24
24
  define_setting :auth_strategy, "swagger"
25
+ define_setting :current_user_class, "User"
25
26
 
26
27
  def self.verify_url
27
28
  url + verify_endpoint
@@ -19,7 +19,7 @@ module GrapeSimpleAuth
19
19
  end
20
20
 
21
21
  def current_user=(info)
22
- @_current_user = JSON.parse(info.to_json, object_class: DataStruct)
22
+ @_current_user = JSON.parse(info.to_json, object_class: User)
23
23
  end
24
24
 
25
25
  def current_user
@@ -34,6 +34,33 @@ module GrapeSimpleAuth
34
34
  @credentials
35
35
  end
36
36
 
37
+ class User < OpenStruct
38
+ def as_json(*args)
39
+ super.as_json['table']
40
+ end
41
+
42
+ def self.base_class
43
+ self
44
+ end
45
+
46
+ def self.primary_key
47
+ "id"
48
+ end
49
+
50
+
51
+ def self.name
52
+ GrapeSimpleAuth.current_user_class
53
+ end
54
+
55
+ def _read_attribute attr
56
+ self.send attr
57
+ end
58
+
59
+ def self.polymorphic_name
60
+ GrapeSimpleAuth.current_user_class
61
+ end
62
+ end
63
+
37
64
  class DataStruct < OpenStruct
38
65
  def as_json(*args)
39
66
  super.as_json['table']
@@ -1,3 +1,3 @@
1
1
  module GrapeSimpleAuth
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape_simple_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yunan Helmy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-22 00:00:00.000000000 Z
11
+ date: 2018-12-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler