Module: Keycloak::Admin::Users
- Extended by:
- Resource, Resource::Pagination
- Defined in:
- lib/keycloak/admin/users.rb
Overview
Users resource.
The class is based on Keycloak::Admin::Resource and Keycloak::Admin::Resource::Pagination. It provides following additional methods:
-
::join
-
::leave
-
::logout
-
::password
-
::sessions
Constant Summary
Constants included from Resource::Pagination
Resource::Pagination::MAX_ENTRIES
Instance Attribute Summary
Attributes included from Resource
Class Method Summary collapse
-
.join(id, group_id) ⇒ Object
Add user to group.
-
.leave(id, group_id) ⇒ Object
Remove user from group.
-
.logout(id) ⇒ Object
Logout user from all sessions.
-
.membership(id) ⇒ Object
User membership.
-
.password(id, attributes) ⇒ Object
Set new password for user.
-
.sessions(id) ⇒ Object
Get user sessions.
Methods included from Resource::Pagination
Methods included from Resource
all, create, delete, find_by, find_by_id, update
Class Method Details
.join(id, group_id) ⇒ Object
Add user to group.
27 28 29 30 31 |
# File 'lib/keycloak/admin/users.rb', line 27 def join(id, group_id) @agent.put("#{resource}/#{id}/groups/#{group_id}") true end |
.leave(id, group_id) ⇒ Object
Remove user from group.
35 36 37 38 39 |
# File 'lib/keycloak/admin/users.rb', line 35 def leave(id, group_id) @agent.delete("#{resource}/#{id}/groups/#{group_id}") true end |
.logout(id) ⇒ Object
Logout user from all sessions.
55 56 57 58 59 |
# File 'lib/keycloak/admin/users.rb', line 55 def logout(id) @agent.post("#{resource}/#{id}/logout") true end |
.membership(id) ⇒ Object
User membership.
43 44 45 46 47 48 49 50 51 |
# File 'lib/keycloak/admin/users.rb', line 43 def membership(id) objects = [] (1..pages).each do |page| first = (page * MAX_ENTRIES) - MAX_ENTRIES objects << @agent.get("#{resource}/#{id}/groups?first=#{first}&max=#{MAX_ENTRIES}") end objects.flatten.map { |object| mash(object) } end |
.password(id, attributes) ⇒ Object
Set new password for user.
63 64 65 66 67 68 69 |
# File 'lib/keycloak/admin/users.rb', line 63 def password(id, attributes) # { temporary: false, value: 'password' } attributes[:type] = 'password' @agent.put("#{resource}/#{id}/reset-password", params: { body: attributes.to_json }) true end |
.sessions(id) ⇒ Object
Get user sessions.
73 74 75 76 77 |
# File 'lib/keycloak/admin/users.rb', line 73 def sessions(id) objects = @agent.get("#{resource}/#{id}/sessions") objects.map { |object| mash(object) } end |