Create a .acl with solid-file-client

I am trying to create a .acl for a folder ‘prueba’ with permissions only for my account, and i have the next method:
`private createACL() {

    let file = 'https://mypod.solid.community//prueba/.acl';
    let content = '@prefix  acl:  <http://www.w3.org/ns/auth/acl#>  .\n'+
        '<#authorization1>\n'+
        'a             acl:Authorization;\n'+
        'acl:agent     <https://mypod.solid.community/profile/card#me>;\n'+
        'acl:accessTo  <https://mypod.solid.community//prueba/>;\n'+
        'acl:mode      acl:Read,\n'+
        'acl:Write,\n'+
        'acl:Control.\n'
    this.fileClient.updateFile(file,content).then(success => {
        console.log(`New ACL for ${file}.`)
    }, err => console.log(err));
}`

I think the structure of the acl is right (i used the acl spec, and with the same steps i can create a normal file.
But i cant create the acl, i hava a folder, but it hasnt got the acl.


Edit:
This is the code that works:

private createACL () {
        let file = 'https://mypod.solid.community/test/.acl';
        let content = '@prefix acl: <http://www.w3.org/ns/auth/acl#>. \ n' +
            '<#owner> \ n' +
            'a acl: Authorization; \ n' +
            'acl: agent <https://mypod.solid.community/profile/card#me>; \ n' +
            'acl: accessTo <https://mypod.solid.community/test/>; \ n' +
            'acl: defaultForNew <./>;' +
            'acl: mode \ n acl: Read, \ n' +
            'acl: Write, \ n' +
            'acl: Control. \ n' +

            '<#reader> \ n' +
            'a acl: Authorization; \ n' +
            'acl: defaultForNew <./>;' +
            'acl: accessTo <https://mypod.solid.community/test/>; \ n' +
            'acl: mode acl: Read; \ n' +
            'acl: agent <https://otherpod.inrupt.net/profile/card#me>.'

        this.fileClient.updateFile (file, content) .then (success => {
            console.log (`Created $ {file} .`)
        }, err => console.log (err));
    }

Dou you mean that the .acl file is not in the folder after you run updateFile() or that the file is there but it does not have the permissions impact you expect? Did you intend the double-slashes in //prueba in your accessTo and the file name?

I am using Solid Explorer to see the .acl of the folder, and there isnt any rule for prueba, it is just empty.
I tried with \\prueba\, \prueba\, \\prueba and \prueba and nothing work
Maybe i am writing bad the content of the acl.

I don’t know how Solid Explorer works, but with the data browser and with Solid IDE you can enter the full URL e.g. https://mypod.solid.community/prueba/.acl and see .acl files. They do not show up in any regular directory listings by design, you need to ask for them specifically.

I am using the basic pod explorer, the solid community explorer, and when i am going to look the acl, it said there isnt any acl for prueba.
I have made more tries, too, and after a couple of times i get this with the next code:

 private createACL() {
    let file = 'https://mypod.solid.community/prueba7/.acl';
    let contenido = '@prefix  acl:  <http://www.w3.org/ns/auth/acl#>  .\n'+
        '<#authorization1>\n'+
        'a             acl:Authorization;\n'+
        'acl:agent     <https://mypod.solid.community/profile/card#me>;\n'+
        'acl:accessTo  <https://mypod.solid.community/prueba7>;\n'+
        'acl:mode\n      acl:Read,\n'+
        'acl:Write,\n'+
        'acl:Control.'+

        '<#authorization2>\n'+
        'a               acl:Authorization;\n'+
        'acl:accessTo  <https://mypod.solid.community/prueba7>;\n'+
        'acl:mode        acl:Read;\n'+
        'acl:agent  <https:/otherpod.inrupt.net/profile/card#me>.'

    this.fileClient.updateFile(file,contenido).then(success => {
        console.log(`Updated ${file}.`)
    }, err => console.log(err));
}

and i get the next .acl


I dont know what is g_L…, but is empty.
And when i change ‘acl:Control.’ to ‘acl:Control.\n’, i lost the control of the folder. I am in the 7 test, becouse i cant delete the previous six test.

And here is the error

Outline.expand: Unable to fetch https://mypod.solid.community/prueba7/.acl: Failed to load https://mypod.solid.community/prueba7/.acl Fetcher: Error trying to parse https://mypod.solid.community/prueba7/.acl as Notation3:
Error: Line 10 of https://mypod.solid.community/prueba7/.acl: Bad syntax: expected ‘.’ or ‘}’ or ‘]’ at end of statement
at: “a acl:Authorizat” status: 200

I dont undestand the error. How can i miss a ‘.’ or ‘]’ or ‘}’ in the middle of a word?

Did you try acl:Control.\n in lieu of acl:Control.

Yes, i have done it, and i lost the access to the folder. Later, i can’t enter or edit the folder, neither the .acl.

The error says it is trying to parse your file as Notation3 yet the file contents are in Turtle. Try to force the content-type when you write the file like this: fileClient.updateFile( file, content, “text/turtle” ).

Ok, i thing is almost over.
Now it creates a .acl.ttl in the folder, like this:


But the reader i gave access to read cant read it, becouse the pod cant find the /prueba9/.acl
Now the code is this:

 private createACL() {
    let file = 'https://mypod.solid.community/prueba9/.acl';
    let contenido = '@prefix  acl:  <http://www.w3.org/ns/auth/acl#>  .\n'+
        '<#owner>\n'+
        'a             acl:Authorization;\n'+
        'acl:agent     <https://mypod.solid.community/profile/card#me>;\n'+
        'acl:accessTo  <https://mypod.solid.community/prueba9/>;\n'+
        'acl:mode\n      acl:Read,\n'+
        'acl:Write,\n'+
        'acl:Control.\n'+

        '<#reader>\n'+
        'a               acl:Authorization;\n'+
        'acl:accessTo  <https://mypod.solid.community/prueba9/>;\n'+
        'acl:mode        acl:Read;\n'+
        'acl:agent  <https://otherpod.inrupt.net/profile/card#me>.'

    this.fileClient.updateFile(file,contenido,"text/turtle").then(success => {
        console.log(`Created ${file}.`)
    }, err => console.log(err));
}

Just to confirm: (1) when you upload the file without specifying content-type, it gives you the Notation3 error and creates the file /prueba9/.acl. and (2) when you upload the same content with “text-turtle” specified as the content type, the Notation3 error goes away but the file gets named /prueba9/.acl.ttl.

Is this what is happening?

(1) When i upload without specifying, it creates the .acl right, if there is a mistake like forgetting the /n after the acl:Control, then it creates a .acl with a error in it and the Nonatition3, but if i write it without any mistke, i lose the access to the folder. (2) yes

But you get the Notation3 error?

Yes, if i write the acl with some error,yes, i get the Notation3; If i write it without any error, i lose the acces, so i guess i create a .acl.

Are you literally putting " https://mypod.solid.community/profile/card#me as the agent? Unless you have an account with the username “mypod” this will lock you out.

No, i am putting my pod id, it’s just to generalize.

You could try adding this to each authorization:

 acl:defaultForNew <./>;

Other than that, I’m out of ideas. If you get it solved, please post back.

1 Like

Ok, i wil try, and when i gave to the solution i will update the post. Thanks for all of your help.

that works, thanks a lot

Hey, you can try templated string, so you won’t need \n and +