SQLFORM.grid and user_signature - unexpected behavior

66 views
Skip to first unread message

Tom Clerckx

unread,
May 10, 2021, 9:22:24 AM5/10/21
to web2py-users

I was running into some issue with SQLFORM.grid and after going through the code, I realized that the grid does not include request.vars when calculating the URL signature (ref: v2.21.1, gluon/sqlhtml.py @ 2440). 

Please correct me if I would be wrong,... else it may be useful to add something about this behavior in the web2py documentation:


SQLFORM.grid validates the signature without taking into account request.vars

As such, any constructed URL that contains a user_signature and that is pointing to the page that uses the controller function which creates this grid, should have this signature created without including request.vars! 

Thus, hash_vars should be set to False in that case. If not, you may get a ‘not authorized’ flash message and you will be redirected.

E.g. a signed URL pointing to such page should look like:

URL(‘mypage_with_grid’, args=[‘a’, ‘b’, ‘c’], vars={‘var1’:’val1’}, user_signature=True, hash_vars=False)


Tom Clerckx

unread,
May 24, 2021, 3:53:06 AM5/24/21
to web2py-users
Can someone confirm my reasoning... or correct it if it's wrong?

Thanks,
Tom.

Reply all
Reply to author
Forward
0 new messages