Skip to content

Commit b32beb9

Browse files
committed
up
1 parent 6e1b0ae commit b32beb9

8 files changed

Lines changed: 81 additions & 87 deletions

File tree

.env.example

Lines changed: 0 additions & 35 deletions
This file was deleted.

.htaccess

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# PHP CRUD API Generator - Root Security Configuration
2+
# Disable directory listing for this project
3+
Options -Indexes
4+
#
5+
# Goal:
6+
# - Protect sensitive files in the project root (.env, configs, vault, etc.)
7+
# - Restrict dashboard and health endpoints to trusted IPs only
8+
#
9+
# 📖 Full security guide: docs/DASHBOARD_SECURITY.md
10+
11+
# ----------------------------------------------------------------------
12+
# 1) Protect .env and other dotfiles in project root
13+
# ----------------------------------------------------------------------
14+
15+
<FilesMatch "^\.env">
16+
Require all denied
17+
</FilesMatch>
18+
19+
<FilesMatch "^\.(git|svn|hg|env)">
20+
Require all denied
21+
</FilesMatch>
22+
23+
# ----------------------------------------------------------------------
24+
# 2) Protect Admin Dashboard (root/dashboard.html)
25+
# ----------------------------------------------------------------------
26+
27+
<Files "dashboard.html">
28+
# Apache 2.4+ syntax: only allow localhost by default
29+
Require ip 127.0.0.1 ::1
30+
# To allow additional IPs in production, add lines like:
31+
# Require ip YOUR.PUBLIC.IP.HERE
32+
</Files>
33+
34+
# ----------------------------------------------------------------------
35+
# 3) Protect Health Endpoint (root/health.php)
36+
# ----------------------------------------------------------------------
37+
38+
<Files "health.php">
39+
# Apache 2.4+ syntax: only allow localhost by default
40+
Require ip 127.0.0.1 ::1
41+
# To allow monitoring servers in production, add lines like:
42+
# Require ip 198.51.100.10
43+
</Files>
44+
45+
# Optional: Add HTTP Basic Authentication
46+
# Uncomment and configure if you want password protection
47+
#
48+
# <Files "dashboard.html">
49+
# AuthType Basic
50+
# AuthName "Admin Dashboard"
51+
# AuthUserFile /path/to/.htpasswd
52+
# Require valid-user
53+
# </Files>
54+
#
55+
# Create password file with:
56+
# htpasswd -c .htpasswd admin
57+
58+
# Optional: Redirect HTTP to HTTPS (recommended for production)
59+
# RewriteEngine On
60+
# RewriteCond %{HTTPS} off
61+
# RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

.htaccess.example

Lines changed: 0 additions & 52 deletions
This file was deleted.

.htaccessTest

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Options -Indexes
2+
RewriteEngine on
3+
RewriteCond %{REQUEST_FILENAME} !-d
4+
RewriteCond %{REQUEST_FILENAME} !-f
5+
#RewriteRule ^ - [R=404,L]
6+
#RewriteRule ^ - [R=403,L]
7+
8+
#ErrorDocument 404
9+
#ErrorDocument 403
10+
11+
12+
RewriteRule (.+) index.php [QSA,L]

config/.htaccess

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Deny direct web access to config files
2+
Require all denied

sql/.htaccess

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Deny direct web access to SQL files
2+
Require all denied

src/.htaccess

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Deny direct web access to source code
2+
Require all denied

tests/.htaccess

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Deny direct web access to tests
2+
Require all denied

0 commit comments

Comments
 (0)