[keycloak-user] JPA Authentication Provider

Marek Posolda mposolda at redhat.com
Mon Jun 2 03:38:07 EDT 2014

Hi Josh,

yes, it's possible to create your own JPA authentication provider, which 
will use hibernate model of your own application and authenticate users 
based on your user data. I hope I understand correctly that this is 
something you are trying achieve?

For declare own datasource, it's easiest to add datasource into file 
JBOSS_HOME/standalone/configuration/standalone.xml (look at 
JBoss/Wildfly documentation and/or existing datasource declarations how 
to do it) and then either create new file META-INF/persistence.xml 
inside your JAR and/or extend existing keycloak file 
and declare your own persistence unit, which will point to the 
datasource declared in standalone.xml . Again look at docs or existing 
persistence units for inspiration. Finally in code of your provider, you 
can do something like:

EntityManagerFactory emf =Persistence.createEntityManagerFactory("name-of-your-persistence-unit");

You can take a look at existing Keycloak sources for inspiration.


On 30.5.2014 22:39, Josh wrote:
> Hi guys,
> Wondering if it would be possible to create a JPA authentication 
> provider?
> What I am trying to do is share the hibernate user model between 
> keycloak authentication provider and my application.  I've got as far 
> as extracting the models into their own project so they can be used as 
> dependency between my application / authentication provider.
> Still wrapping my head around JavaEE architecture so forgive me if 
> this next sentence doesn't make any sense... The properties 
> authentication adapter in beta1 examples is a jar which can't really 
> declare it's own data sources.  So wondering how I would implement a 
> provider that defines its own datasource?
> Thanks,
> Josh
> _______________________________________________
> keycloak-user mailing list
> keycloak-user at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-user

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/keycloak-user/attachments/20140602/a2a7257f/attachment.html 

More information about the keycloak-user mailing list