Orkut Gmail Calendar Documents Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
No redirect when not enough credentials
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Cecil Westerhof  
View profile  
 More options Apr 24 2008, 6:07 pm
From: "Cecil Westerhof" <cldwester...@gmail.com>
Date: Thu, 24 Apr 2008 14:37:05 +0200
Local: Thurs, Apr 24 2008 6:07 pm
Subject: No redirect when not enough credentials

I have been playing with TG for two days now and I must say that untill now
I like it. ;-}

With the identity module you go to a login page when you do not have enough
credentials. Is it possible to make a difference between a user that is not
logged in (login page) and a logged in user that has not enough credentials
(entry denied)?

--
Cecil Westerhof


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Christopher Arndt  
View profile  
 More options Apr 24 2008, 8:14 pm
From: Christopher Arndt <chris.ar...@web.de>
Date: Thu, 24 Apr 2008 16:44:17 +0200
Local: Thurs, Apr 24 2008 8:14 pm
Subject: Re: No redirect when not enough credentials
Cecil Westerhof schrieb:

> I have been playing with TG for two days now and I must say that untill
> now I like it. ;-}

> With the identity module you go to a login page when you do not have
> enough credentials. Is it possible to make a difference between a user
> that is not logged in (login page) and a logged in user that has not
> enough credentials (entry denied)?

Yes, you can, but this is a feature of the identity framework that isn't
really documented well (i.e not at all ;-)).

You can set the configuration setting 'identity.failure_url' to a
callable, which will get evaluated every time an IdentityFailure
exception occurs. In this function you can then check

a) if the the user is anonymous (not logged in)
b) what the error message(s) of the IdentityFailure exception are

and then return different URLs depending on this info.

Example (untested):

def failure_url():
     if (identity.current.not_anonymous and
        'foo' in cherrypy.request.identity_errors):
        return url('/access_denied')
     return url('/login')

See the code for 'turbogears.identity.exceptions' (set_identity_errors,
IdentityFailure) and turbogears.identity.conditions (Predicate, require)
for particulars.

As a simpler, but less general alternative, you can test for the
required permissions *within* your controller method and then just do
the redirect yourself. If you are just redirecting to a "Access denied"
page, you probably don't need to care about retaining request parameters
across redirects.

Example (also untested):

class MyController(controllers.Controller, identity.SecureResource):
     @expose('bla')
     def bla(self):
         if not 'foo' in identity.current.permissions:
             if identity.current.not_anonymous:
                 redirect('/access_denied')
             raise identity.IdentityFailure

See also
http://docs.turbogears.org/1.0/UsingIdentity#explicit-permission-chec...

HTH, Chris


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Cecil Westerhof  
View profile  
 More options Apr 24 2008, 11:54 pm
From: "Cecil Westerhof" <cldwester...@gmail.com>
Date: Thu, 24 Apr 2008 20:24:52 +0200
Local: Thurs, Apr 24 2008 11:54 pm
Subject: Re: [TurboGears] Re: No redirect when not enough credentials

2008/4/24, Christopher Arndt <chris.ar...@web.de>:

> > I have been playing with TG for two days now and I must say that untill
> > now I like it. ;-}

> > With the identity module you go to a login page when you do not have
> > enough credentials. Is it possible to make a difference between a user
> > that is not logged in (login page) and a logged in user that has not
> > enough credentials (entry denied)?

> Yes, you can, but this is a feature of the identity framework that isn't
> really documented well (i.e not at all ;-)).

Thanks for the info.

--
Cecil Westerhof


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lukasz Szybalski  
View profile  
 More options Apr 25 2008, 12:28 am
From: "Lukasz Szybalski" <szybal...@gmail.com>
Date: Thu, 24 Apr 2008 13:58:58 -0500
Local: Fri, Apr 25 2008 12:28 am
Subject: Re: [TurboGears] Re: No redirect when not enough credentials

Hello Christopher,
Would be nice if what you wrote here was added to the .py file that
has the code.

http://lucasmanual.com/tgdocs/turbogears.identity.exceptions-pysrc.ht...

Just wondering, what is your / TG project preference when documenting
things like this. I'm sure you could copy what you wrote here in the
email and paste it to turbogears/identity/exceptions.py comment
section, and that would be painless.

Lucas


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Christopher Arndt  
View profile  
 More options Apr 25 2008, 2:37 am
From: Christopher Arndt <chris.ar...@web.de>
Date: Thu, 24 Apr 2008 23:07:51 +0200
Local: Fri, Apr 25 2008 2:37 am
Subject: Re: No redirect when not enough credentials
Lukasz Szybalski schrieb:

> On Thu, Apr 24, 2008 at 9:44 AM, Christopher Arndt <chris.ar...@web.de> wrote:
>>  Cecil Westerhof schrieb:
>>  > With the identity module you go to a login page when you do not have
>>  > enough credentials. Is it possible to make a difference between a user
>>  > that is not logged in (login page) and a logged in user that has not
>>  > enough credentials (entry denied)?

>>  Yes, you can, but this is a feature of the identity framework that isn't
>>  really documented well (i.e not at all ;-)).
> Would be nice if what you wrote here was added to the .py file that
> has the code.

> http://lucasmanual.com/tgdocs/turbogears.identity.exceptions-pysrc.ht...

I'll open a ticket so I dont forget this.

> Just wondering, what is your / TG project preference when documenting
> things like this. I'm sure you could copy what you wrote here in the
> email and paste it to turbogears/identity/exceptions.py comment
> section, and that would be painless.

I'm not sure if I understand your question? Are you suggesting I should
copy-and-paste what I wrote into a source ccode docstring? I think I
should test if it actually works first ;-)

Chris


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lukasz Szybalski  
View profile  
 More options Apr 25 2008, 2:45 am
From: "Lukasz Szybalski" <szybal...@gmail.com>
Date: Thu, 24 Apr 2008 16:15:23 -0500
Local: Fri, Apr 25 2008 2:45 am
Subject: Re: [TurboGears] Re: No redirect when not enough credentials

Yes. I think a lot of documentation is here on the list, and sometimes
if somebody with svn write access could copy and paste it into source
code docstring (after testing it ;) ) it can be automatically
generated via epydoc.

It would be cool if that was possible and done more often.(when time permits)

Just suggesting.
Lucas


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2010 Google