02-15-2021 02:32 AM
Hi,
I'm using the Nuxeo Python API with Nuxeo 10.10 and want to know if there is any way to fetch all accessible document while log as administrator. I've already find a way, but it's a bit tricky and i don't think it's the official way.
Thanks in advance,
Hugo
Edit : I want a way to "usurpate" the user account as admin 🙂
I've a website where a user connect via a CAS. When authenticated he can access to a "Nuxeo Interface" (not the nuxeo website but an intern page of my website where he can search for particular documents). So the user doesn't connect to Nuxeo with his account because i don't want him to enter his password again, i use the CAS username which is the same as the Nuxeo username to get his groups. At the same time i get all documents from Nuxeo where he makes a demand, i get the ACL of the document with fetch_acls() and compare the groups and permission to user_groups. So I've an array of array of documents with user permission returned by my method :
Something like this :
[
[ Document1, Write ],
[ Document2, Read ],
]
But i've heard that there's a better way to do this, like "usurpate" user by directly taking all documents accessible by him, instead of doing this by myself in my app
Hope you understand
Hugo
The part to get permission : A "node" is a Document
def check_perm_level(old, new):
if old >= new:
return old
else:
return new
def get_node_permission(node, groups):
perm_level = 0
acls = node.fetch_acls()
for i in range(len(acls)):
permissions = acls[i]["aces"]
for permission in permissions:
if permission['username'] not in groups or permission['granted'] == "False":
continue
else:
if permission['permission'] == 'Read':
perm_level = check_perm_level(perm_level, 1)
elif permission['permission'] == 'ReadWrite':
perm_level = check_perm_level(perm_level, 2)
elif permission['permission'] == 'Everything':
perm_level = check_perm_level(perm_level, 3)
return perm_level
02-15-2021 04:11 AM
Could you share your code please?
02-15-2021 06:53 AM
I've answered you in the commentary below, thanks in advance
02-15-2021 06:54 AM
[Mickaël Schoentgen](https
02-16-2021 08:45 AM
Did you see [Auth.LoginAs](https
02-16-2021 10:21 AM
Yes something like that, but i can't figure how to use it
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.