<?xml version="1.0"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>CKAN: Ticket #1044: Sysadmins locked-out of API without Right: (visitor, SITE_READ, System)</title>
    <link>http://localhost/ticket/1044</link>
    <description>&lt;p&gt;
The problem is that in ckan/controllers/rest.py the &lt;a class="missing wiki"&gt;BaseApiController?&lt;/a&gt; has this method:
&lt;/p&gt;
&lt;pre class="wiki"&gt;    def __before__(self, action, **env):
        BaseController.__before__(self, action, **env)
        if not self.authorizer.am_authorized(c, model.Action.SITE_READ, model.System):
            abort(401, _('Not authorized to see this page'))
&lt;/pre&gt;&lt;p&gt;
which works on the basis of your c.user, rather than your apikey. All API users are treated as visitors (since API users don't get a login cookie) and even a sysadmin's apikey is blocked unless there is a right for a Visitor to SITE_READ.
&lt;/p&gt;
&lt;p&gt;
Also needs tests.
&lt;/p&gt;
&lt;p&gt;
(Also, why is this restriction only on the API, package search, group index and tags and agroup index? I'm guessing SITE_READ is only for places where other authz don't apply, but maybe it should not be called 'SITE_READ' but 'OTHER_READ' or something?)
&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/1044</link>
    </image>
    <generator>Trac 0.12.3</generator>
    <item>
      
        <dc:creator>rgrp</dc:creator>

      <pubDate>Thu, 17 Mar 2011 10:59:22 GMT</pubDate>
      <title></title>
      <link>http://localhost/ticket/1044#comment:1</link>
      <guid isPermaLink="false">http://localhost/ticket/1044#comment:1</guid>
      <description>
        &lt;p&gt;
Think this would be resolved by refactoring implied in &lt;a class="closed ticket" href="http://localhost/ticket/1001" title="enhancement: API should use normal user credentials if available (closed: fixed)"&gt;ticket:1001&lt;/a&gt; (specifically checks for api key and remote user should lead to availability of same set of identification information).
&lt;/p&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>dread</dc:creator>

      <pubDate>Thu, 17 Mar 2011 17:19:27 GMT</pubDate>
      <title>cc set</title>
      <link>http://localhost/ticket/1044#comment:2</link>
      <guid isPermaLink="false">http://localhost/ticket/1044#comment:2</guid>
      <description>
          &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;cc&lt;/strong&gt;
              &lt;em&gt;pudo&lt;/em&gt; added
            &lt;/li&gt;
          &lt;/ul&gt;
        &lt;p&gt;
I agree with leaving &lt;a class="closed ticket" href="http://localhost/ticket/1001" title="enhancement: API should use normal user credentials if available (closed: fixed)"&gt;#1001&lt;/a&gt; solving this issue. Centralising this is good. This ticket can instead focus on:
&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;returning the correct 403 error (rather than the 302 currently)
&lt;/li&gt;&lt;li&gt;creating some tests
&lt;/li&gt;&lt;li&gt;documenting
&lt;/li&gt;&lt;li&gt;consider renaming the SITE_READ variable and rethinking purpose
&lt;/li&gt;&lt;/ul&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>dread</dc:creator>

      <pubDate>Fri, 18 Mar 2011 12:05:05 GMT</pubDate>
      <title>owner changed</title>
      <link>http://localhost/ticket/1044#comment:3</link>
      <guid isPermaLink="false">http://localhost/ticket/1044#comment:3</guid>
      <description>
          &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;owner&lt;/strong&gt;
              changed from &lt;em&gt;dread&lt;/em&gt; to &lt;em&gt;pudo&lt;/em&gt;
            &lt;/li&gt;
          &lt;/ul&gt;
        &lt;p&gt;
I've added in tests for SITE_READ and corrected the 403 response - see branch bug-1044-site-read.
&lt;/p&gt;
&lt;p&gt;
The tests have uncovered some inconsistencies in the use of SITE_READ between reading/editing a package in the Web interface vs the REST API. Friedrich, do you want to take a look at ckan/tests/functional/test_authz.py:TestSiteRead.test_pkggroupadmin_read for details and have a think about how this should best work. How about making SITE_READ more widespread in the WUI, to protect read/editing/searching things, in addition to the READ and EDIT &lt;a class="missing wiki"&gt;RoleActions?&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
Once that is decided, it should be pretty easy to refer to the tests and document SITE_READ.
&lt;/p&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>pudo</dc:creator>

      <pubDate>Sun, 20 Mar 2011 13:16:47 GMT</pubDate>
      <title></title>
      <link>http://localhost/ticket/1044#comment:4</link>
      <guid isPermaLink="false">http://localhost/ticket/1044#comment:4</guid>
      <description>
        &lt;p&gt;
David, thanks for writing those tests - perhaps we should combine them with the ones below ("&lt;a class="missing wiki"&gt;TestLockedDownUsage?&lt;/a&gt;") which attempt to basically do the same.
&lt;/p&gt;
&lt;p&gt;
As for the inconsistency introduced by the global check in the REST API you're right: Of course it is strange that WUI access checks are more granular than the API checks. The alternative is that we either move authz checks into all relevant REST places (a major refactoring I would be suspicious of) or that we introduce duplicate checks on the WUI actions (I actually have performance concerns about that, authz is incredibly slow - and it introduces another level of special authz that I think we really should not have). Given the choice I'd opt for the REST refactor - there is no good reason to make SITE_READ a duplicate check where authz already applies.
&lt;/p&gt;
&lt;p&gt;
On the other hand, this is a function we really don't want to enable or even have and that was only added to satisfy some very specific user demands. Given that these are fulfilled, I'm actually OK keeping the inconsistency for now - nobody will see it in normal operations and in a locked-down environment, users will need to have API keys anyway.
&lt;/p&gt;
&lt;p&gt;
Regarding the naming, I'm pretty opionion-less: SITE_READ was proposed by rgrp and I think its pretty fitting, while OTHER_READ would just confuse me. PUBLIC_READ might work, though.
&lt;/p&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>dread</dc:creator>

      <pubDate>Mon, 21 Mar 2011 12:57:03 GMT</pubDate>
      <title></title>
      <link>http://localhost/ticket/1044#comment:5</link>
      <guid isPermaLink="false">http://localhost/ticket/1044#comment:5</guid>
      <description>
        &lt;p&gt;
I'm happy to leave the inconsistencies in SITE_READ for now, since this will be resolved when authz is centralised between WUI and API in the dictization refactor.
&lt;/p&gt;
&lt;p&gt;
I'm also happy to leave both &lt;a class="missing wiki"&gt;TestSiteRead?&lt;/a&gt; and &lt;a class="missing wiki"&gt;TestLockedDownUsage?&lt;/a&gt; as they complement each other nicely actually.
&lt;/p&gt;
&lt;p&gt;
So I think all that remains for this ticket is to add a paragraph to the authz documentation about SITE_READ. Pudo would you mind doing this? It's well worth noting where it applies and where it doesn't.
&lt;/p&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>pudo</dc:creator>

      <pubDate>Mon, 28 Mar 2011 09:25:54 GMT</pubDate>
      <title>status changed; resolution set</title>
      <link>http://localhost/ticket/1044#comment:6</link>
      <guid isPermaLink="false">http://localhost/ticket/1044#comment:6</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;worksforme&lt;/em&gt;
            &lt;/li&gt;
          &lt;/ul&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>dread</dc:creator>

      <pubDate>Mon, 28 Mar 2011 09:34:31 GMT</pubDate>
      <title>status changed; resolution deleted</title>
      <link>http://localhost/ticket/1044#comment:7</link>
      <guid isPermaLink="false">http://localhost/ticket/1044#comment:7</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;worksforme&lt;/em&gt; deleted
            &lt;/li&gt;
          &lt;/ul&gt;
        &lt;p&gt;
I think all that remains for this ticket is to add a paragraph to the authz documentation about SITE_READ. Pudo would you mind doing this? It's well worth noting where it applies and where it doesn't.
&lt;/p&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>dread</dc:creator>

      <pubDate>Wed, 06 Apr 2011 13:22:35 GMT</pubDate>
      <title>status changed; resolution set</title>
      <link>http://localhost/ticket/1044#comment:8</link>
      <guid isPermaLink="false">http://localhost/ticket/1044#comment:8</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;
I've added in the docs for this in cset:013da53052d1 ready for release 1.3.3.
&lt;/p&gt;
      </description>
      <category>Ticket</category>
    </item>
 </channel>
</rss>