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 +4 -4
- data/README.md +3 -1
- data/lib/keycloak/user_entity.rb +9 -12
- data/lib/keycloak/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91adde1a917a9abc16e320afab4bceb64ffcc177
|
4
|
+
data.tar.gz: 349fe8ced7814acfd3f9b09a77aa4d0b4cff0afd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
139
|
+
def keycloak_client
|
140
|
+
Keycloak::Realm.shundao_admin.client
|
141
|
+
end
|
140
142
|
end
|
141
143
|
```
|
142
144
|
|
data/lib/keycloak/user_entity.rb
CHANGED
@@ -2,34 +2,31 @@ module Keycloak
|
|
2
2
|
module UserEntity
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
|
-
|
6
|
-
|
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(
|
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(
|
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 ?
|
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
|
data/lib/keycloak/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2019-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|