<?xml version="1.0"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>CKAN: Ticket #787: Auth API</title>
    <link>http://localhost/ticket/787</link>
    <description>&lt;p&gt;
Auth Proposal
&lt;/p&gt;
&lt;p&gt;
Use case: We'd like an authenticated and authorized Drupal user to be able to
edit/delete packages using the API
&lt;/p&gt;
&lt;p&gt;
To do this a user would need a CKAN API key so we need some way of Drupal
telling CKAN who a user is so that they can get their API key.
&lt;/p&gt;
&lt;p&gt;
Proposed Implementation
&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;
A user visits the CKAN API key page to get their key. Because CKAN is at
catalogue.data.gov.uk (a subdomain of the Drupal site) it can read Drupal
cookies.
&lt;/p&gt;
&lt;p&gt;
If there is no &lt;tt&gt;&lt;/tt&gt;DRXtrArgs&lt;tt&gt;&lt;/tt&gt; or &lt;tt&gt;&lt;/tt&gt;DRXtrArgs2&lt;tt&gt;&lt;/tt&gt; cookie, we know the user isn't
signed in so we redirect them to Drupal to sign in.
&lt;/p&gt;
&lt;p&gt;
WISHLIST: It would be really nice if we could pass the URL to redirect back to
Drupal so tha Druapl can send them back to the CKAN API key page
&lt;/p&gt;
&lt;p&gt;
Either way, they get back to CKAN and now the cookies exist. When the first
HTTP request header is sent, CKAN will read the Drupal session ID and then call
a Drupal API, server to server.
&lt;/p&gt;
&lt;p&gt;
TODO: Implement an API on the drupal server which accepts a Drupal session ID
as an argument and returns the username and credentials, but only if the
request if from the CKAN server (perhaps we specify an API key in the request)
&lt;/p&gt;
&lt;p&gt;
If the session is valid CKAN will set its own auth cookie and show them the
page with the API key. CKAN only considers a user signed in if both the CKAN
cookie *and* Drupal session ID are present. If at any time they sign out of
Drupal the Drupal session disappears so they will be signed out of CKAN too.
&lt;/p&gt;
&lt;p&gt;
Now the user has an API key they can use the standard CKAN command line API
tools.
&lt;/p&gt;
&lt;p&gt;
The API key is the only thing the user will need to use the CKAN API. This
poses a problem. What if a user is removed from Drupal but still has a CKAN API
key?
&lt;/p&gt;
&lt;p&gt;
Two solutions:
&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;API keys will be set to only be valid for the length of a Drupal session so
that a user will only be able to use the write API for a little time after
credentials are revoked
&lt;/li&gt;&lt;/ol&gt;&lt;ol start="2"&gt;&lt;li&gt;CKAN provides an API to allow Drupal to revoke keys
&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;
Option 1. seems easier to me. If we choose this we will write a &lt;tt&gt;&lt;/tt&gt;get_api_key&lt;tt&gt;&lt;/tt&gt;
command line tool so that Drupal user can write things like this:
&lt;/p&gt;
&lt;p&gt;
::
&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;
datapkg list_packages --api_key &lt;tt&gt;get_api_key&lt;/tt&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
The &lt;tt&gt;&lt;/tt&gt;get_api_key&lt;tt&gt;&lt;/tt&gt; function will prompt for username and password and then
perform the steps necessary to get an API key.
&lt;/p&gt;
</description>
    <language>en-us</language>
    <image>
      <title>CKAN</title>
      <url>http://assets.okfn.org/p/ckan/img/ckan_logo_shortname.png</url>
      <link>http://localhost/ticket/787</link>
    </image>
    <generator>Trac 0.12.3</generator>
    <item>
      
        <dc:creator>pudo</dc:creator>

      <pubDate>Tue, 09 Nov 2010 09:33:27 GMT</pubDate>
      <title></title>
      <link>http://localhost/ticket/787#comment:1</link>
      <guid isPermaLink="false">http://localhost/ticket/787#comment:1</guid>
      <description>
        &lt;p&gt;
