<?xml version="1.0"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>CKAN: Ticket #1001: API should use normal user credentials if available</title>
    <link>http://localhost/ticket/1001</link>
    <description>&lt;p&gt;
When using the API 'locally' i.e. from the CKAN instance (as would be the case with an ajax interface) the API, especially that allowing READ requests should use the normal user credentials if they are available prior to looking for an API key.
&lt;/p&gt;
&lt;p&gt;
The key change appears to be to change _get_user_for_apikey method in lib/base.py &lt;a class="missing wiki"&gt;BaseController?&lt;/a&gt; to check the c.user attribute (may wish to rename as the name may now be a bit misleading ...).
&lt;/p&gt;
&lt;p&gt;
This is critical to incorporating any ajax editing into the frontend.
&lt;/p&gt;
&lt;p&gt;
As part of this ticket we should do a general consolidation of the identification system in lib/base.py so that both api_key and normal user auth lead to the same set of auth-related objects being available (suggest c.user and c.userobj and c.author).
&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/1001</link>
    </image>
    <generator>Trac 0.12.3</generator>
    <item>
      
        <dc:creator>rgrp</dc:creator>

      <pubDate>Mon, 28 Feb 2011 10:35:05 GMT</pubDate>
      <title>milestone changed</title>
      <link>http://localhost/ticket/1001#comment:1</link>
      <guid isPermaLink="false">http://localhost/ticket/1001#comment:1</guid>
      <description>
          &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;milestone&lt;/strong&gt;
                changed from &lt;em&gt;ckan-v1.4-sprint-2&lt;/em&gt; to &lt;em&gt;ckan-v1.4-sprint-3&lt;/em&gt;
            &lt;/li&gt;
          &lt;/ul&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>rgrp</dc:creator>

      <pubDate>Thu, 17 Mar 2011 10:58:29 GMT</pubDate>
      <title>description changed; repo, theme set</title>
      <link>http://localhost/ticket/1001#comment:2</link>
      <guid isPermaLink="false">http://localhost/ticket/1001#comment:2</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;description&lt;/strong&gt;
              modified (&lt;a href="/ticket/1001?action=diff&amp;amp;version=2"&gt;diff&lt;/a&gt;)
            &lt;/li&gt;
          &lt;/ul&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>thejimmyg</dc:creator>

      <pubDate>Thu, 17 Mar 2011 13:12:35 GMT</pubDate>
      <title></title>
      <link>http://localhost/ticket/1001#comment:3</link>
      <guid isPermaLink="false">http://localhost/ticket/1001#comment:3</guid>
      <description>
        &lt;p&gt;
Yes, I think the two should be consolidated, but as was noted elsewhere (I think) we don't want the API to ever be authenticated via a cookie, otherwise we open ourselves to CSRF attacks. Instead we could support the API key as a query parameter as an alternative to via the HTTP header if it is hard to set an HTTP header in JS libraries?
&lt;/p&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>pudo</dc:creator>

      <pubDate>Sun, 20 Mar 2011 12:58:08 GMT</pubDate>
      <title></title>
      <link>http://localhost/ticket/1001#comment:4</link>
      <guid isPermaLink="false">http://localhost/ticket/1001#comment:4</guid>
      <description>
        &lt;p&gt;
My vote on this would be to enable "httpbasic" auth via repoze.who and to add an API key challenger to ckan/lib/authenticator.py that accepts API keys, from within repoze.who. This way we won't have to work around the framework at all and can retain compatibility to the existing mechanisms.
&lt;/p&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>rgrp</dc:creator>

      <pubDate>Mon, 21 Mar 2011 10:36:19 GMT</pubDate>
      <title>milestone changed</title>
      <link>http://localhost/ticket/1001#comment:5</link>
      <guid isPermaLink="false">http://localhost/ticket/1001#comment:5</guid>
      <description>
          &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;milestone&lt;/strong&gt;
                changed from &lt;em&gt;ckan-v1.4-sprint-3&lt;/em&gt; to &lt;em&gt;ckan-v1.4-sprint-4&lt;/em&gt;
            &lt;/li&gt;
          &lt;/ul&gt;
        &lt;p&gt;
First work in cset:6b8cbe465b61
&lt;/p&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>pudo</dc:creator>

      <pubDate>Mon, 21 Mar 2011 10:44:09 GMT</pubDate>
      <title></title>
      <link>http://localhost/ticket/1001#comment:6</link>
      <guid isPermaLink="false">http://localhost/ticket/1001#comment:6</guid>
      <description>
        &lt;p&gt;
Wrote a WDMMG version of this yesterday: &lt;a class="ext-link" href="https://bitbucket.org/okfn/wdmmg/changeset/398ce0eb3901#chg-wdmmg/lib/authenticator.py"&gt;&lt;span class="icon"&gt;​&lt;/span&gt;https://bitbucket.org/okfn/wdmmg/changeset/398ce0eb3901#chg-wdmmg/lib/authenticator.py&lt;/a&gt;
&lt;/p&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>rgrp</dc:creator>

      <pubDate>Sun, 27 Mar 2011 12:31:22 GMT</pubDate>
      <title>status changed; resolution set</title>
      <link>http://localhost/ticket/1001#comment:7</link>
      <guid isPermaLink="false">http://localhost/ticket/1001#comment:7</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;/ul&gt;
        &lt;p&gt;
Completed and merged into default in cset:cb200f339dbb. At the moment have done the very simple option but pudo's approach seems better and we could refactor towards that going forward.
&lt;/p&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>dread</dc:creator>

      <pubDate>Mon, 28 Mar 2011 10:23:34 GMT</pubDate>
      <title>status changed; resolution deleted</title>
      <link>http://localhost/ticket/1001#comment:8</link>
      <guid isPermaLink="false">http://localhost/ticket/1001#comment:8</guid>
      <description>
          &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;status&lt;/strong&gt;
                changed from &lt;em&gt;closed&lt;/em&gt; to &lt;em&gt;reopened&lt;/em&gt;
            &lt;/li&gt;
            &lt;li&gt;&lt;strong&gt;resolution&lt;/strong&gt;
                &lt;em&gt;fixed&lt;/em&gt; deleted
            &lt;/li&gt;
          &lt;/ul&gt;
        &lt;p&gt;
You mentioned writing tests? Also the CSRF question from James hasn't been addressed.
&lt;/p&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>rgrp</dc:creator>

      <pubDate>Mon, 28 Mar 2011 11:05:51 GMT</pubDate>
      <title>status changed; resolution set</title>
      <link>http://localhost/ticket/1001#comment:9</link>
      <guid isPermaLink="false">http://localhost/ticket/1001#comment:9</guid>
      <description>
          &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;status&lt;/strong&gt;
                changed from &lt;em&gt;reopened&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;/ul&gt;
        &lt;p&gt;
This ticket did not include CSRF matters - please raise in a separate ticket if you wish. I looked in some detail at the testing options and nothing seemed simple to do that didn't duplicate code we already have (since no way to access the base controller halfway through a request). This can be tested as necessary as part of the development of the new js work.
&lt;/p&gt;
      </description>
      <category>Ticket</category>
    </item>
 </channel>
</rss>