Groups
Groups
Sign in
Groups
Groups
web2py-users
Conversations
Labels
About
Send feedback
Help
auth.impersonate not working?!
56 views
Skip to first unread message
António Ramos
unread,
Dec 18, 2019, 12:42:12 PM
12/18/19
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to web...@googlegroups.com
hello i have a controller function that is called as a get/post request
this functions then needs to log as a specific user before manipulating data from tables.
4 is my user id
def
checkLoad
():
user
=
auth.impersonate(
4
)
return "ok"
When i call it with postman or something to test my endpoint i get
Not Authorized
Any ideas why ?
Regards
António
António Ramos
unread,
Dec 18, 2019, 12:53:10 PM
12/18/19
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to web...@googlegroups.com
found it
Had to create a group called "impersonate"
then added my user to that membership
then
in my function
user
=
auth.login_bare(
"teslaoneday
"
,
"youwish..."
)
user
=
auth.impersonate(
25
)
Not it works as expected...
Regards
António Ramos
unread,
Jan 16, 2020, 10:42:47 AM
1/16/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to web...@googlegroups.com
Back again to impersonate issue. I have the sysadmin user member of impersonate like the attached pic.
My code to impersonate user 25 as follows "
Forbidden"
def
execdal
():
user
=
auth.login_bare(
"sysadmin"
,
"mypwd"
)
auth.impersonate(
25
)
return
dict
(
a
=
user)
António Ramos
unread,
Jan 16, 2020, 10:46:39 AM
1/16/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to web...@googlegroups.com
bad english in previous email. Sorry about that.
the user sysadmin belongs to group "impersonate" ike attached pic in previous email.
My code to impersonate user sysadmin as user 25 returns "Forbidden"
any help ?
Regards
António
António Ramos
unread,
Jan 16, 2020, 11:08:37 AM
1/16/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to web...@googlegroups.com
apparently have to add_permission like
user
=
auth.login_bare(
"user"
,
"pwd"
)
auth.add_permission(
impersonateGroupID
,
"impersonate"
, db.auth_user,
0
)
auth.impersonate(
46
)
return
auth.user_id
Reply all
Reply to author
Forward
0 new messages