Alternative:
&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;The Drupal system will expose a resource at data.gov.uk/profile which wil contain the reqesting user's nickname, fullname, email etc. in JSON (or XML) form.
&lt;/li&gt;&lt;li&gt;The Drupal system will also run an OAuth server (and provide /request_token, /access_token, /authorize).
&lt;/li&gt;&lt;li&gt;CKAN's login form will be rewired to initiate a client OAuth request on the /profile resource.
&lt;/li&gt;&lt;li&gt;Recognizing CKAN's callback URL at catalogue.data.gov.uk, Drupal will automatically grant the request if a user is signed in.
&lt;/li&gt;&lt;li&gt;Upon return, a user is created, optionally using the OAuth access token as the users API key, thus making it known both to Drupal and CKAN.
&lt;/li&gt;&lt;li&gt;The authorizer will be extended to check access to the /profile resource for OAuth accounts (slow but safe).
&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;
Advantages:
&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Well-known protocol, does not depend on cookies (which are strange and never behave as defined, or even the same in multiple browsers)
&lt;/li&gt;&lt;li&gt;Python code is available: &lt;a class="ext-link" href="http://oauth.googlecode.com/svn/code/python/oauth/example"&gt;&lt;span class="icon"&gt;​&lt;/span&gt;http://oauth.googlecode.com/svn/code/python/oauth/example&lt;/a&gt;
&lt;/li&gt;&lt;li&gt;Drupal seems to have very complete support: &lt;a class="ext-link" href="http://drupal.org/node/296205"&gt;&lt;span class="icon"&gt;​&lt;/span&gt;http://drupal.org/node/296205&lt;/a&gt;
&lt;/li&gt;&lt;li&gt;Can be fully implemented as a plugin, using an OAuthClientController for callback and adding hooks to the Authorizer (perhaps need to reconfigure who.ini)
&lt;/li&gt;&lt;/ul&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>johnbywater</dc:creator>

      <pubDate>Mon, 15 Nov 2010 10:07:38 GMT</pubDate>
      <title>sprint changed</title>
      <link>http://localhost/ticket/787#comment:2</link>
      <guid isPermaLink="false">http://localhost/ticket/787#comment:2</guid>
      <description>
          &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;sprint&lt;/strong&gt;
                changed from &lt;em&gt;1.3.3&lt;/em&gt; to &lt;em&gt;1.3.4&lt;/em&gt;
            &lt;/li&gt;
          &lt;/ul&gt;
        &lt;p&gt;
Moved from sprint 1.3.3
&lt;/p&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>thejimmyg</dc:creator>

      <pubDate>Fri, 07 Jan 2011 16:32:46 GMT</pubDate>
      <title>milestone changed; priority, component set</title>
      <link>http://localhost/ticket/787#comment:3</link>
      <guid isPermaLink="false">http://localhost/ticket/787#comment:3</guid>
      <description>
          &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;priority&lt;/strong&gt;
                set to &lt;em&gt;major&lt;/em&gt;
            &lt;/li&gt;
            &lt;li&gt;&lt;strong&gt;component&lt;/strong&gt;
                set to &lt;em&gt;dgu&lt;/em&gt;
            &lt;/li&gt;
            &lt;li&gt;&lt;strong&gt;milestone&lt;/strong&gt;
                changed from &lt;em&gt;ckan-v1.3&lt;/em&gt; to &lt;em&gt;longterm&lt;/em&gt;
            &lt;/li&gt;
          &lt;/ul&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>thejimmyg</dc:creator>

      <pubDate>Mon, 28 Mar 2011 09:47:47 GMT</pubDate>
      <title>milestone changed; repo, theme set</title>
      <link>http://localhost/ticket/787#comment:4</link>
      <guid isPermaLink="false">http://localhost/ticket/787#comment:4</guid>
      <description>
          &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;repo&lt;/strong&gt;
                set to &lt;em&gt;ckan&lt;/em&gt;
            &lt;/li&gt;
            &lt;li&gt;&lt;strong&gt;theme&lt;/strong&gt;
                set to &lt;em&gt;none&lt;/em&gt;
            &lt;/li&gt;
            &lt;li&gt;&lt;strong&gt;milestone&lt;/strong&gt;
                changed from &lt;em&gt;longterm&lt;/em&gt; to &lt;em&gt;ckan-v1.4-sprint-5&lt;/em&gt;
            &lt;/li&gt;
          &lt;/ul&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>thejimmyg</dc:creator>

      <pubDate>Mon, 18 Apr 2011 09:14:14 GMT</pubDate>
      <title></title>
      <link>http://localhost/ticket/787#comment:5</link>
      <guid isPermaLink="false">http://localhost/ticket/787#comment:5</guid>
      <description>
        &lt;p&gt;
