[Zope] set permission dependig from domain (workaround)

Marcus Bergmann zope@zope.org
Fri, 01 Mar 2002 15:47:36 +0100


Paul Browning wrote:
> 
> --On 28 February 2002 16:37 +0100 Marcus Bergmann
> <marcus.bergmann@isst.fhg.de> wrote:
> 
> > Hello,
> >
> > is it possible to set permissions, e.g. 'view', depending from the
> > surfers domain? I need to protect files and folders from viewing by
> > surfers outside our domains. I dont want a login screen!
> >
> > Any suggestions?
> 

After try and error with using the "domain authentication mode" without
success, I use this workaround for my special case.

For each file I want to publish I set the "Precondition" to
"checkDomain". This is a method what checks if the surfer comes from our
internal networks or from outside:

<dtml-let trusted_domains="['1.2.3','4.5.6','7.8.9']">	#not the real
domains :)
 <dtml-in trusted_domains>
  <dtml-let surfers_domain="_.string.join([_.string.split(REMOTE_ADDR,
'.')[0], _.string.split(REMOTE_ADDR, '.')[1], 
_.string.split(REMOTE_ADDR, '.')[2]], '.')">
   <dtml-if "surfers_domain == _['sequence-item']">
    <dtml-return "1">
   </dtml-if>
  </dtml-let>
 </dtml-in>
 <dtml-raise NotFound>Web Page Not Found</dtml-raise>
</dtml-let>


Thank you for helping me out :)
Marcus