How can one extend the user model itself?

Is it possible to extend the user model itself in Keycloak?

I’d like to add a new field to the user model, that would also be persisted and stored in db.

There are many ways to achieve this, one of them is a custom implementation of the user model spi.

However, this approach is probably in conflict with currently ongoing efforts to move as much as possible into the attributes array of the user. Which is probably the easiest way to get the data persisted. This would also require you to modify the frontend in case you want to expose the information.

Currently in preview is the declarative user profile feature, which would allow you to configure the user attributes and its validators from the admin console.