<?xml version="1.0" encoding="UTF-8" ?>
<rdf:RDF xmlns="http://usefulinc.com/ns/doap#" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><Project><name>iw.rejectanonymous</name>
<shortdesc>Disallow access to a folder and its children if user is anonymous</shortdesc>
<description>==========================
iw.rejectanonymous package
==========================

.. contents::

What is iw.rejectanonymous ?
============================

This package is made to reject unconditionnally anonymous users from a plone
site; they should get redirected by plone to login form. The basic use case is
an extranet, where all visitors must be authenticated.

How to use iw.rejectanonymous ?
===============================

By default an anonymous user can browse portal:

    &gt;&gt;&gt; portal_url = self.portal.absolute_url()
    &gt;&gt;&gt; browser.open(portal_url)
    &gt;&gt;&gt; browser.url == portal_url
    True
    &gt;&gt;&gt; browser.headers['status']
    '200 OK'

We mark the portal with IPrivateSite; this can be achieved by code or in the ZMI
using "Interfaces" tab on the portal object. Now Anonymous will get Unauthorized
exception. In a plone site this should results in a redirect to login form.

    &gt;&gt;&gt; from zope.interface import alsoProvides
    &gt;&gt;&gt; from iw.rejectanonymous import IPrivateSite
    &gt;&gt;&gt; alsoProvides(self.portal, IPrivateSite)
    &gt;&gt;&gt; browser.open(portal_url)
    Traceback (most recent call last):
    ...
    Unauthorized: ...

Login form and some styles ressources are still accessible:

    &gt;&gt;&gt; login_form_url = self.portal.login_form.absolute_url()
    &gt;&gt;&gt; browser.open(login_form_url)
    &gt;&gt;&gt; browser.url == login_form_url
    True
    &gt;&gt;&gt; require_login_url = self.portal.require_login.absolute_url()
    &gt;&gt;&gt; browser.open(require_login_url)
    &gt;&gt;&gt; browser.url == require_login_url
    True
    &gt;&gt;&gt; cooked_css = self.portal.portal_css.getCookedResources()[0]
    &gt;&gt;&gt; cooked_css_url = '%s/portal_css/%s' % (portal_url, cooked_css.getId())
    &gt;&gt;&gt; browser.open(cooked_css_url)
    &gt;&gt;&gt; browser.url == cooked_css_url
    True
    &gt;&gt;&gt; cooked_js = self.portal.portal_javascripts.getCookedResources()[0]
    &gt;&gt;&gt; cooked_js_url = '%s/portal_javascripts/%s' % (portal_url, cooked_js.getId())
    &gt;&gt;&gt; browser.open(cooked_js_url)
    &gt;&gt;&gt; browser.url == cooked_js_url
    True
    &gt;&gt;&gt; logo_id = self.portal.base_properties.getProperty('logoName')
    &gt;&gt;&gt; logo_url = self.portal[logo_id].absolute_url()
    &gt;&gt;&gt; browser.open(logo_url)
    &gt;&gt;&gt; browser.url == logo_url
    True

Then we log in, and we will be authorized to browse the portal

    &gt;&gt;&gt; from Products.PloneTestCase.setup import default_user, default_password
    &gt;&gt;&gt; browser.addHeader('Authorization',
    ...                   'Basic %s:%s' % (default_user, default_password))
    &gt;&gt;&gt; browser.open(portal_url)
    &gt;&gt;&gt; browser.url == portal_url
    True
    &gt;&gt;&gt; browser.headers['status']
    '200 OK'</description>
<homepage rdf:resource="http://ingeniweb.svn.sourceforge.net/svnroot/ingeniweb/iw.rejectanonymous" />
<maintainer><foaf:Person><foaf:name>Ingeniweb</foaf:name>
<foaf:mbox_sha1sum>ce647768fc2915c7851be5591bf96a90966761ef</foaf:mbox_sha1sum></foaf:Person></maintainer>
<release><Version><revision>1.0.0</revision></Version></release>
</Project></rdf:RDF>