<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
<link rel="self" type="application/atom+xml" href="https://forum.yubico.com/feed.php?f=5&amp;t=350" />

<title>Yubico Forum</title>
<subtitle>...visit our web-store at</subtitle>
<link href="https://forum.yubico.com/index.php" />
<updated>2009-07-10T19:16:51+01:00</updated>

<author><name><![CDATA[Yubico Forum]]></name></author>
<id>https://forum.yubico.com/feed.php?f=5&amp;t=350</id>
<entry>
<author><name><![CDATA[fortean]]></name></author>
<updated>2009-07-10T19:16:51+01:00</updated>
<published>2009-07-10T19:16:51+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=350&amp;p=1569#p1569</id>
<link href="https://forum.yubico.com/viewtopic.php?t=350&amp;p=1569#p1569"/>
<title type="html"><![CDATA[Re: Protecting standard webpages with your Yubikey]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=350&amp;p=1569#p1569"><![CDATA[
<div class="quotetitle">James wrote:</div><div class="quotecontent"><br />If your implementation is different than the &quot;mod_authn_yubikey&quot; Apache module discussed in <a href="http://forum.yubico.com/viewtopic.php?f=3&amp;t=176&amp;hilit=mod_authn_yubikey" class="postlink">this thread</a> and at <a href="http://mod_authn_yubikey.coffeecrew.org" class="postlink">this website</a>, I would be interested in how you did it. I think it's good to have more than one way to do something in the event one of of the techniques no longer works or is no longer maintained.<br /></div><br /><br />Thanks for the links, James. Well, I don't know about mod_authn_yubikey (yet), will check it out later. <br /><br />My method uses mod_auth_external. That module can be used to call an external program<br /><br />Caveat! Caveat!<br /><br />** WARNING: this is just a proof of concept, you need to consider carefully if you want to use this code<br />** WARNING: it involves running a setuid binary!<br />** WARNING: and a very crude session mechanism, that really needs improvement<br />** WARNING: calling an external program can be a real resource hog<br /><br />Having said that..<br /><br />To set mod-auth-external  up, I did something like this:<br /><br />$ wget <!-- m --><a class="postlink" href="http://mod-auth-external.googlecode.com/files/mod_auth_external-2.2.11.tar.gz">http://mod-auth-external.googlecode.com ... .11.tar.gz</a><!-- m --><br />$ tar xzf mod_auth_external-2.2.11.tar.gz <br />$ cd mod_auth_external-2.2.11<br />$ more INSTALL<br />$ apxs -c mod_auth_external.c <br />$ apxs -i -a mod_auth_external.la <br /><br />So, now I had a method to call an external program.  The external program is expected to read username and password from stdin, it<br />has to return true or false to indicate if the username / password combination was correct.<br /><br />As the yubikey software already comes with 'ykvalidate', I decided to write a little wrapper around it to do just that. However, ykvalidate will not authenticate others than yourself, unless you are root. I decided to change the source code of ykvalidate a bit so it would allow processes that run with the uid of the webserver to access entries of other users: made the program run setuid and made it check for the effective uid instead of the real uid).  Recompiled it, su-ed to 'apache', tried to ykvalidate root's yubikey - and it which worked fine. Then I wrote this wrapperscript&#058;<br /><br /><br /><div class="codetitle"><b>Code:</b></div><div class="codecontent">#!/bin/bash<br />read username<br />read yubikey<br /><br /># in minutes, maximum inactive time<br />MAXINACTIVE=2<br /><br /># config<br />SESSIONS=/etc/yubikey.d/sessions<br /><br /># sanity<br />&#91; -z &quot;$username&quot; &#93; &amp;&amp; exit 1<br />&#91; -z &quot;$yubikey&quot; &#93; &amp;&amp; exit 1<br />&#91; ${#yubikey} -ne 44 &#93; &amp;&amp; exit 1 <br />&#91; -d $SESSIONS &#93; || exit 1<br /><br />status=1;<br /><br />if &#91; -f $SESSIONS/$yubikey &#93; <br />then<br /><br />  # continuation of earlier session<br />  atim=$(stat -c '%X' $SESSIONS/$yubikey)<br />  wtim=$(date +%s)<br />  asec=$&#91; ( $wtim - $atim ) / 60 &#93;<br />  if &#91; $asec -gt $MAXINACTIVE &#93;<br />  then<br />     #echo &quot;session $yubikey is $asec minutes old, expired&quot; &gt;&gt;/tmp/hk.log<br />     # remove expired sessions<br />     rm $SESSIONS/$yubikey<br />     find $SESSIONS -type f -amin +$MAXINACTIVE -exec rm {} \;<br />     status=1<br />  else<br />     # refresh session<br />     #echo &quot;session $yubikey is $asec minutes old, refreshed&quot; &gt;&gt;/tmp/hk.log<br />     touch $SESSIONS/$yubikey<br />     status=0<br />  fi<br /><br />else<br />  # new session<br />  #echo &quot;session $yubikey is new&quot; &gt;&gt;/tmp/hk.log<br />  /usr/local/bin/ykvalidate --user $username $yubikey 2&gt;/dev/null 1&gt;&amp;2<br />  status=$?<br />  #echo &quot;session $yubikey status: $status&quot; &gt;&gt;/tmp/h<br />  &#91; $status -eq 0 &#93; &amp;&amp; touch $SESSIONS/$yubikey<br />fi<br /><br />exit $status<br /><br /></div><br /><br />(Note that the session mechanisme is quite crude, this still is a proof of concept, any improvements are welcomed).<br />(also note that I had to create the various directories and make them owned by apache).<br /><br />I changed the http configuration for the website to include these rules within it's virtualhost container:<br /><br /><div class="codetitle"><b>Code:</b></div><div class="codecontent">    AddExternalAuth yubikey /usr/local/bin/ykvalidate_wrapper<br />    SetExternalAuthMethod yubikey pipe<br />    &lt;Location /test&gt;<br />      AuthType Basic<br />      AuthName Requires_Yubikey<br />      AuthExternal yubikey<br />      require valid-user<br />    &lt;/Location&gt;<br /></div><br /><br />Next, I restarted my Apache, surfed to <!-- m --><a class="postlink" href="http://www.example.com/test">http://www.example.com/test</a><!-- m --> and the box popped up, I filled in username and pressed the yubikey button in the 'password' field. Works fine.  If you don't do anything for 2 minutes and surf to that same page again, you'll need to redo the authentication.<p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=682">fortean</a> — Fri Jul 10, 2009 7:16 pm</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[James]]></name></author>
<updated>2009-07-07T18:22:57+01:00</updated>
<published>2009-07-07T18:22:57+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=350&amp;p=1556#p1556</id>
<link href="https://forum.yubico.com/viewtopic.php?t=350&amp;p=1556#p1556"/>
<title type="html"><![CDATA[Re: Protecting standard webpages with your Yubikey]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=350&amp;p=1556#p1556"><![CDATA[
If your implementation is different than the &quot;mod_authn_yubikey&quot; Apache module discussed in <a href="http://forum.yubico.com/viewtopic.php?f=3&amp;t=176&amp;hilit=mod_authn_yubikey" class="postlink">this thread</a> and at <a href="http://mod_authn_yubikey.coffeecrew.org" class="postlink">this website</a>, I would be interested in how you did it. I think it's good to have more than one way to do something in the event one of of the techniques no longer works or is no longer maintained.<p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=87">James</a> — Tue Jul 07, 2009 6:22 pm</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[fortean]]></name></author>
<updated>2009-07-05T21:23:17+01:00</updated>
<published>2009-07-05T21:23:17+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=350&amp;p=1555#p1555</id>
<link href="https://forum.yubico.com/viewtopic.php?t=350&amp;p=1555#p1555"/>
<title type="html"><![CDATA[Protecting standard webpages with your Yubikey]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=350&amp;p=1555#p1555"><![CDATA[
Hi, guys,<br /><br />y'all probably know how to configure Apache to protect arbitrary webpages with a password: add some directives in the httpd.conf (or in a .htaccess file) and add a password file with htpasswd. Next time you surf to that page, a popup appears, requiring you to enter your username and password. Works fine, and the big advantage here is that it even works with the simplest (HTML) webpages. <br /><br />But what if you'd want to use the Yubikey instead - and in OTP mode?<br /><br />I wanted to do something like this: <br /><br />- put some statements in an .htaccess file or Location/Directory container<br />- surf to the protected page<br />- the standard popup would appear<br />- I'd type in my username<br />- put the cursor in the 'password' field<br />- and press my Yubikey <br />- and have access (if the key was valid, of course).<br /><br />Well, I got it to work  <img src="https://forum.yubico.com/images/smilies/icon_cool.gif" alt="8-)" title="Cool" /> <br /><br />Just to make sure I did not reinvent wheels: is there anybody else here that figured out how to do this and has documented it? If not, I will try to compose a 'howto' next weekend (I have a very busy week ahead, so won't be able to do so this week).<p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=682">fortean</a> — Sun Jul 05, 2009 9:23 pm</p><hr />
]]></content>
</entry>
</feed>