<div dir="ltr">Sounds like you&#39;re on the right track. You&#39;d need to implement support for Mongo as well though as we can&#39;t accept it otherwise.<div><br></div><div>With regards to tests I&#39;d add to org.keycloak.testsuite.admin.realm.RealmTest which would also make sure attributes work correctly when added through the admin endpoints.<br><div class="gmail_extra"><br><div class="gmail_quote">On 13 August 2016 at 16:47, Dmitry Telegin <span dir="ltr">&lt;<a href="mailto:mitya@cargosoft.ru" target="_blank">mitya@cargosoft.ru</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div>Hi,</div><div><br></div><div>(As Stian is on vacation now, I&#39;d appreciate if someone other helps me with this feature.)</div><div><br></div><div>Please take a look <a href="https://github.com/keycloak/keycloak/compare/2.1.0.Final...cargosoft:KEYCLOAK-3327" target="_blank">https://github.com/<wbr>keycloak/keycloak/compare/2.1.<wbr>0.Final...cargosoft:KEYCLOAK-<wbr>3327</a></div><div><br></div><div>(it has been branched off 2.1.0.Final for the ease of testing, I&#39;ll rebase it onto master if needed)</div><div><br></div><div>o.k.models.RealmModel: added methods (borrowed signatures from jpa.RealmAdapter)</div><div>o.k.models.jpa.RealmAdapter: added @Override annotations</div><div><span title="model/mongo/src/main/java/org/keycloak/models/mongo/keycloak/adapters/RealmAdapter.java">o.k.models.mongo.keycloak.<wbr>adapters.RealmAdapter: added stubs (throwing </span>UnsupportedOperation<wbr>Exception)</div><div><span title="model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/RealmAdapter.java">o.k.models.cache.infinispan.<wbr>RealmAdapter: added attributes caching logic</span></div><div><span title="model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/RealmAdapter.java">o.k.</span>models.cache.infinispan.<wbr>entities.CachedRealm: added attributes cache (as Map&lt;String, String&gt;)</div><div><br></div><div>As for tests, I&#39;m afraid I&#39;ll need some guidance. org.keycloak.testsuite.model.<wbr>ModelTest seems appropriate for that; but it will need support for attributes in RealmRepresentation and RealmManager. Is this the right direction?</div><div><br></div><div>Dmitry</div><div><div class="h5"><div><br></div><blockquote type="cite"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 18 July 2016 at 22:35, Dmitry Telegin <span dir="ltr">&lt;<a href="mailto:mitya@cargosoft.ru" target="_blank">mitya@cargosoft.ru</a>&gt;</span> wrote:<br><blockquote type="cite"><div><div>Stian,</div><div><br></div><div>Here we go: <a href="https://issues.jboss.org/browse/KEYCLOAK-3327" target="_blank">https://issues.jboss.org/<wbr>browse/KEYCLOAK-3327</a></div><div><br></div><div>If the fix is somewhat trivial (i.e. a matter of adding fields and getters/setters) I think I could work on a PR as well.</div></div><br></blockquote><div><br></div><div>As the attributes are already available in the underlying entities it&#39;s just a matter of exposing through RealmModel and add tests for it.</div><div> </div><blockquote type="cite"><div><div><br></div><div>BTW, does this mean that all the custom entities provided via Entity SPI are not by default cache-enabled (and won&#39;t be synchronized between the nodes in clustered environment)?</div><div>If so, will it be easy to cache-enable them? Is this just a matter of providing Infinispan adapters similar to existing ones for Realm/User/Role/Client etc.?</div></div><br></blockquote><div><br></div><div>There&#39;s no caching for custom entities. I&#39;d recommend using Hibernate 2nd level cache for it as it&#39;s rather tricky to create a custom one. We have our custom one because we need to support Mongo as well as users from different sources (user federation and identity brokering).</div><div> </div><blockquote type="cite"><div><div><br></div><div>Ideally, I&#39;d like to see a current domain-extension example augmented with Infinispan cache functionality. I&#39;ve got some ideas on a detailed walkthrough tutorial for building complete, full-featured KeyCloak extensions (it&#39;s a big topic I&#39;ll elaborate on a bit later); I think Infinispan-enabled entities could be covered there, too.</div></div><br></blockquote><div><br></div><div>No chance we&#39;re adding cache for custom entities. It&#39;s just to hard to get right. For custom entities you should use Hibernate 2nd level cache.</div><div> </div><blockquote type="cite"><div><div><br></div><div>Regards,</div><div>Dmitry</div><div><br></div><div>В Пн, 18/07/2016 в 07:39 +0200, Stian Thorgersen пишет:</div><div><div><blockquote type="cite"><div dir="ltr">Forgot that attributes are not exposed through RealmModel. You can&#39;t access the JPA RealmAdapter directly as you&#39;ll break the cache functionality. You can create a JIRA to request attributes added to RealmModel though.</div><div class="gmail_extra"><br><div class="gmail_quote">On 15 July 2016 at 20:28, Mitya <span dir="ltr">&lt;<a href="mailto:mitya@cargosoft.ru" target="_blank">mitya@cargosoft.ru</a>&gt;</span> wrote:<br><blockquote type="cite"><div><div>Stian,</div><div><br></div><div>In my provider, session.getContext().getRealm(<wbr>) returns an instance of org.keycloak.models.cache.<wbr>infinispan.RealmAdapter. But in order to be able to manage attributes, we need an org.keycloak.models.jpa.<wbr>RealmAdapter. What&#39;s the best way to obtain it?</div><div><br></div><div>I&#39;ve yet come up with the following:</div><div><br></div><div>RealmModel realm = session.getContext().getRealm(<wbr>);</div><div>RealmAdapter adapter = (RealmAdapter) session.getProvider(<wbr>RealmProvider.class).getRealm(<wbr>realm.getId());</div><div><div><div><br></div><div><br></div><blockquote type="cite"><div dir="ltr">Realm attributes should be perfect for that</div><div class="gmail_extra"><br><div class="gmail_quote">On 12 July 2016 at 13:42, Mitya <span dir="ltr">&lt;<a href="mailto:mitya@cargosoft.ru" target="_blank">mitya@cargosoft.ru</a>&gt;</span> wrote:<br><blockquote type="cite"><div><div>Hi,</div><div><br></div><div>I&#39;m developing a KeyCloak extension, and I want some custom (per-realm) parameters to be tuned via the GUI form. Speaking of the storage mechanism for my settings, are realm attributes suitable for that? or should I create a dedicated custom entity instead?</div><div><br></div><div>Thx,</div><div>Mitya</div></div><br>______________________________<wbr>_________________<br>
keycloak-dev mailing list<br>
<a href="mailto:keycloak-dev@lists.jboss.org" target="_blank">keycloak-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/keycloak-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/keycloak-dev</a><br></blockquote></div><br></div>
</blockquote></div></div></div><br></blockquote></div><br></div>
</blockquote></div></div></div><br></blockquote></div><br></div></div>
</blockquote></div></div></div></blockquote></div><br></div></div></div>