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

Danny Im imxxx021 at umn.edu
Tue Mar 14 14:17:06 EDT 2017


Thanks for the suggestion,

I tried throwing a ModelException from within my custom event listener
provider's onEvent method but the user still got created.

On Thu, Mar 9, 2017 at 2:15 AM, Marek Posolda <mposolda at redhat.com> wrote:

> 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!
>>
>>
>


-- 
Danny Im
Software Developer
Polar Geospatial Center
University of Minnesota


More information about the keycloak-user mailing list