<div dir="ltr">nevermind. forgot to add the PasswordPolicySpi to the services file...<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Apr 29, 2016 at 2:48 PM, Roelof Naude <span dir="ltr">&lt;<a href="mailto:roelof.naude@gmail.com" target="_blank">roelof.naude@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">thank you, that helped.<br>
<br>
got the first round of changes done. some test cases are now failing.<br>
this is due to PasswordPolicy loading the PasswordPolicyProvider<br>
implementations. looks like the KeycloakSessionFactory::init was not<br>
called. factoriesMap is null.<br>
<br>
probably due to more setup / config needed. had a look at some of the<br>
provider tests (CustomIdentityProvider) but did not spot anything specific.<br>
<br>
do you have any hints?<br>
<span class=""><br>
On 04/29/2016 11:10 AM, Stian Thorgersen wrote:<br>
&gt; Pass in PasswordPolicy then. PasswordPolicy can store the config in the<br>
&gt; correct format. getInt(String provider) would parse string and store as<br>
&gt; an int in a map.<br>
&gt;<br>
&gt; This can be improved later, we&#39;re currently having a separate discussion<br>
&gt; about adding something like this. Ideally password policies would also<br>
&gt; support more advanced configuration like authenticators, mappers, etc<br>
&gt; already do. That on the other side is more work. If you want to do<br>
&gt; something like what they do that would be great though.<br>
&gt;<br>
&gt; On 29 April 2016 at 09:48, Roelof Naude &lt;<a href="mailto:roelof.naude@gmail.com">roelof.naude@gmail.com</a><br>
</span><span class="">&gt; &lt;mailto:<a href="mailto:roelof.naude@gmail.com">roelof.naude@gmail.com</a>&gt;&gt; wrote:<br>
&gt;<br>
&gt;     hi,<br>
&gt;<br>
&gt;     adding the config to the verify / validate method makes no sense.<br>
&gt;     take for instance HashIterations. it needs to keep the config for<br>
&gt;     later when the password encode takes place. PasswordPolicy::validate<br>
&gt;     is called after construction of the policies...at a time when the<br>
&gt;     configuration has been parsed already. re-parsing the config for<br>
&gt;     every validate can be expensive.<br>
&gt;<br>
&gt;     PasswordPolicyProvider implementations will most likely not access<br>
&gt;     external resources. granted, one cannot foresee all future usage<br>
&gt;     patterns either.<br>
&gt;<br>
&gt;     On 04/29/2016 07:58 AM, Stian Thorgersen wrote:<br>
&gt;<br>
&gt;         Simplest option is to simply add the config to the verify method.<br>
&gt;<br>
&gt;         We have some other SPIs that have more than one instance of a given<br>
&gt;         provider per-realm, but as you say they&#39;re not associated with the<br>
&gt;         session. This could cause them not to be closed, or to have multiple<br>
&gt;         instances with same config created per-session.<br>
&gt;<br>
&gt;         On 28 April 2016 at 15:37, Roelof Naude &lt;<a href="mailto:roelof.naude@gmail.com">roelof.naude@gmail.com</a><br>
&gt;         &lt;mailto:<a href="mailto:roelof.naude@gmail.com">roelof.naude@gmail.com</a>&gt;<br>
</span><div><div class="h5">&gt;         &lt;mailto:<a href="mailto:roelof.naude@gmail.com">roelof.naude@gmail.com</a> &lt;mailto:<a href="mailto:roelof.naude@gmail.com">roelof.naude@gmail.com</a>&gt;&gt;&gt;<br>
&gt;         wrote:<br>
&gt;<br>
&gt;              thank you. have made some headway with this.<br>
&gt;<br>
&gt;              there is a slight issue though. Providers are cached and<br>
&gt;         thus mostly<br>
&gt;              stateless.<br>
&gt;<br>
&gt;              password policies on the other hand are constructed<br>
&gt;         on-demand and<br>
&gt;              may contain configuration. this configuration can be different<br>
&gt;              between various realms, e.g. HashIterations could be 20 for<br>
&gt;         realm1<br>
&gt;              and 200 for realm2.<br>
&gt;<br>
&gt;              the current provider loading mechanisms caches both the<br>
&gt;         factory and<br>
&gt;              provider instances.<br>
&gt;<br>
&gt;              1. is there a session instance per realm? if so, then there<br>
&gt;         is no issue<br>
&gt;              2. if not, how do you propose creating policy instances per<br>
&gt;         realm?<br>
&gt;<br>
&gt;              PasswordPolicyFactory could expose an extra method,<br>
&gt;         create(String<br>
&gt;              arg), but the provider loading mechanism will ignore it.<br>
&gt;         one could<br>
&gt;              add specific knowledge of that method, but that feels wrong.<br>
&gt;<br>
&gt;              another option would be to teach KeycloakSession to return a<br>
&gt;              ProviderFactory instance. PasswordPolicy could call this<br>
&gt;         method to<br>
&gt;              create PasswordPolicyProvider instances on-demand. this<br>
&gt;         method would<br>
&gt;              delegate to the underlying KeycloakSessonFactory to lookup the<br>
&gt;              appropriate factory.<br>
&gt;<br>
&gt;              this last option could work. would prefer to clear it with<br>
&gt;         you guys<br>
&gt;              first though.<br>
&gt;<br>
&gt;              On 04/28/2016 07:51 AM, Stian Thorgersen wrote:<br>
&gt;<br>
&gt;                  First thing would be to create PasswordPolicySPI,<br>
&gt;                  PasswordPolicyProviderFactory<br>
&gt;                  and PasswordPolicyProvider. PasswordPolicyProvider<br>
&gt;         should have same<br>
&gt;                  methods as Policy. You&#39;d then have to extract all<br>
&gt;         built-in providers<br>
&gt;                  from PasswordPolicy into PasswordPolicyProvider<br>
&gt;         implementations,<br>
&gt;                  this<br>
&gt;                  should be relatively straightforward as they are<br>
&gt;         already &quot;id&quot; -&gt;<br>
&gt;                  implementation, just means you retrieve it with<br>
&gt;         KeycloakSession<br>
&gt;                  rather<br>
&gt;                  than hard-coded in PasswordPolicy. PasswordPolicy<br>
&gt;         should then be<br>
&gt;                  change<br>
&gt;                  to use KeycloakSession to retrieve<br>
&gt;         PasswordPolicyProvider instead of<br>
&gt;                  hard-coded Policy implementations.<br>
&gt;<br>
&gt;                  Next step would be admin console integration. At the<br>
&gt;         moment the<br>
&gt;                  list of<br>
&gt;                  policies is hard-coded it would need to get the list of<br>
&gt;         policies<br>
&gt;                  from<br>
&gt;                  server-info instead. There are other bits that use<br>
&gt;         server-info<br>
&gt;                  to list<br>
&gt;                  providers already so take a look at that. You would<br>
&gt;         probably<br>
&gt;                  also need<br>
&gt;                  to add a method to PasswordPolicyProvider to return a<br>
&gt;                  description of the<br>
&gt;                  policy for the admin console tooltips.<br>
&gt;<br>
&gt;                  On 25 April 2016 at 18:36, Roelof Naude<br>
&gt;         &lt;<a href="mailto:roelof.naude@gmail.com">roelof.naude@gmail.com</a> &lt;mailto:<a href="mailto:roelof.naude@gmail.com">roelof.naude@gmail.com</a>&gt;<br>
&gt;                  &lt;mailto:<a href="mailto:roelof.naude@gmail.com">roelof.naude@gmail.com</a><br>
&gt;         &lt;mailto:<a href="mailto:roelof.naude@gmail.com">roelof.naude@gmail.com</a>&gt;&gt;<br>
&gt;                  &lt;mailto:<a href="mailto:roelof.naude@gmail.com">roelof.naude@gmail.com</a><br>
&gt;         &lt;mailto:<a href="mailto:roelof.naude@gmail.com">roelof.naude@gmail.com</a>&gt; &lt;mailto:<a href="mailto:roelof.naude@gmail.com">roelof.naude@gmail.com</a><br>
&gt;         &lt;mailto:<a href="mailto:roelof.naude@gmail.com">roelof.naude@gmail.com</a>&gt;&gt;&gt;&gt;<br>
&gt;                  wrote:<br>
&gt;<br>
&gt;                       thank you all for the quick response.<br>
&gt;<br>
&gt;                       do you guys have a basic idea on how to approach<br>
&gt;         the policy<br>
&gt;                  spi? we<br>
&gt;                       are more than willing to help out to get it done.<br>
&gt;<br>
&gt;                       maintaining a fork is maybe an option to resolve the<br>
&gt;                  immediate need,<br>
&gt;                       but would prefer to keep things upstream as much<br>
&gt;         as possible.<br>
&gt;<br>
&gt;                       On Mon, Apr 25, 2016 at 5:30 PM, Stian Thorgersen<br>
&gt;                       &lt;<a href="mailto:sthorger@redhat.com">sthorger@redhat.com</a> &lt;mailto:<a href="mailto:sthorger@redhat.com">sthorger@redhat.com</a>&gt;<br>
&gt;         &lt;mailto:<a href="mailto:sthorger@redhat.com">sthorger@redhat.com</a> &lt;mailto:<a href="mailto:sthorger@redhat.com">sthorger@redhat.com</a>&gt;&gt;<br>
&gt;                  &lt;mailto:<a href="mailto:sthorger@redhat.com">sthorger@redhat.com</a><br>
&gt;         &lt;mailto:<a href="mailto:sthorger@redhat.com">sthorger@redhat.com</a>&gt; &lt;mailto:<a href="mailto:sthorger@redhat.com">sthorger@redhat.com</a><br>
&gt;         &lt;mailto:<a href="mailto:sthorger@redhat.com">sthorger@redhat.com</a>&gt;&gt;&gt;&gt; wrote:<br>
&gt;<br>
&gt;                           We an to introduce a password policy spi soon,<br>
&gt;         but for now<br>
&gt;                           you&#39;re stuck with the built-in policies.<br>
&gt;<br>
&gt;                           On 25 Apr 2016 16:43, &quot;Bruno Oliveira&quot;<br>
&gt;                  &lt;<a href="mailto:bruno@abstractj.org">bruno@abstractj.org</a> &lt;mailto:<a href="mailto:bruno@abstractj.org">bruno@abstractj.org</a>&gt;<br>
&gt;         &lt;mailto:<a href="mailto:bruno@abstractj.org">bruno@abstractj.org</a> &lt;mailto:<a href="mailto:bruno@abstractj.org">bruno@abstractj.org</a>&gt;&gt;<br>
&gt;                           &lt;mailto:<a href="mailto:bruno@abstractj.org">bruno@abstractj.org</a><br>
&gt;         &lt;mailto:<a href="mailto:bruno@abstractj.org">bruno@abstractj.org</a>&gt;<br>
&gt;<br>
&gt;                  &lt;mailto:<a href="mailto:bruno@abstractj.org">bruno@abstractj.org</a><br>
&gt;         &lt;mailto:<a href="mailto:bruno@abstractj.org">bruno@abstractj.org</a>&gt;&gt;&gt;&gt; wrote:<br>
&gt;<br>
&gt;                               I believe we don&#39;t have an SPI for this,<br>
&gt;         yet. See:<br>
&gt;         <a href="https://issues.jboss.org/browse/KEYCLOAK-2824" rel="noreferrer" target="_blank">https://issues.jboss.org/browse/KEYCLOAK-2824</a>.<br>
&gt;<br>
&gt;                               IMO, Argon2 is completely new and aside<br>
&gt;         from the<br>
&gt;                  bindings,<br>
&gt;                               we don&#39;t have<br>
&gt;                               a Java implementation, yet for this. I&#39;m<br>
&gt;         not sure<br>
&gt;                  if is a<br>
&gt;                               good idea to<br>
&gt;                               introduce C to the codebase, but totally<br>
&gt;         doable to<br>
&gt;                  have an<br>
&gt;                               SPI for<br>
&gt;                               policies.<br>
&gt;<br>
&gt;                               On 2016-04-25, Roelof Naude wrote:<br>
&gt;                                &gt; hi,<br>
&gt;                                &gt;<br>
&gt;                                &gt; a client has requested the use of the<br>
&gt;         argon2 [1, 2]<br>
&gt;                               password hashing<br>
&gt;                                &gt; scheme. this can easily be added as an<br>
&gt;         external<br>
&gt;                  provider.<br>
&gt;                               we do however<br>
&gt;                                &gt; require custom password policies, e.g.<br>
&gt;         memory /<br>
&gt;                               parallelism cost as well as<br>
&gt;                                &gt; salt length. AFAIK there is no way to<br>
&gt;         provide policy<br>
&gt;                               extensions using a<br>
&gt;                                &gt; provider interface?<br>
&gt;                                &gt;<br>
&gt;                                &gt; would argon2 be a worthwhile contribution?<br>
&gt;                                &gt;<br>
&gt;                                &gt; regards<br>
&gt;                                &gt; roelof.<br>
&gt;                                &gt;<br>
&gt;                                &gt; [1]<br>
&gt;         <a href="https://github.com/P-H-C/phc-winner-argon2" rel="noreferrer" target="_blank">https://github.com/P-H-C/phc-winner-argon2</a><br>
&gt;                                &gt; [2] <a href="https://github.com/phxql/argon2-jvm" rel="noreferrer" target="_blank">https://github.com/phxql/argon2-jvm</a><br>
&gt;<br>
&gt;                                &gt;<br>
&gt;         _______________________________________________<br>
&gt;                                &gt; keycloak-dev mailing list<br>
&gt;                                &gt; <a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a><br>
&gt;         &lt;mailto:<a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a>&gt;<br>
&gt;                  &lt;mailto:<a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a><br>
&gt;         &lt;mailto:<a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a>&gt;&gt;<br>
&gt;                               &lt;mailto:<a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a><br>
&gt;         &lt;mailto:<a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a>&gt;<br>
&gt;                  &lt;mailto:<a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a><br>
&gt;         &lt;mailto:<a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a>&gt;&gt;&gt;<br>
&gt;                                &gt;<br>
&gt;         <a href="https://lists.jboss.org/mailman/listinfo/keycloak-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-dev</a><br>
&gt;<br>
&gt;<br>
&gt;                               --<br>
&gt;<br>
&gt;                               abstractj<br>
&gt;                               PGP: 0x84DC9914<br>
&gt;<br>
&gt;           _______________________________________________<br>
&gt;                               keycloak-dev mailing list<br>
&gt;         <a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a><br>
&gt;         &lt;mailto:<a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a>&gt;<br>
&gt;         &lt;mailto:<a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a><br>
&gt;         &lt;mailto:<a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a>&gt;&gt;<br>
&gt;                               &lt;mailto:<a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a><br>
&gt;         &lt;mailto:<a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a>&gt;<br>
&gt;                  &lt;mailto:<a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a><br>
</div></div>&gt;         &lt;mailto:<a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a>&gt;&gt;&gt;<br>
&gt;         <a href="https://lists.jboss.org/mailman/listinfo/keycloak-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-dev</a><br>
<span class="">&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
_______________________________________________<br>
keycloak-dev mailing list<br>
<a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a><br>
</span><a href="https://lists.jboss.org/mailman/listinfo/keycloak-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-dev</a><br>
</blockquote></div><br></div>