keycloak-ruby-client 0.0.8 → 0.0.9

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
  SHA1:
3
- metadata.gz: 15e664b3d8f91b89f7f6486f322a364a5b201045
4
- data.tar.gz: a87cad169868812f3504296963c5306ea62f8c9c
3
+ metadata.gz: 91adde1a917a9abc16e320afab4bceb64ffcc177
4
+ data.tar.gz: 349fe8ced7814acfd3f9b09a77aa4d0b4cff0afd
5
5
  SHA512:
6
- metadata.gz: 3f4a1411d8033cfb0a1b9c4e551377266d3ced6c801e32ece8908220438735d0a899cf57728be994635284d7167a13932f663464cecd1771ccce3db1b1126fe7
7
- data.tar.gz: 5931bbeb64841be046af2877ae8df52669c44e504ae1e32a515ceca1e39ff17fdc544247f329e3b8cd18b6a571aa75a4c94e81d532b4c56f38ecfc1b8c2f1d2d
6
+ metadata.gz: 4f2f96727de3173f496d9919cd85e5acec9d5ec6fe85dcfe28c164e296befa01fa9a4ea054c682d5f37b5e7ac163bddec2aebcfb973308a895e26d1fcdda0db7
7
+ data.tar.gz: 246966257694d98680ee4cb821dbc190c6f55833fe980901eb5467552744cd209e5a1198c935d064d233e5c402cbbcb2cbfc4bc62d4146182afb02bfce7b27dd
data/README.md CHANGED
@@ -136,7 +136,9 @@ Your model file `User.rb` as the following:
136
136
  class User < ApplicationRecord
137
137
  include Keycloak::UserEntity
138
138
 
139
- use_keycloak_client Keycloak::Realm.shundao_admin.client
139
+ def keycloak_client
140
+ Keycloak::Realm.shundao_admin.client
141
+ end
140
142
  end
141
143
  ```
142
144
 
@@ -2,34 +2,31 @@ module Keycloak
2
2
  module UserEntity
3
3
  extend ActiveSupport::Concern
4
4
 
5
- class_methods do
6
- cattr_reader :keycloak_client
7
-
8
- # @param client [Keycloak::Client] keycloak client
9
- def use_keycloak_client(client)
10
- @keycloak_client = client
5
+ included do
6
+ def keycloak_client
7
+ raise NotImplementedError
11
8
  end
12
- end
13
9
 
14
- included do
15
10
  def keycloak_identify
16
11
  id
17
12
  end
18
13
 
19
14
  def user_info(reload = false)
20
- _set_or_get_keycloak_data(:user_info, reload) { keycloak_client.find_user(keycloak_identify) }
15
+ _set_or_get_keycloak_data(:@user_info, reload) { keycloak_client.find_user(keycloak_identify) }
21
16
  end
22
17
 
23
18
  def realm_roles(reload = false)
24
- _set_or_get_keycloak_data(:realm_roles, reload) { keycloak_client.find_user_realm_roles(keycloak_identify) }
19
+ _set_or_get_keycloak_data(:@realm_roles, reload) { keycloak_client.find_user_realm_roles(keycloak_identify) }
25
20
  end
26
21
 
27
22
  def has_role?(role)
28
- realm_roles.include?(role)
23
+ realm_roles.map(&:name).include?(role)
29
24
  end
30
25
 
31
26
  def _set_or_get_keycloak_data(attr_name, reload)
32
- reload ? instance_variable_set(yield) : instance_variable_get(attr_name) || instance_variable_set(yield)
27
+ reload ?
28
+ instance_variable_set(attr_name, yield) :
29
+ instance_variable_get(attr_name) || instance_variable_set(attr_name, yield)
33
30
  end
34
31
  end
35
32
  end
@@ -1,3 +1,3 @@
1
1
  module Keycloak
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: keycloak-ruby-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fuxin Hao
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-08-27 00:00:00.000000000 Z
11
+ date: 2019-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails