Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

Can files be kept private on Grav?

Started by Walter Byrd 6 years ago · 3 replies · 972 views
6 years ago

Although there are advantages to a flat file system. I have to wonder about keeping anything private. Can anybody get to files on grav, just by the URL?

6 years ago

I'm also interested in this. Following.

6 years ago

@walterbyrd, @marcocevoli Although I'm not that well versed in .htaccess, I think (and correct me if I'm wrong) the following snippet will block all sorts of file types in the /user tree and also all *.md files anywhere in your site:

TXT
# Block access to specific file types for these user folders
RewriteRule ^(user)/(.*)\.(txt|md|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ error [F]
# Block all direct access to .md files:
RewriteRule \.md$ error [F]
last edited 06/12/20 by pamtbaau
6 years ago

I had to write a little plugin that looks at a pages frontmatter, and if it contained "private_content: true", then it is hidden from the archive page creation and if someone were to access it via a url (i.e. someone shared a link) it returns the 404 page. I am still working on the part of the plugin that allows access to the content should a privileged user access the content.

Suggested topics

Topic Participants Replies Views Activity
General · by themetman, 24 hours ago
2 40 17 hours ago
General · by Hanns Mattes, 1 week ago
0 121 1 week ago
General · by Karmalakas, 1 week ago
2 185 1 week ago
General · by Hanns Mattes, 3 weeks ago
0 235 3 weeks ago
General · by Dima, 4 weeks ago
1 211 4 weeks ago