FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Page permissions

 
Post new topic   Reply to topic    PyLucid - CMS - Forum Forum Index -> system
View previous topic :: View next topic  
Author Message
rantaaho



Joined: 09 Jan 2008
Posts: 47
Location: Kuopio, Finland

PostPosted: Mon 11 Feb, 2008 12:27    Post subject: Page permissions Reply with quote

Are there any plans for implementing page permissions, i.e. restrict access to page for some users or user groups?

Since Django doesn't support row level permissions, this has to be done in PyLucid. I think that it is not possible to implement permissions without changing Page-model.

I need permissions, and I can do some coding for it. But since it includes more than just writing a plugin, I would like to do it so, that it could be accepted to PyLucid codebase. Thus all suggestions and guidance are very wellcome.

My target is to restrict some of the pages to some user groups. Thus, I was planning to add to the Page-model a ManytoMany-relationship with Django groups. So that if a Page has some related groups, user has to belong at least one of them to see the page. Adding that check to page rendering and main_menu shouldn't be that hard, or?
Back to top
View user's profile Send private message
jens
Administrator


Joined: 12 Oct 2005
Posts: 972
Location: duisburg, germany

PostPosted: Mon 11 Feb, 2008 12:39    Post subject: Reply with quote

Yes, there exist no real page permissions.

You can edit the bool "PermitViewPublic" in the django panle under the TAB "Advanced options"... So you can limit the access to users how are logged-in.

There exist the Point "PermitViewGroup" and "PermitEditGroup"... But these Values aren't working. Its not complete implemented...

The Problem is: I don't need this features really. So i not work active on this stuff...

If you will implement a page permission systems, it's very welcome Wink But i think this is a Feature for v0.8.1 and not for v0.8, that i will release soon...
_________________

http://www.jensdiemer.de | http://www.htfx.de | http://www.python-forum.de
Back to top
View user's profile Send private message
rantaaho



Joined: 09 Jan 2008
Posts: 47
Location: Kuopio, Finland

PostPosted: Mon 11 Feb, 2008 14:47    Post subject: Reply with quote

Ok, I hadn't found PermitViewGroup et al.

I will check what I can do for permissions.
Back to top
View user's profile Send private message
jens
Administrator


Joined: 12 Oct 2005
Posts: 972
Location: duisburg, germany

PostPosted: Mon 11 Feb, 2008 15:51    Post subject: Reply with quote

The first Problem is, the view method must check the PermitViewGroup. But this is not implemented.

The "PermitViewGroup check" can be places in here:
http://trac.pylucid.net/browser/trunk/pylucid/PyLucid/system/detect_page.py#L66

I think this can be done in a few lines...
_________________

http://www.jensdiemer.de | http://www.htfx.de | http://www.python-forum.de
Back to top
View user's profile Send private message
rantaaho



Joined: 09 Jan 2008
Posts: 47
Location: Kuopio, Finland

PostPosted: Tue 12 Feb, 2008 12:18    Post subject: Reply with quote

Thanks for the pointer.

The obvious next questions are: which exception should it raise: AccessDeny, Http404, or should we have a separate Http401?
Where these exceptions are supposed to be handled? There doesn't seem to be code for that in index.py. For 404 and 500 the default seems to be Django.
Back to top
View user's profile Send private message
jens
Administrator


Joined: 12 Oct 2005
Posts: 972
Location: duisburg, germany

PostPosted: Tue 12 Feb, 2008 12:46    Post subject: Reply with quote

Very good question Wink

I don't known whitch the best choice... From http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html :
    401 Unauthorized
    403 Forbidden


btw. we have a own 404 and 500: http://trac.pylucid.net/browser/trunk/pylucid/PyLucid/templates_PyLucid

The other way: A redirect to the login page... But it's not implemented a way back to the page, after the login was successful...
_________________

http://www.jensdiemer.de | http://www.htfx.de | http://www.python-forum.de
Back to top
View user's profile Send private message
rantaaho



Joined: 09 Jan 2008
Posts: 47
Location: Kuopio, Finland

PostPosted: Tue 12 Feb, 2008 14:48    Post subject: Reply with quote

From RFC 2616:
Quote:
401 Unauthorized
The request requires user authentication.

