41 lines
1 KiB
Python
41 lines
1 KiB
Python
# -*- coding: iso-8859-1 -*-
|
|
"""
|
|
MoinMoin - CAS authentication
|
|
|
|
Jasig CAS (see http://www.jasig.org/cas) authentication module.
|
|
|
|
@copyright: 2012 MoinMoin:RichardLiao
|
|
@license: GNU GPL, see COPYING for details.
|
|
"""
|
|
|
|
import sys
|
|
import os
|
|
import time, re
|
|
import urlparse
|
|
import urllib, urllib2
|
|
from netaddr import IPNetwork, IPAddress
|
|
|
|
from MoinMoin import log
|
|
logging = log.getLogger(__name__)
|
|
|
|
from MoinMoin.auth import BaseAuth
|
|
from MoinMoin import user, wikiutil
|
|
from MoinMoin.Page import Page
|
|
from anonymous_user import AnonymousAuth
|
|
|
|
class PublicCategories(AnonymousAuth):
|
|
name = 'PublicCategories'
|
|
|
|
def __init__(self, pub_cats=[], auth_username="Connexion"):
|
|
AnonymousAuth.__init__(self, auth_username=auth_username)
|
|
self.pub_cats=pub_cats
|
|
|
|
def can_view(self, request):
|
|
p = urlparse.urlparse(request.url)
|
|
categories = Page(request, p.path[1:]).getCategories(request)
|
|
|
|
for cat in self.pub_cats:
|
|
if cat in categories:
|
|
return True
|
|
return False
|
|
|