keycloak-admin 1.1.3 → 1.1.4
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.
- checksums.yaml +4 -4
- data/.github/workflows/Dockerfile +24 -24
- data/.github/workflows/ci.yml +80 -83
- data/.gitignore +9 -9
- data/.rspec +2 -2
- data/CHANGELOG.md +194 -188
- data/Dockerfile +12 -12
- data/Gemfile +3 -3
- data/Gemfile.lock +51 -49
- data/MIT-LICENSE +20 -20
- data/README.md +748 -748
- data/bin/console +9 -9
- data/keycloak-admin.gemspec +24 -24
- data/lib/keycloak-admin/client/attack_detection_client.rb +41 -41
- data/lib/keycloak-admin/client/client.rb +56 -56
- data/lib/keycloak-admin/client/client_authz_permission_client.rb +80 -80
- data/lib/keycloak-admin/client/client_authz_policy_client.rb +75 -75
- data/lib/keycloak-admin/client/client_authz_resource_client.rb +92 -92
- data/lib/keycloak-admin/client/client_authz_scope_client.rb +70 -70
- data/lib/keycloak-admin/client/client_client.rb +71 -71
- data/lib/keycloak-admin/client/client_role_client.rb +20 -20
- data/lib/keycloak-admin/client/client_role_mappings_client.rb +32 -32
- data/lib/keycloak-admin/client/configurable_token_client.rb +35 -35
- data/lib/keycloak-admin/client/group_client.rb +148 -131
- data/lib/keycloak-admin/client/identity_provider_client.rb +51 -51
- data/lib/keycloak-admin/client/realm_client.rb +122 -122
- data/lib/keycloak-admin/client/role_client.rb +59 -59
- data/lib/keycloak-admin/client/role_mapper_client.rb +47 -45
- data/lib/keycloak-admin/client/token_client.rb +29 -29
- data/lib/keycloak-admin/client/user_client.rb +266 -266
- data/lib/keycloak-admin/configuration.rb +52 -52
- data/lib/keycloak-admin/representation/attack_detection_representation.rb +17 -17
- data/lib/keycloak-admin/representation/camel_json.rb +12 -12
- data/lib/keycloak-admin/representation/client_authz_permission_representation.rb +33 -33
- data/lib/keycloak-admin/representation/client_authz_policy_config_representation.rb +14 -14
- data/lib/keycloak-admin/representation/client_authz_policy_representation.rb +26 -26
- data/lib/keycloak-admin/representation/client_authz_resource_representation.rb +25 -25
- data/lib/keycloak-admin/representation/client_authz_scope_representation.rb +16 -16
- data/lib/keycloak-admin/representation/client_representation.rb +71 -71
- data/lib/keycloak-admin/representation/credential_representation.rb +38 -38
- data/lib/keycloak-admin/representation/federated_identity_representation.rb +15 -15
- data/lib/keycloak-admin/representation/group_representation.rb +21 -21
- data/lib/keycloak-admin/representation/identity_provider_mapper_representation.rb +19 -19
- data/lib/keycloak-admin/representation/identity_provider_representation.rb +67 -67
- data/lib/keycloak-admin/representation/impersonation_redirection_representation.rb +16 -16
- data/lib/keycloak-admin/representation/impersonation_representation.rb +43 -43
- data/lib/keycloak-admin/representation/protocol_mapper_representation.rb +19 -19
- data/lib/keycloak-admin/representation/realm_representation.rb +14 -14
- data/lib/keycloak-admin/representation/representation.rb +23 -23
- data/lib/keycloak-admin/representation/role_representation.rb +19 -19
- data/lib/keycloak-admin/representation/session_representation.rb +22 -22
- data/lib/keycloak-admin/representation/token_representation.rb +39 -39
- data/lib/keycloak-admin/representation/user_representation.rb +47 -47
- data/lib/keycloak-admin/resource/base_role_containing_resource.rb +28 -28
- data/lib/keycloak-admin/resource/group_resource.rb +11 -11
- data/lib/keycloak-admin/resource/user_resource.rb +7 -7
- data/lib/keycloak-admin/version.rb +3 -3
- data/lib/keycloak-admin.rb +84 -84
- data/spec/client/attack_detection_client_spec.rb +102 -102
- data/spec/client/client_authz_permission_client_spec.rb +170 -170
- data/spec/client/client_authz_policy_client_spec.rb +169 -169
- data/spec/client/client_authz_resource_client_spec.rb +150 -150
- data/spec/client/client_authz_scope_client_spec.rb +133 -133
- data/spec/client/client_client_spec.rb +133 -133
- data/spec/client/client_role_mappings_client_spec.rb +82 -82
- data/spec/client/client_spec.rb +28 -28
- data/spec/client/configurable_token_client_spec.rb +34 -34
- data/spec/client/group_client_spec.rb +328 -258
- data/spec/client/identity_provider_client_spec.rb +92 -92
- data/spec/client/realm_client_spec.rb +155 -155
- data/spec/client/role_client_spec.rb +79 -79
- data/spec/client/role_mapper_client_spec.rb +113 -68
- data/spec/client/token_client_spec.rb +68 -68
- data/spec/client/user_client_spec.rb +373 -373
- data/spec/configuration_spec.rb +113 -113
- data/spec/integration/client_authorization_spec.rb +93 -95
- data/spec/representation/attack_detection_representation_spec.rb +15 -15
- data/spec/representation/client_authz_permission_representation_spec.rb +52 -52
- data/spec/representation/client_authz_policy_representation_spec.rb +46 -46
- data/spec/representation/client_authz_resource_representation_spec.rb +33 -33
- data/spec/representation/client_authz_scope_representation_spec.rb +18 -18
- data/spec/representation/client_representation_spec.rb +119 -119
- data/spec/representation/group_representation_spec.rb +22 -22
- data/spec/representation/identity_provider_mapper_representation_spec.rb +24 -24
- data/spec/representation/identity_provider_representation_spec.rb +113 -113
- data/spec/representation/impersonation_representation_spec.rb +163 -163
- data/spec/representation/protocol_mapper_representation_spec.rb +57 -57
- data/spec/representation/role_representation_spec.rb +37 -37
- data/spec/representation/session_representation_spec.rb +15 -15
- data/spec/representation/user_representation_spec.rb +15 -15
- data/spec/resource/group_resource_spec.rb +14 -14
- data/spec/resource/user_resource_spec.rb +14 -14
- data/spec/spec_helper.rb +37 -37
- metadata +10 -10
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
module KeycloakAdmin
|
|
2
|
-
class IdentityProviderRepresentation < Representation
|
|
3
|
-
attr_accessor :alias,
|
|
4
|
-
:display_name,
|
|
5
|
-
:internal_id,
|
|
6
|
-
:provider_id,
|
|
7
|
-
:enabled,
|
|
8
|
-
:update_profile_first_login_mode,
|
|
9
|
-
:trust_email,
|
|
10
|
-
:store_token,
|
|
11
|
-
:add_read_token_role_on_create,
|
|
12
|
-
:authenticate_by_default,
|
|
13
|
-
:link_only,
|
|
14
|
-
:first_broker_login_flow_alias,
|
|
15
|
-
:config
|
|
16
|
-
|
|
17
|
-
def self.from_hash(hash)
|
|
18
|
-
if hash.nil?
|
|
19
|
-
nil
|
|
20
|
-
else
|
|
21
|
-
new(
|
|
22
|
-
hash["alias"],
|
|
23
|
-
hash["displayName"],
|
|
24
|
-
hash["internalId"],
|
|
25
|
-
hash["providerId"],
|
|
26
|
-
hash["enabled"],
|
|
27
|
-
hash["updateProfileFirstLoginMode"],
|
|
28
|
-
hash["trustEmail"],
|
|
29
|
-
hash["storeToken"],
|
|
30
|
-
hash["addReadTokenRoleOnCreate"],
|
|
31
|
-
hash["authenticateByDefault"],
|
|
32
|
-
hash["linkOnly"],
|
|
33
|
-
hash["firstBrokerLoginFlowAlias"],
|
|
34
|
-
hash["config"]
|
|
35
|
-
)
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def initialize(alias_name,
|
|
40
|
-
display_name,
|
|
41
|
-
internal_id,
|
|
42
|
-
provider_id,
|
|
43
|
-
enabled,
|
|
44
|
-
update_profile_first_login_mode,
|
|
45
|
-
trust_email,
|
|
46
|
-
store_token,
|
|
47
|
-
add_read_token_role_on_create,
|
|
48
|
-
authenticate_by_default,
|
|
49
|
-
link_only,
|
|
50
|
-
first_broker_login_flow_alias,
|
|
51
|
-
config)
|
|
52
|
-
@alias = alias_name
|
|
53
|
-
@display_name = display_name
|
|
54
|
-
@internal_id = internal_id
|
|
55
|
-
@provider_id = provider_id
|
|
56
|
-
@enabled = enabled
|
|
57
|
-
@update_profile_first_login_mode = update_profile_first_login_mode
|
|
58
|
-
@trust_email = trust_email
|
|
59
|
-
@store_token = store_token
|
|
60
|
-
@add_read_token_role_on_create = add_read_token_role_on_create
|
|
61
|
-
@authenticate_by_default = authenticate_by_default
|
|
62
|
-
@link_only = link_only
|
|
63
|
-
@first_broker_login_flow_alias = first_broker_login_flow_alias
|
|
64
|
-
@config = config || {}
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
end
|
|
1
|
+
module KeycloakAdmin
|
|
2
|
+
class IdentityProviderRepresentation < Representation
|
|
3
|
+
attr_accessor :alias,
|
|
4
|
+
:display_name,
|
|
5
|
+
:internal_id,
|
|
6
|
+
:provider_id,
|
|
7
|
+
:enabled,
|
|
8
|
+
:update_profile_first_login_mode,
|
|
9
|
+
:trust_email,
|
|
10
|
+
:store_token,
|
|
11
|
+
:add_read_token_role_on_create,
|
|
12
|
+
:authenticate_by_default,
|
|
13
|
+
:link_only,
|
|
14
|
+
:first_broker_login_flow_alias,
|
|
15
|
+
:config
|
|
16
|
+
|
|
17
|
+
def self.from_hash(hash)
|
|
18
|
+
if hash.nil?
|
|
19
|
+
nil
|
|
20
|
+
else
|
|
21
|
+
new(
|
|
22
|
+
hash["alias"],
|
|
23
|
+
hash["displayName"],
|
|
24
|
+
hash["internalId"],
|
|
25
|
+
hash["providerId"],
|
|
26
|
+
hash["enabled"],
|
|
27
|
+
hash["updateProfileFirstLoginMode"],
|
|
28
|
+
hash["trustEmail"],
|
|
29
|
+
hash["storeToken"],
|
|
30
|
+
hash["addReadTokenRoleOnCreate"],
|
|
31
|
+
hash["authenticateByDefault"],
|
|
32
|
+
hash["linkOnly"],
|
|
33
|
+
hash["firstBrokerLoginFlowAlias"],
|
|
34
|
+
hash["config"]
|
|
35
|
+
)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def initialize(alias_name,
|
|
40
|
+
display_name,
|
|
41
|
+
internal_id,
|
|
42
|
+
provider_id,
|
|
43
|
+
enabled,
|
|
44
|
+
update_profile_first_login_mode,
|
|
45
|
+
trust_email,
|
|
46
|
+
store_token,
|
|
47
|
+
add_read_token_role_on_create,
|
|
48
|
+
authenticate_by_default,
|
|
49
|
+
link_only,
|
|
50
|
+
first_broker_login_flow_alias,
|
|
51
|
+
config)
|
|
52
|
+
@alias = alias_name
|
|
53
|
+
@display_name = display_name
|
|
54
|
+
@internal_id = internal_id
|
|
55
|
+
@provider_id = provider_id
|
|
56
|
+
@enabled = enabled
|
|
57
|
+
@update_profile_first_login_mode = update_profile_first_login_mode
|
|
58
|
+
@trust_email = trust_email
|
|
59
|
+
@store_token = store_token
|
|
60
|
+
@add_read_token_role_on_create = add_read_token_role_on_create
|
|
61
|
+
@authenticate_by_default = authenticate_by_default
|
|
62
|
+
@link_only = link_only
|
|
63
|
+
@first_broker_login_flow_alias = first_broker_login_flow_alias
|
|
64
|
+
@config = config || {}
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
module KeycloakAdmin
|
|
2
|
-
class ImpersonationRedirectionRepresentation < Representation
|
|
3
|
-
attr_reader :headers, :impersonation_url, :http_method, :body
|
|
4
|
-
|
|
5
|
-
def initialize(http_method, body, impersonation_url, headers)
|
|
6
|
-
@http_method = http_method
|
|
7
|
-
@body = body
|
|
8
|
-
@impersonation_url = impersonation_url
|
|
9
|
-
@headers = headers
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def self.from_url(url, headers)
|
|
13
|
-
new(:post, {}, url, headers)
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
1
|
+
module KeycloakAdmin
|
|
2
|
+
class ImpersonationRedirectionRepresentation < Representation
|
|
3
|
+
attr_reader :headers, :impersonation_url, :http_method, :body
|
|
4
|
+
|
|
5
|
+
def initialize(http_method, body, impersonation_url, headers)
|
|
6
|
+
@http_method = http_method
|
|
7
|
+
@body = body
|
|
8
|
+
@impersonation_url = impersonation_url
|
|
9
|
+
@headers = headers
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def self.from_url(url, headers)
|
|
13
|
+
new(:post, {}, url, headers)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
require "http-cookie"
|
|
2
|
-
|
|
3
|
-
module KeycloakAdmin
|
|
4
|
-
class ImpersonationRepresentation < Representation
|
|
5
|
-
attr_accessor :set_cookie_strings,
|
|
6
|
-
:set_cookies,
|
|
7
|
-
:same_realm,
|
|
8
|
-
:redirect,
|
|
9
|
-
:domain
|
|
10
|
-
|
|
11
|
-
def self.from_response(response, origin)
|
|
12
|
-
body = JSON.parse(response.body)
|
|
13
|
-
representation = new
|
|
14
|
-
representation.set_cookie_strings = response.headers[:set_cookie]
|
|
15
|
-
representation.set_cookies = representation.set_cookie_strings.map { |set_cookie| parse_set_cookie_string(set_cookie, origin) }
|
|
16
|
-
representation.same_realm = body["sameRealm"]
|
|
17
|
-
representation.redirect = body["redirect"]
|
|
18
|
-
representation.domain = origin
|
|
19
|
-
representation
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def self.parse_set_cookie_string(set_cookie_string, origin)
|
|
23
|
-
HTTP::Cookie.parse(set_cookie_string, origin).first
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def cookies_to_rails_hash
|
|
27
|
-
@set_cookies.map do |cookie|
|
|
28
|
-
rails_cookie = {
|
|
29
|
-
name: cookie.name,
|
|
30
|
-
value: cookie.value,
|
|
31
|
-
httponly: cookie.httponly,
|
|
32
|
-
expires: cookie.expires,
|
|
33
|
-
path: cookie.path,
|
|
34
|
-
domain: cookie.domain
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
rails_cookie[:max_age] = cookie.max_age if cookie.max_age
|
|
38
|
-
rails_cookie[:secure] = cookie.secure if cookie.secure
|
|
39
|
-
rails_cookie
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
1
|
+
require "http-cookie"
|
|
2
|
+
|
|
3
|
+
module KeycloakAdmin
|
|
4
|
+
class ImpersonationRepresentation < Representation
|
|
5
|
+
attr_accessor :set_cookie_strings,
|
|
6
|
+
:set_cookies,
|
|
7
|
+
:same_realm,
|
|
8
|
+
:redirect,
|
|
9
|
+
:domain
|
|
10
|
+
|
|
11
|
+
def self.from_response(response, origin)
|
|
12
|
+
body = JSON.parse(response.body)
|
|
13
|
+
representation = new
|
|
14
|
+
representation.set_cookie_strings = response.headers[:set_cookie]
|
|
15
|
+
representation.set_cookies = representation.set_cookie_strings.map { |set_cookie| parse_set_cookie_string(set_cookie, origin) }
|
|
16
|
+
representation.same_realm = body["sameRealm"]
|
|
17
|
+
representation.redirect = body["redirect"]
|
|
18
|
+
representation.domain = origin
|
|
19
|
+
representation
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.parse_set_cookie_string(set_cookie_string, origin)
|
|
23
|
+
HTTP::Cookie.parse(set_cookie_string, origin).first
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def cookies_to_rails_hash
|
|
27
|
+
@set_cookies.map do |cookie|
|
|
28
|
+
rails_cookie = {
|
|
29
|
+
name: cookie.name,
|
|
30
|
+
value: cookie.value,
|
|
31
|
+
httponly: cookie.httponly,
|
|
32
|
+
expires: cookie.expires,
|
|
33
|
+
path: cookie.path,
|
|
34
|
+
domain: cookie.domain
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
rails_cookie[:max_age] = cookie.max_age if cookie.max_age
|
|
38
|
+
rails_cookie[:secure] = cookie.secure if cookie.secure
|
|
39
|
+
rails_cookie
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
module KeycloakAdmin
|
|
2
|
-
class ProtocolMapperRepresentation < Representation
|
|
3
|
-
attr_accessor :config,
|
|
4
|
-
:id,
|
|
5
|
-
:name,
|
|
6
|
-
:protocol,
|
|
7
|
-
:protocolMapper
|
|
8
|
-
|
|
9
|
-
def self.from_hash(hash)
|
|
10
|
-
rep = new
|
|
11
|
-
rep.id = hash["id"]
|
|
12
|
-
rep.config = hash["config"]
|
|
13
|
-
rep.name = hash["name"]
|
|
14
|
-
rep.protocol = hash["protocol"]
|
|
15
|
-
rep.protocolMapper = hash["protocolMapper"]
|
|
16
|
-
rep
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
1
|
+
module KeycloakAdmin
|
|
2
|
+
class ProtocolMapperRepresentation < Representation
|
|
3
|
+
attr_accessor :config,
|
|
4
|
+
:id,
|
|
5
|
+
:name,
|
|
6
|
+
:protocol,
|
|
7
|
+
:protocolMapper
|
|
8
|
+
|
|
9
|
+
def self.from_hash(hash)
|
|
10
|
+
rep = new
|
|
11
|
+
rep.id = hash["id"]
|
|
12
|
+
rep.config = hash["config"]
|
|
13
|
+
rep.name = hash["name"]
|
|
14
|
+
rep.protocol = hash["protocol"]
|
|
15
|
+
rep.protocolMapper = hash["protocolMapper"]
|
|
16
|
+
rep
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
module KeycloakAdmin
|
|
2
|
-
class RealmRepresentation < Representation
|
|
3
|
-
attr_accessor :id,
|
|
4
|
-
:realm
|
|
5
|
-
# TODO: Add more attributes
|
|
6
|
-
|
|
7
|
-
def self.from_hash(hash)
|
|
8
|
-
realm = new
|
|
9
|
-
realm.id = hash["id"]
|
|
10
|
-
realm.realm = hash["realm"]
|
|
11
|
-
realm
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
1
|
+
module KeycloakAdmin
|
|
2
|
+
class RealmRepresentation < Representation
|
|
3
|
+
attr_accessor :id,
|
|
4
|
+
:realm
|
|
5
|
+
# TODO: Add more attributes
|
|
6
|
+
|
|
7
|
+
def self.from_hash(hash)
|
|
8
|
+
realm = new
|
|
9
|
+
realm.id = hash["id"]
|
|
10
|
+
realm.realm = hash["realm"]
|
|
11
|
+
realm
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
require "json"
|
|
2
|
-
require_relative "camel_json"
|
|
3
|
-
|
|
4
|
-
class Representation
|
|
5
|
-
include ::KeycloakAdmin::CamelJson
|
|
6
|
-
|
|
7
|
-
def as_json(options=nil)
|
|
8
|
-
Hash[instance_variables.map { |ivar| [ivar.to_s[1..-1], instance_variable_get(ivar)] }]
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def to_json(options=nil)
|
|
12
|
-
snaked_hash = as_json(options)
|
|
13
|
-
snaked_hash.keys.reduce({}) do |camelized_hash, key|
|
|
14
|
-
camelized_hash[camelize(key, false)] = snaked_hash[key]
|
|
15
|
-
camelized_hash
|
|
16
|
-
end.to_json(options)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def self.from_json(json)
|
|
20
|
-
hash = JSON.parse(json)
|
|
21
|
-
from_hash(hash)
|
|
22
|
-
end
|
|
23
|
-
end
|
|
1
|
+
require "json"
|
|
2
|
+
require_relative "camel_json"
|
|
3
|
+
|
|
4
|
+
class Representation
|
|
5
|
+
include ::KeycloakAdmin::CamelJson
|
|
6
|
+
|
|
7
|
+
def as_json(options=nil)
|
|
8
|
+
Hash[instance_variables.map { |ivar| [ivar.to_s[1..-1], instance_variable_get(ivar)] }]
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def to_json(options=nil)
|
|
12
|
+
snaked_hash = as_json(options)
|
|
13
|
+
snaked_hash.keys.reduce({}) do |camelized_hash, key|
|
|
14
|
+
camelized_hash[camelize(key, false)] = snaked_hash[key]
|
|
15
|
+
camelized_hash
|
|
16
|
+
end.to_json(options)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.from_json(json)
|
|
20
|
+
hash = JSON.parse(json)
|
|
21
|
+
from_hash(hash)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
module KeycloakAdmin
|
|
2
|
-
class RoleRepresentation < Representation
|
|
3
|
-
attr_accessor :id,
|
|
4
|
-
:name,
|
|
5
|
-
:composite,
|
|
6
|
-
:client_role,
|
|
7
|
-
:container_id,
|
|
8
|
-
|
|
9
|
-
def self.from_hash(hash)
|
|
10
|
-
role = new
|
|
11
|
-
role.id = hash["id"]
|
|
12
|
-
role.name = hash["name"]
|
|
13
|
-
role.composite = hash["composite"]
|
|
14
|
-
role.client_role = hash["clientRole"]
|
|
15
|
-
role.container_id = hash["containerId"]
|
|
16
|
-
role
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
1
|
+
module KeycloakAdmin
|
|
2
|
+
class RoleRepresentation < Representation
|
|
3
|
+
attr_accessor :id,
|
|
4
|
+
:name,
|
|
5
|
+
:composite,
|
|
6
|
+
:client_role,
|
|
7
|
+
:container_id,
|
|
8
|
+
|
|
9
|
+
def self.from_hash(hash)
|
|
10
|
+
role = new
|
|
11
|
+
role.id = hash["id"]
|
|
12
|
+
role.name = hash["name"]
|
|
13
|
+
role.composite = hash["composite"]
|
|
14
|
+
role.client_role = hash["clientRole"]
|
|
15
|
+
role.container_id = hash["containerId"]
|
|
16
|
+
role
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
module KeycloakAdmin
|
|
2
|
-
class SessionRepresentation < Representation
|
|
3
|
-
attr_accessor :id,
|
|
4
|
-
:username,
|
|
5
|
-
:user_id,
|
|
6
|
-
:ip_address,
|
|
7
|
-
:start,
|
|
8
|
-
:last_access,
|
|
9
|
-
:remember_me,
|
|
10
|
-
|
|
11
|
-
def self.from_hash(hash)
|
|
12
|
-
rep = new
|
|
13
|
-
rep.id = hash["id"]
|
|
14
|
-
rep.username = hash["username"]
|
|
15
|
-
rep.user_id = hash["userId"]
|
|
16
|
-
rep.ip_address = hash["ipAddress"]
|
|
17
|
-
rep.start = hash["start"]
|
|
18
|
-
rep.last_access = hash["lastAccess"]
|
|
19
|
-
rep.remember_me = hash["rememberMe"]
|
|
20
|
-
rep
|
|
21
|
-
end
|
|
22
|
-
end
|
|
1
|
+
module KeycloakAdmin
|
|
2
|
+
class SessionRepresentation < Representation
|
|
3
|
+
attr_accessor :id,
|
|
4
|
+
:username,
|
|
5
|
+
:user_id,
|
|
6
|
+
:ip_address,
|
|
7
|
+
:start,
|
|
8
|
+
:last_access,
|
|
9
|
+
:remember_me,
|
|
10
|
+
|
|
11
|
+
def self.from_hash(hash)
|
|
12
|
+
rep = new
|
|
13
|
+
rep.id = hash["id"]
|
|
14
|
+
rep.username = hash["username"]
|
|
15
|
+
rep.user_id = hash["userId"]
|
|
16
|
+
rep.ip_address = hash["ipAddress"]
|
|
17
|
+
rep.start = hash["start"]
|
|
18
|
+
rep.last_access = hash["lastAccess"]
|
|
19
|
+
rep.remember_me = hash["rememberMe"]
|
|
20
|
+
rep
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
23
|
end
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
module KeycloakAdmin
|
|
3
|
-
class TokenRepresentation < Representation
|
|
4
|
-
attr_accessor :access_token,
|
|
5
|
-
:token_type,
|
|
6
|
-
:expires_in,
|
|
7
|
-
:refresh_token,
|
|
8
|
-
:refresh_expires_in,
|
|
9
|
-
:id_token,
|
|
10
|
-
:not_before_policy,
|
|
11
|
-
:session_state
|
|
12
|
-
|
|
13
|
-
def initialize(access_token, token_type, expires_in, refresh_token, refresh_expires_in, id_token, not_before_policy, session_state)
|
|
14
|
-
@access_token = access_token
|
|
15
|
-
@token_type = token_type
|
|
16
|
-
@expires_in = expires_in
|
|
17
|
-
@refresh_token = refresh_token
|
|
18
|
-
@refresh_expires_in = refresh_expires_in
|
|
19
|
-
@id_token = id_token
|
|
20
|
-
@not_before_policy = not_before_policy
|
|
21
|
-
@session_state = session_state
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def self.from_hash(hash)
|
|
25
|
-
new(
|
|
26
|
-
hash["access_token"],
|
|
27
|
-
hash["token_type"],
|
|
28
|
-
hash["expires_in"],
|
|
29
|
-
hash["refresh_token"],
|
|
30
|
-
hash["refresh_expires_in"],
|
|
31
|
-
hash["id_token"],
|
|
32
|
-
hash["not-before-policy"],
|
|
33
|
-
hash["session_state"],
|
|
34
|
-
)
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
|
|
1
|
+
|
|
2
|
+
module KeycloakAdmin
|
|
3
|
+
class TokenRepresentation < Representation
|
|
4
|
+
attr_accessor :access_token,
|
|
5
|
+
:token_type,
|
|
6
|
+
:expires_in,
|
|
7
|
+
:refresh_token,
|
|
8
|
+
:refresh_expires_in,
|
|
9
|
+
:id_token,
|
|
10
|
+
:not_before_policy,
|
|
11
|
+
:session_state
|
|
12
|
+
|
|
13
|
+
def initialize(access_token, token_type, expires_in, refresh_token, refresh_expires_in, id_token, not_before_policy, session_state)
|
|
14
|
+
@access_token = access_token
|
|
15
|
+
@token_type = token_type
|
|
16
|
+
@expires_in = expires_in
|
|
17
|
+
@refresh_token = refresh_token
|
|
18
|
+
@refresh_expires_in = refresh_expires_in
|
|
19
|
+
@id_token = id_token
|
|
20
|
+
@not_before_policy = not_before_policy
|
|
21
|
+
@session_state = session_state
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.from_hash(hash)
|
|
25
|
+
new(
|
|
26
|
+
hash["access_token"],
|
|
27
|
+
hash["token_type"],
|
|
28
|
+
hash["expires_in"],
|
|
29
|
+
hash["refresh_token"],
|
|
30
|
+
hash["refresh_expires_in"],
|
|
31
|
+
hash["id_token"],
|
|
32
|
+
hash["not-before-policy"],
|
|
33
|
+
hash["session_state"],
|
|
34
|
+
)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
module KeycloakAdmin
|
|
2
|
-
class UserRepresentation < Representation
|
|
3
|
-
attr_accessor :id,
|
|
4
|
-
:created_timestamp,
|
|
5
|
-
:attributes,
|
|
6
|
-
:origin,
|
|
7
|
-
:username,
|
|
8
|
-
:email,
|
|
9
|
-
:enabled,
|
|
10
|
-
:email_verified,
|
|
11
|
-
:first_name,
|
|
12
|
-
:last_name,
|
|
13
|
-
:totp,
|
|
14
|
-
:credentials,
|
|
15
|
-
:federated_identities,
|
|
16
|
-
:required_actions
|
|
17
|
-
|
|
18
|
-
def self.from_hash(hash)
|
|
19
|
-
user = new
|
|
20
|
-
user.id = hash["id"]
|
|
21
|
-
user.created_timestamp = hash["createdTimestamp"]
|
|
22
|
-
user.origin = hash["origin"]
|
|
23
|
-
user.username = hash["username"]
|
|
24
|
-
user.email = hash["email"]
|
|
25
|
-
user.enabled = hash["enabled"]
|
|
26
|
-
user.email_verified = hash["emailVerified"]
|
|
27
|
-
user.first_name = hash["firstName"]
|
|
28
|
-
user.last_name = hash["lastName"]
|
|
29
|
-
user.attributes = hash["attributes"]
|
|
30
|
-
user.required_actions = hash["requiredActions"] || []
|
|
31
|
-
user.totp = hash["totp"] || false
|
|
32
|
-
user.credentials = hash["credentials"]&.map{ |hash| CredentialRepresentation.from_hash(hash) } || []
|
|
33
|
-
user.federated_identities = hash["federatedIdentities"]&.map { |hash| FederatedIdentityRepresentation.from_hash(hash) } || []
|
|
34
|
-
user
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def add_credential(credential_representation)
|
|
38
|
-
@credentials ||= []
|
|
39
|
-
@credentials.push(credential_representation)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def add_federated_identity(federated_identity_representation)
|
|
43
|
-
@federated_identities ||= []
|
|
44
|
-
@federated_identities.push(federated_identity_representation)
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
1
|
+
module KeycloakAdmin
|
|
2
|
+
class UserRepresentation < Representation
|
|
3
|
+
attr_accessor :id,
|
|
4
|
+
:created_timestamp,
|
|
5
|
+
:attributes,
|
|
6
|
+
:origin,
|
|
7
|
+
:username,
|
|
8
|
+
:email,
|
|
9
|
+
:enabled,
|
|
10
|
+
:email_verified,
|
|
11
|
+
:first_name,
|
|
12
|
+
:last_name,
|
|
13
|
+
:totp,
|
|
14
|
+
:credentials,
|
|
15
|
+
:federated_identities,
|
|
16
|
+
:required_actions
|
|
17
|
+
|
|
18
|
+
def self.from_hash(hash)
|
|
19
|
+
user = new
|
|
20
|
+
user.id = hash["id"]
|
|
21
|
+
user.created_timestamp = hash["createdTimestamp"]
|
|
22
|
+
user.origin = hash["origin"]
|
|
23
|
+
user.username = hash["username"]
|
|
24
|
+
user.email = hash["email"]
|
|
25
|
+
user.enabled = hash["enabled"]
|
|
26
|
+
user.email_verified = hash["emailVerified"]
|
|
27
|
+
user.first_name = hash["firstName"]
|
|
28
|
+
user.last_name = hash["lastName"]
|
|
29
|
+
user.attributes = hash["attributes"]
|
|
30
|
+
user.required_actions = hash["requiredActions"] || []
|
|
31
|
+
user.totp = hash["totp"] || false
|
|
32
|
+
user.credentials = hash["credentials"]&.map{ |hash| CredentialRepresentation.from_hash(hash) } || []
|
|
33
|
+
user.federated_identities = hash["federatedIdentities"]&.map { |hash| FederatedIdentityRepresentation.from_hash(hash) } || []
|
|
34
|
+
user
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def add_credential(credential_representation)
|
|
38
|
+
@credentials ||= []
|
|
39
|
+
@credentials.push(credential_representation)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def add_federated_identity(federated_identity_representation)
|
|
43
|
+
@federated_identities ||= []
|
|
44
|
+
@federated_identities.push(federated_identity_representation)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|