Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when inheriting permissions from parent folder #5

Closed
jesQM opened this issue Apr 18, 2020 · 5 comments
Closed

Issue when inheriting permissions from parent folder #5

jesQM opened this issue Apr 18, 2020 · 5 comments

Comments

@jesQM
Copy link

jesQM commented Apr 18, 2020

Cheers @Otto-AA , I have recently been using your library in a project and I have stumbled upon some problems.

I am trying to edit permissions on a file without .acl (it inherits permissions from parent directory) and whenever I change them to add someone to read a file, I get a 403 status when accessing my file, however, the other user is able of reading it.

I have my file with such permissions.
image

And using this code I try to add someone with read:

async shareFile(url){
        console.log("About to:");
        console.log(url);

        const fetch = auth.fetch.bind(auth); // const auth = require('solid-auth-client');
        const utils = new AclApi(fetch, { autoSave: true });

        const acl = await utils.loadFromFileUrl(url);

        let p = new Permissions();
        p.add(READ);
        let a = new Agents();
        a.addWebId("https://aliceuniovi.inrupt.net/profile/card#me");

        try {
            await acl.addRule(p, a);
            console.log("updated acl")
        } catch (e) {
            console.error('Error while adding rule')
            console.error(e)
            throw e
        }
}

When executed, the following is printed in the console:

About to:
https://uo263624.solid.community/viade/routes/48bb5195-2a42-42e8-968e-988528e0a1dc.json
GET https://uo263624.solid.community/viade/routes/48bb5195-2a42-42e8-968e-988528e0a1dc.json.acl 404 (Not Found)
updated acl

And the other user can download the json with no problem, but, if I try to access.

You are currently logged in as https://uo263624.solid.community/profile/card#me, but do not have permission to access https://uo263624.solid.community/viade/routes/cb9c1ecb-4f9e-4f75-94c9-d06ace9d8365.json.
image

And, as unable to read the file nor the .acl, I don't know what the permissions are or what happened.

If instead of READ, I give other permissions like, CONTROL. The other user can read the .acl (thus not edit it nor download the json file (this is odd)) and shows the following:
image

Not sure where I am messing up, but I've tried different approaches for some time while checking the provided example, yet with no avail.

Kind regards and sorry for such a long "I need help" post.

@Otto-AA
Copy link
Owner

Otto-AA commented Apr 18, 2020

Are you using the newest version? It sounds like the behaviour of an older version, so could you check that you have a build of version 0.1.0? To use the latest version, you can clone it from github, run npm run build and use the js file from the dist directory.

@Otto-AA
Copy link
Owner

Otto-AA commented Apr 18, 2020

Ok, I think I found the root of the issue. I didn't update the dist folder in github in the last months, so it likely hasn't included the patch for loading the default from the parent.

I've updated it now, so if you reinstall it in your project it should work. But I'd suggest you to somehow add a version to your dependency, else changes in this project which are not backwards compatible could break yours. I don't know how you could do this, building it yourself should work I guess.

@Otto-AA
Copy link
Owner

Otto-AA commented Apr 18, 2020

And as a side note. You could use shortcuts to replace this

        let p = new Permissions();
        p.add(READ);
        let a = new Agents();
        a.addWebId("https://aliceuniovi.inrupt.net/profile/card#me");

        try {
            await acl.addRule(p, a);
            console.log("updated acl")
        } catch (e) {

with

        try {
            await acl.addRule(READ, "https://aliceuniovi.inrupt.net/profile/card#me");
            console.log("updated acl")
        } catch (e) {

The first param of addRule can also be a single permission (READ) or array of permissions ([READ, WRITE]). The second value can be a webId or an array of webIds. You only need to use new Agents() if you want to add groups, public or authenticated. For webIds, just use the shortcut.

@jesQM
Copy link
Author

jesQM commented Apr 18, 2020

Oh wow, it does indeed work now, just the update was required. However, have done some testing and looks like if the only acl found is the one of the root of the pod, nothing is done (haven't really tested deeply as it is not now works for what i require)

Wasn't expecting for you to answer so fast, thanks a ton. And... I did really enjoy that sidenote of yours, it will make stuff easier 😄.

@Otto-AA
Copy link
Owner

Otto-AA commented Apr 18, 2020

I'm glad that it helped you, good luck with your project :)

However, have done some testing and looks like if the only acl found is the one of the root of the pod, nothing is done (haven't really tested deeply as it is not now works for what i require)

If the parent has an acl file, it should find it and use the defaults (if it has any) from this file. Else continue with the grandparent, etc. until the root which must have an acl file. So if it uses the acl file from root, either there is no folder in between with an acl file, or the library has a bug.

@jesQM jesQM closed this as completed Apr 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants