You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+23-4
Original file line number
Diff line number
Diff line change
@@ -80,9 +80,21 @@ These are all the configuration options and their default value between brackets
80
80
- "cacheType": `TempFile`, `Redis`, `Memcache`, `Memcached` or `NoCache` (`TempFile`)
81
81
- "cachePath": Path/address of the cache (defaults to system's temp directory)
82
82
- "cacheTime": Number of seconds the cache is valid (`10`)
83
-
- "debug": Show errors in the "X-Debug-Info" header (`false`)
83
+
- "debug": Show errors in the "X-Exception" headers (`false`)
84
84
- "basePath": URI base path of the API (determined using PATH_INFO by default)
85
85
86
+
All configuration options are also available as environment variables. Write the config option with capitals, a "PHP_CRUD_API_" prefix and underscores for word breakes, so for instance:
87
+
88
+
- PHP_CRUD_API_DRIVER=mysql
89
+
- PHP_CRUD_API_ADDRESS=localhost
90
+
- PHP_CRUD_API_PORT=3306
91
+
- PHP_CRUD_API_DATABASE=php-crud-api
92
+
- PHP_CRUD_API_USERNAME=php-crud-api
93
+
- PHP_CRUD_API_PASSWORD=php-crud-api
94
+
- PHP_CRUD_API_DEBUG=1
95
+
96
+
The environment variables take precedence over the PHP configuration.
97
+
86
98
## Limitations
87
99
88
100
These limitation and constrains apply:
@@ -614,10 +626,10 @@ You can tune the middleware behavior using middleware specific configuration par
614
626
- "firewall.reverseProxy": Set to "true" when a reverse proxy is used ("")
615
627
- "firewall.allowedIpAddresses": List of IP addresses that are allowed to connect ("")
616
628
- "cors.allowedOrigins": The origins allowed in the CORS headers ("*")
617
-
- "cors.allowHeaders": The headers allowed in the CORS request ("Content-Type, X-XSRF-TOKEN, X-Authorization, X-Debug-Info, X-Exception-Name, X-Exception-Message, X-Exception-File")
629
+
- "cors.allowHeaders": The headers allowed in the CORS request ("Content-Type, X-XSRF-TOKEN, X-Authorization")
618
630
- "cors.allowMethods": The methods allowed in the CORS request ("OPTIONS, GET, PUT, POST, DELETE, PATCH")
619
631
- "cors.allowCredentials": To allow credentials in the CORS request ("true")
620
-
- "cors.exposeHeaders": Whitelist headers that browsers are allowed to access ("X-Debug-Info, X-Exception-Name, X-Exception-Message, X-Exception-File")
632
+
- "cors.exposeHeaders": Whitelist headers that browsers are allowed to access ("")
621
633
- "cors.maxAge": The time that the CORS grant is valid in seconds ("1728000")
622
634
- "xsrf.excludeMethods": The methods that do not require XSRF protection ("OPTIONS,GET")
623
635
- "xsrf.cookieName": The name of the XSRF protection cookie ("XSRF-TOKEN")
@@ -653,6 +665,7 @@ You can tune the middleware behavior using middleware specific configuration par
653
665
- "reconnect.passwordHandler": Handler to implement retrieval of the database password ("")
654
666
- "authorization.tableHandler": Handler to implement table authorization rules ("")
655
667
- "authorization.columnHandler": Handler to implement column authorization rules ("")
668
+
- "authorization.pathHandler": Handler to implement path authorization rules ("")
656
669
- "authorization.recordHandler": Handler to implement record authorization filter rules ("")
657
670
- "validation.handler": Handler to implement validation rules for input values ("")
658
671
- "validation.types": Types to enable type validation for, empty means 'none' ("all")
@@ -840,7 +853,7 @@ Add the "columns" controller in the configuration to enable this functionality.
840
853
841
854
### Authorizing tables, columns and records
842
855
843
-
By default all tablesand columns are accessible. If you want to restrict access to some tables you may add the 'authorization' middleware
856
+
By default all tables, columns and paths are accessible. If you want to restrict access to some tables you may add the 'authorization' middleware
844
857
and define a 'authorization.tableHandler' function that returns 'false' for these tables.
845
858
846
859
'authorization.tableHandler' => function ($operation, $tableName) {
@@ -862,6 +875,12 @@ The above example will restrict access to the 'password' field of the 'users' ta
862
875
The above example will disallow access to user records where the username is 'admin'.
863
876
This construct adds a filter to every executed query.
864
877
878
+
'authorization.pathHandler' => function ($path) {
879
+
return $path === 'openapi' ? false : true;
880
+
},
881
+
882
+
The above example will disabled the `/openapi` route.
883
+
865
884
NB: You need to handle the creation of invalid records with a validation (or sanitation) handler.
0 commit comments