[keycloak-user] Is there a pre-save event

Marek Posolda mposolda at redhat.com
Thu Mar 9 03:15:32 EST 2017


AFAIK we don't have any additional validation for creating user through 
admin REST API. But I can see that "success" event in 
UsersResource.createUser is invoked even before the transaction commit 
happened. So I think that if you do the validations in your event 
listener and throw the ModelException from it, it will cause the 
transaction rollback and user won't be written to DB.

Maybe there is some space for improvement in our API (eg. infinispan has 
both "pre" and "post" events), however this one above should work too.

Marek

On 08/03/17 19:13, Danny Im wrote:
> Hi,
>
> I'm implementing an Event Listener Provider, and was wondering if there is
> a way to add some functionality before an object is created or updated.  In
> my case, I would like to do some extra validation on incoming fields before
> a user is created within keycloak.
>
> In the javadoc:
> http://www.keycloak.org/docs-api/2.5/javadocs/index.html
> under org.keycloak.events.admin.OperationType I only see four actions:
> ACTION
> <http://www.keycloak.org/docs-api/2.5/javadocs/org/keycloak/events/admin/OperationType.html#ACTION>,
> CREATE,
> <http://www.keycloak.org/docs-api/2.5/javadocs/org/keycloak/events/admin/OperationType.html#CREATE>
> DELETE
> <http://www.keycloak.org/docs-api/2.5/javadocs/org/keycloak/events/admin/OperationType.html#DELETE>,
> and UPDATE
> <http://www.keycloak.org/docs-api/2.5/javadocs/org/keycloak/events/admin/OperationType.html#UPDATE>
>
>
> Thanks!
>



More information about the keycloak-user mailing list