The AuthAPI now exists as an IMiddleware plugin, we really need the permission system moved into CKAN before it is useful though and this depends on a refactor of the Auth system. See &lt;a class="closed ticket" href="http://localhost/ticket/1094" title="enhancement: [super] Refactor the Auth System (closed: duplicate)"&gt;#1094&lt;/a&gt;
&lt;/p&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>thejimmyg</dc:creator>

      <pubDate>Mon, 18 Apr 2011 09:14:43 GMT</pubDate>
      <title>milestone changed</title>
      <link>http://localhost/ticket/787#comment:6</link>
      <guid isPermaLink="false">http://localhost/ticket/787#comment:6</guid>
      <description>
          &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;milestone&lt;/strong&gt;
                changed from &lt;em&gt;ckan-v1.4-sprint-5&lt;/em&gt; to &lt;em&gt;ckan-v1.4-sprint-6&lt;/em&gt;
            &lt;/li&gt;
          &lt;/ul&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>shevski</dc:creator>

      <pubDate>Fri, 08 Jul 2011 12:00:48 GMT</pubDate>
      <title>milestone changed</title>
      <link>http://localhost/ticket/787#comment:7</link>
      <guid isPermaLink="false">http://localhost/ticket/787#comment:7</guid>
      <description>
          &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;milestone&lt;/strong&gt;
                changed from &lt;em&gt;ckan-v1.5&lt;/em&gt; to &lt;em&gt;ckan-current-sprint&lt;/em&gt;
            &lt;/li&gt;
          &lt;/ul&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>kindly</dc:creator>

      <pubDate>Mon, 15 Aug 2011 09:23:03 GMT</pubDate>
      <title>keywords set</title>
      <link>http://localhost/ticket/787#comment:8</link>
      <guid isPermaLink="false">http://localhost/ticket/787#comment:8</guid>
      <description>
          &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;keywords&lt;/strong&gt;
              &lt;em&gt;dgu&lt;/em&gt; added
            &lt;/li&gt;
          &lt;/ul&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>thejimmyg</dc:creator>

      <pubDate>Mon, 12 Sep 2011 09:51:58 GMT</pubDate>
      <title>status, milestone changed; resolution set</title>
      <link>http://localhost/ticket/787#comment:9</link>
      <guid isPermaLink="false">http://localhost/ticket/787#comment:9</guid>
      <description>
          &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;status&lt;/strong&gt;
                changed from &lt;em&gt;new&lt;/em&gt; to &lt;em&gt;closed&lt;/em&gt;
            &lt;/li&gt;
            &lt;li&gt;&lt;strong&gt;resolution&lt;/strong&gt;
                set to &lt;em&gt;fixed&lt;/em&gt;
            &lt;/li&gt;
            &lt;li&gt;&lt;strong&gt;milestone&lt;/strong&gt;
                changed from &lt;em&gt;ckan-current-sprint&lt;/em&gt; to &lt;em&gt;ckan-sprint-2011-09-12&lt;/em&gt;
            &lt;/li&gt;
          &lt;/ul&gt;
        &lt;p&gt;
The joint authentication was implemented a long time ago and is deployed on catalogue.data.gov.uk. We'll build the authorisation layer in ticket &lt;a class="new ticket" href="http://localhost/ticket/1326" title="enhancement: Write a set of auth plugin functions to integrate with Druapl (new)"&gt;#1326&lt;/a&gt; so marking this as fixed.
&lt;/p&gt;
      </description>
      <category>Ticket</category>
    </item>
 </channel>
</rss>