Skip to content
Grav 2.0 is officially stable. Read the announcement →
General

Can files be kept private on Grav?

Started by Walter Byrd 6 years ago · 3 replies · 796 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 jean-louis67, 3 weeks ago
2 308 3 weeks ago
General · by Andy Miller, 3 weeks ago
0 310 3 weeks ago
General · by Veehem, 4 weeks ago
0 263 4 weeks ago
General · by milkboy, 4 weeks ago
0 264 4 weeks ago
General · by ian russell, 1 month ago
2 335 1 month ago