diff --git a/lib/keycloak/http_client.rb b/lib/keycloak/http_client.rb index dd19bd8..c44b920 100644 --- a/lib/keycloak/http_client.rb +++ b/lib/keycloak/http_client.rb @@ -34,6 +34,15 @@ def put(uri, body = {}, access_token: nil) end end + def delete(uri, body = {}, access_token: nil) + uri = URI.parse(uri) + + request(:delete, uri, access_token) do |request| + request.body = body.to_json + request['Content-Type'] = 'application/json' + end + end + def post_form(uri, params, access_token: nil) uri = URI.parse(uri) diff --git a/lib/keycloak/realm.rb b/lib/keycloak/realm.rb index 1d1b980..6ff2ba4 100644 --- a/lib/keycloak/realm.rb +++ b/lib/keycloak/realm.rb @@ -56,7 +56,7 @@ def refresh(refresh_token) }) end - [:get, :post, :put].each do |method| + [:get, :post, :put, :delete].each do |method| define_method method do |endpoint, *args, **kwargs| kwargs[:access_token] = service_user_token http_client.send(method, "#{host}/admin/realms/#{realm}/#{endpoint}", *args, **kwargs)