Acl and access

Hello, I just can’t figure out how to implement a private site. I need to implement a site/project1/page1,page2,page3 which are accessible to users of the group ‘project1users’, and a different site/project2/pagea,pageb,pagec which are accessible to group ‘project2users’.

I’ve tried to understand if the admin plugin or the login plugin do these kind of things, but unfortunately I just didn’t get if they do and I am missing some bit of information, or if they just don’t.

Can you help me understand?


Let me know how you get on based on twitter back and forth :slight_smile:

BTW, all the access stuff is totally arbitrary. You can put whatever you want.

You can specifically deny access to any particular string, or allow. Just those strings (site.log, admin.login,, etc), would need to match up in the YAML of the user if you want to provide or deny access.

There are really no restrictions, you can do pretty much anything with it.

The login plugin simply runs through any access rules on a page, and checks if the current logged in user has any rules that match, if the user does, access is granted, else a login prompt is displayed.

That’s all it does, so the rules you come up with and define are up to you.

Hope that makes sense!

thank you @rhukster.

I am trying to implement a “private” site using the Learn2 theme. I just want to enable access to the site only to authenticated users.

I just don’t understand how I shall do it. If I go in the plugin configuration and add a custom login url (‘login’) I get this error:

The template file for this page: "form.html.twig" is not provided by the theme: "Learn2"

But from what I read the plugin should generate a login page shouldn’t it?

Anyway I create the file, which I put in /partials/login/form.html.twig, with this content:

 {% if config.plugins.login.enabled and grav.user.username %}
    <li><i class="fa fa-lock"></i> {% include 'partials/login-status.html.twig' %}</li>
{% endif %}

But it seems that nothing changes.

What am I doing wrong?

First, don’t set a custom URL. It will create a login page automatically ‘on the current’ page by default. So remove that custom login path. Learn2 does not have a form.html.twig, you would have to create one, or use the one from Antimatter as a base.

Every page in your learn site (or the restricted pages at least) would need to have that access: site.login: true setting that is explained in the login README.

ok, now I will try. Is it possible to set this on a folder level, or root level?

No, must be set per-page currently.