Class: KeycloakAdmin::AttackDetectionClient

Inherits:
Client
  • Object
show all
Defined in:
lib/keycloak-admin/client/attack_detection_client.rb

Instance Method Summary collapse

Methods inherited from Client

#create_payload, #created_id, #current_token, #execute_http, #headers, #server_url

Constructor Details

#initialize(configuration, realm_client) ⇒ AttackDetectionClient

Returns a new instance of AttackDetectionClient.

Raises:

  • (ArgumentError)


3
4
5
6
7
# File 'lib/keycloak-admin/client/attack_detection_client.rb', line 3

def initialize(configuration, realm_client)
  super(configuration)
  raise ArgumentError.new("realm must be defined") unless realm_client.name_defined?
  @realm_client = realm_client
end

Instance Method Details

#brute_force_url(user_id = nil) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/keycloak-admin/client/attack_detection_client.rb', line 34

def brute_force_url(user_id = nil)
  if user_id
    "#{@realm_client.realm_admin_url}/attack-detection/brute-force/users/#{user_id}"
  else
    "#{@realm_client.realm_admin_url}/attack-detection/brute-force/users"
  end
end

#lock_status(user_id) ⇒ Object

Raises:

  • (ArgumentError)


9
10
11
12
13
14
15
16
# File 'lib/keycloak-admin/client/attack_detection_client.rb', line 9

def lock_status(user_id)
  raise ArgumentError.new("user_id must be defined") if user_id.nil?

  response = execute_http do
    RestClient::Resource.new(brute_force_url(user_id), @configuration.rest_client_options).get(headers)
  end
  AttackDetectionRepresentation.from_hash(JSON.parse(response))
end

#unlock_user(user_id) ⇒ Object

Raises:

  • (ArgumentError)


18
19
20
21
22
23
24
25
# File 'lib/keycloak-admin/client/attack_detection_client.rb', line 18

def unlock_user(user_id)
  raise ArgumentError.new("user_id must be defined") if user_id.nil?

  execute_http do
    RestClient::Resource.new(brute_force_url(user_id), @configuration.rest_client_options).delete(headers)
  end
  true
end

#unlock_usersObject



27
28
29
30
31
32
# File 'lib/keycloak-admin/client/attack_detection_client.rb', line 27

def unlock_users
  execute_http do
    RestClient::Resource.new(brute_force_url, @configuration.rest_client_options).delete(headers)
  end
  true
end