<div dir="ltr">From your original email, it sounds like you want to extend the existing LDAP identity driver implementation, rather than writing a custom driver from scratch, which is what you've written. The TemplatedCatalog driver sort of follows that pattern with the KVS catalog driver, although it's not a spectacular example.</div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jan 27, 2014 at 9:11 PM, Simon Perfer <span dir="ltr"><<a href="mailto:simon.perfer@hotmail.com" target="_blank">simon.perfer@hotmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div dir="ltr">I dug a bit more and found this in the logs:<div><br></div><div>
<p>(keystone.common.wsgi): 2014-01-27 19:07:13,851 WARNING The action you have requested has not been implemented.</p><p><br></p><p>Despite basing my (super simple) code on the SQL or LDAP backends, I must be doing something wrong.</p>
<p><br></p><p>-->> I've placed my backend code in <span style="font-size:12pt">/usr/share/pyshared/keystone/identity/backends/nicira.py or </span><span style="font-size:12pt">/usr/share/pyshared/keystone/common/nicira.py</span></p>
<p><span style="font-size:12pt"><br></span></p><p><span style="font-size:12pt">-->> I DO see the "my authenticate module loaded" in the log</span></p><p><span style="font-size:12pt"><br></span></p><p>I would appreciate any help in figuring out what I'm missing. Thanks!</p>
<p><br></p><div class="hm HOEnZb">
<br></div><div><div class="hm HOEnZb"><hr>From: <a href="mailto:simon.perfer@hotmail.com" target="_blank">simon.perfer@hotmail.com</a><br>To: <a href="mailto:openstack-dev@lists.openstack.org" target="_blank">openstack-dev@lists.openstack.org</a><br>
Date: Mon, 27 Jan 2014 21:58:43 -0500</div><div><div class="h5"><br>Subject: Re: [openstack-dev] extending keystone identity<br><br>
<div dir="ltr">Dolph, I appreciate the response and pointing me in the right direction.<div><br></div><div>Here's what I have so far:</div><div><br></div><div><imports here></div><div>
<p><span style="font-size:12pt">CONF = config.CONF</span></p>
<p>LOG = logging.getLogger(__name__)</p>
<p><br></p>
<p>class Identity(identity.Driver):</p>
<p> def __init__(self):</p>
<p> super(Identity, self).__init__()</p>
<p> LOG.debug('My authentication module loaded')</p>
<p><br></p>
<p> def authenticate(self, user_id, password, domain_scope=None):</p>
<p> LOG.debug('in authenticate method')</p><p><br></p><p>When I request a user-list via the python-keystoneclient, we never make it into the authenticate method (as is evident by the missing debug log).</p>
<p><br></p><p>Any thoughts on why I'm not hitting this method?</p><p><br></p><br><div><hr>From: <a href="mailto:dolph.mathews@gmail.com" target="_blank">dolph.mathews@gmail.com</a><br>Date: Mon, 27 Jan 2014 18:14:50 -0600<br>
To: <a href="mailto:openstack-dev@lists.openstack.org" target="_blank">openstack-dev@lists.openstack.org</a><br>Subject: Re: [openstack-dev] extending keystone identity<br><br><div dir="ltr"><div>_check_password() is a private/internal API, so we make no guarantees about it's stability. Instead, override the public authenticate() method with something like this:</div>
<div><br></div><div> def authenticate(self, user_id, password, domain_scope=None):</div>
<div> if user_id in SPECIAL_LIST_OF_USERS:</div><div> # compare against value from keystone.conf</div><div> pass</div><div> else:</div><div> return super(CustomIdentityDriver, self).authenticate(user_id, password, domain_scope)</div>
<div><br><div>On Mon, Jan 27, 2014 at 3:27 PM, Simon Perfer <span dir="ltr"><<a href="mailto:simon.perfer@hotmail.com" target="_blank">simon.perfer@hotmail.com</a>></span> wrote:<br>
<blockquote style="border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div><div dir="ltr"><div><span style="font-size:12pt">I'm looking to create a simple Identity driver that will look at usernames. A small number of specific users should be authenticated by looking at a hard-coded password in keystone.conf, while any other users should fall back to LDAP authentication.</span></div>
<div><br></div><div>I based my original driver on what's found here:</div><div><br></div><div><a href="http://waipeng.wordpress.com/2013/09/30/openstack-ldap-authentication/" target="_blank">http://waipeng.wordpress.com/2013/09/30/openstack-ldap-authentication/</a></div>
<div><br></div><div>As can be seen in the github code (<a href="https://raw.github.com/waipeng/keystone/8c18917558bebbded0f9c588f08a84b0ea33d9ae/keystone/identity/backends/ldapauth.py" style="font-size:12pt" target="_blank">https://raw.github.com/waipeng/keystone/8c18917558bebbded0f9c588f08a84b0ea33d9ae/keystone/identity/backends/ldapauth.py</a>), there's a _check_password() method which is supposedly called at some point.</div>
<div><br></div><div>I've based my driver on this ldapauth.py file, and created an Identity class which subclasses sql.Identity. Here's what I have so far:</div><div><br></div><div>
CONF = config.CONF<br>LOG = logging.getLogger(__name__)<br><br><br>class Identity(sql.Identity):<br> def __init__(self):<br> super(Identity, self).__init__()<br> LOG.debug('My authentication module loaded')<br>
<br><br> def _check_password(self, password, user_ref):<br> LOG.debug('Authenticating via my custom hybrid authentication')<br><br><br> username = user_ref.get('name')<br>
<br> LOG.debug('Username = %s' % username)<br><br><br>I can see from the syslog output that we never enter the _check_password() function.<br></div><div><br></div><div>Can someone point me in the right direction regarding which function calls the identity driver? Also, what is the entry function in the identity drivers? Why wouldn't check_password() be called, as we see in the github / blog example above?</div>
<div><br></div><div>THANKS!</div> </div></div>
<br>_______________________________________________<br>
OpenStack-dev mailing list<br>
<a href="mailto:OpenStack-dev@lists.openstack.org" target="_blank">OpenStack-dev@lists.openstack.org</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
<br></blockquote></div><br></div></div>
<br>_______________________________________________
OpenStack-dev mailing list
<a href="mailto:OpenStack-dev@lists.openstack.org" target="_blank">OpenStack-dev@lists.openstack.org</a>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a></div></div> </div>
<br>_______________________________________________
OpenStack-dev mailing list
<a href="mailto:OpenStack-dev@lists.openstack.org" target="_blank">OpenStack-dev@lists.openstack.org</a>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a></div></div></div></div> </div></div>
<br>_______________________________________________<br>
OpenStack-dev mailing list<br>
<a href="mailto:OpenStack-dev@lists.openstack.org">OpenStack-dev@lists.openstack.org</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
<br></blockquote></div><br></div>