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

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

General

Can files be kept private on Grav?

Started by Walter Byrd 6 years ago · 3 replies · 688 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 Jerry Hunt, 4 days ago
2 101 16 hours ago
General · by pamtbaau, 22 hours ago
1 68 21 hours ago
General · by Andy Miller, 1 day ago
0 53 1 day ago
General · by Marcel, 12 months ago
6 361 5 days ago
General · by Duc , 6 days ago
3 49 6 days ago