Quote:
403 Forbidden
The server understood the request, but is refusing to fulfill it. Authorization will not help and the request SHOULD NOT be repeated.

So clearly 401.

I noticed templates for 404 and 500, but I got confused since they are not used when settings have DEBUG=True... But anyway, we need some other way to deal with permission denied exceptions.
Back to top
View user's profile Send private message
jens
Administrator


Joined: 12 Oct 2005
Posts: 972
Location: duisburg, germany

PostPosted: Tue 12 Feb, 2008 15:24    Post subject: Reply with quote

rantaaho wrote:
So clearly 401.

OK

rantaaho wrote:
I noticed templates for 404 and 500, but I probably have some misconfiguration with paths since they are not used...

Don't know whats going wrong...
_________________

http://www.jensdiemer.de | http://www.htfx.de | http://www.python-forum.de
Back to top
View user's profile Send private message
jens
Administrator


Joined: 12 Oct 2005
Posts: 972
Location: duisburg, germany

PostPosted: Sat 16 Feb, 2008 14:27    Post subject: Reply with quote

I have applied your Patch from ticket http://trac.pylucid.net/ticket/148 - Thanks!

But there is still something to do. Please look search for "FIXME" here: http://trac.pylucid.net/changeset/1416

And we need a unittest for this, see: http://trac.pylucid.net/ticket/149

btw. i like DocStrings Wink
_________________

http://www.jensdiemer.de | http://www.htfx.de | http://www.python-forum.de
Back to top
View user's profile Send private message
rantaaho



Joined: 09 Jan 2008
Posts: 47
Location: Kuopio, Finland

PostPosted: Tue 19 Feb, 2008 09:59    Post subject: Unittests Reply with quote

Thanks,

You were faster in fixing one of the FIXMEs.

I will write an unittest for permitViewPublic. But could you describe the unittest system of PyLucid little bit. It doesn't follow the standard Django system. The unittest's are under dev_scripts/unittests, right? Some other test scripts under dev_scripts/local_tests and something under pylucid/tests, what are these?

Is there somewhere a script to run all unittests? Shouldn't it be called pylucid/PyLucid/tests.py so that "django-admin.sh test" would work?
Back to top
View user's profile Send private message
jens
Administrator


Joined: 12 Oct 2005
Posts: 972
Location: duisburg, germany

PostPosted: Tue 19 Feb, 2008 13:01    Post subject: Re: Unittests Reply with quote

rantaaho wrote:
could you describe the unittest system of PyLucid


Yes, the current unittests are a little bit chaotic. I create a new page for this: http://www.pylucid.org/_goto/137/unittests/
_________________

http://www.jensdiemer.de | http://www.htfx.de | http://www.python-forum.de
Back to top
View user's profile Send private message
rantaaho



Joined: 09 Jan 2008
Posts: 47
Location: Kuopio, Finland

PostPosted: Tue 19 Feb, 2008 13:17    Post subject: Reply with quote

Ok, thanks.

Now it makes more sense.
Back to top
View user's profile Send private message
jens
Administrator


Joined: 12 Oct 2005
Posts: 972
Location: duisburg, germany

PostPosted: Wed 20 Feb, 2008 09:14    Post subject: Reply with quote

I have a new problem detected. I think its related to the changes here.

http://trac.pylucid.net/ticket/156
_________________

http://www.jensdiemer.de | http://www.htfx.de | http://www.python-forum.de
Back to top
View user's profile Send private message
jens
Administrator


Joined: 12 Oct 2005
Posts: 972
Location: duisburg, germany

PostPosted: Fri 22 Feb, 2008 16:00    Post subject: Reply with quote

I changed the "next_url" behavior:
Quote:
-On login: Redirect only, if "next_url" information exists. Otherwiese stay at the current page (ID in _command url).
-On logout: Ony redirect to the default page, if the current page not viewable for anonymous.

see: http://trac.pylucid.net/changeset/1439
_________________

http://www.jensdiemer.de | http://www.htfx.de | http://www.python-forum.de
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PyLucid - CMS - Forum Forum Index -> system All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

<< back to PyLucid CMS Homepage



Powered by phpBB © 2001, 2005 phpBB Group