[keycloak-user] Delete all resources

Corentin Dupont corentin.dupont at gmail.com
Mon Jul 29 09:35:06 EDT 2019


Thanks a lot.
This is the script I wrote:

CLIENTTOKEN=`curl -X POST -H "Content-Type:
application/x-www-form-urlencoded" -d
'grant_type=client_credentials&client_id=api-server&client_secret=XXXXXX' "
http://localhost:8080/auth/realms/waziup/protocol/openid-connect/token" |
jq .access_token -r`

curl "
http://localhost:8080/auth/realms/waziup/authz/protection/resource_set?max=1000"
-H "Authorization: Bearer $CLIENTTOKEN" -H "Content-Type: application/json"
-v > resources.json

jq -c -r '.[]' resources.json | while read i; do
  echo "deleting $i"
  curl -X DELETE "
http://localhost:8080/auth/realms/waziup/authz/protection/resource_set/$i"
-H "Authorization: Bearer $CLIENTTOKEN"
done

Seems to work.
Cheers

On Mon, Jul 29, 2019 at 2:54 PM Pedro Igor Silva <psilva at redhat.com> wrote:

> Hi Corentin,
>
> It should be related to https://issues.jboss.org/browse/KEYCLOAK-8784.
>
> Doing it directly in the DB will not work because of the cache.
>
> One thing you could do, as a workaround, is disable the authz settings and
> enable it again for a particular client. By doing that, any authz setting
> associated with the client will be removed, not only resources. After that,
> you should be able to import your policies and start from scratch.
>
> Regards.
> Pedro Igor
>
> On Mon, Jul 29, 2019 at 9:45 AM Corentin Dupont <corentin.dupont at gmail.com>
> wrote:
>
>> Hi guys,
>> is there an easy way to delete all resources? The UI doesn't seem to offer
>> this functionality.
>> It seems I need to create a small script with the API, right?
>> Or can performing some DB commands (drop TABLE) could do it?
>> Thanks
>> Corentin
>> _______________________________________________
>> keycloak-user mailing list
>> keycloak-user at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/keycloak-user
>>
>


More information about the keycloak-user mailing list