<s> import sys <EOL> from django . middleware . csrf import CsrfViewMiddleware <EOL> from djangorestframework . authentication import BaseAuthentication <EOL> from djangorestframework . views import View <EOL> from djangorestframework . permissions import IsAuthenticated <EOL> from ionyweb . administration . permissions import IsAdminUser , IsSuperAdminUser <EOL> from django . utils . crypto import constant_time_compare <EOL> class UserLoggedInAuthentication ( BaseAuthentication ) : <EOL> """<STR_LIT>""" <EOL> def authenticate ( self , request ) : <EOL> """<STR_LIT>""" <EOL> if getattr ( request , '<STR_LIT:user>' , None ) and request . user . is_active : <EOL> return request . user <EOL> return None <EOL> class IsLoggedInView ( View ) : <EOL> authentication = ( UserLoggedInAuthentication , ) <EOL> permissions = ( IsAuthenticated , ) <EOL> class IsAdminView ( IsLoggedInView ) : <EOL> permissions = ( IsAuthenticated , IsAdminUser ) <EOL> class IsSuperAdminView ( IsLoggedInView ) : <EOL> permissions = ( IsAuthenticated , IsSuperAdminUser ) </s>
