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
+39-7Lines changed: 39 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -70,6 +70,7 @@ These are all the configuration options and their default value between brackets
70
70
- "username": Username of the user connecting to the database (no default)
71
71
- "password": Password of the user connecting to the database (no default)
72
72
- "database": Database the connecting is made to (no default)
73
+
- "tables": Comma separated list of tables to publish (defaults to 'all')
73
74
- "middlewares": List of middlewares to load (`cors`)
74
75
- "controllers": List of controllers to load (`records,geojson,openapi`)
75
76
- "openApiBase": OpenAPI info (`{"info":{"title":"PHP-CRUD-API","version":"1.0.0"}}`)
@@ -93,7 +94,7 @@ These limitation and constrains apply:
93
94
94
95
The following features are supported:
95
96
96
-
-Single PHP file, easy to deploy.
97
+
-Composer install or single PHP file, easy to deploy.
97
98
- Very little code, easy to adapt and maintain
98
99
- Supports POST variables as input (x-www-form-urlencoded)
99
100
- Supports a JSON object as input
@@ -119,10 +120,18 @@ The following features are supported:
119
120
120
121
## Compilation
121
122
123
+
You can install all dependencies of this project using the following command:
124
+
125
+
php install.php
126
+
122
127
You can compile all files into a single "`api.php`" file using:
123
128
124
129
php build.php
125
130
131
+
NB: The install script will patch the dependencies in the vendor directory for PHP 7.0 compatibility.
132
+
133
+
### Development
134
+
126
135
You can access the non-compiled code at the URL:
127
136
128
137
http://localhost:8080/src/records/posts/1
@@ -137,7 +146,7 @@ You can update all dependencies of this project using the following command:
137
146
138
147
This script will install and run [Composer](https://getcomposer.org/) to update the dependencies.
139
148
140
-
NB: The update script will also patch the dependencies in the vendor directory for PHP 7.0 compatibility.
149
+
NB: The update script will patch the dependencies in the vendor directory for PHP 7.0 compatibility.
141
150
142
151
## TreeQL, a pragmatic GraphQL
143
152
@@ -613,6 +622,7 @@ You can tune the middleware behavior using middleware specific configuration par
613
622
- "dbAuth.usernameColumn": The users table column that holds usernames ("username")
614
623
- "dbAuth.passwordColumn": The users table column that holds passwords ("password")
615
624
- "dbAuth.returnedColumns": The columns returned on successful login, empty means 'all' ("")
625
+
- "dbAuth.sessionName": The name of the PHP session that is started ("")
616
626
- "jwtAuth.mode": Set to "optional" if you want to allow anonymous access ("required")
617
627
- "jwtAuth.header": Name of the header containing the JWT token ("X-Authorization")
618
628
- "jwtAuth.leeway": The acceptable number of seconds of clock skew ("5")
@@ -621,13 +631,16 @@ You can tune the middleware behavior using middleware specific configuration par
621
631
- "jwtAuth.algorithms": The algorithms that are allowed, empty means 'all' ("")
622
632
- "jwtAuth.audiences": The audiences that are allowed, empty means 'all' ("")
623
633
- "jwtAuth.issuers": The issuers that are allowed, empty means 'all' ("")
634
+
- "jwtAuth.sessionName": The name of the PHP session that is started ("")
624
635
- "basicAuth.mode": Set to "optional" if you want to allow anonymous access ("required")
625
636
- "basicAuth.realm": Text to prompt when showing login ("Username and password required")
626
637
- "basicAuth.passwordFile": The file to read for username/password combinations (".htpasswd")
638
+
- "basicAuth.sessionName": The name of the PHP session that is started ("")
627
639
- "reconnect.driverHandler": Handler to implement retrieval of the database driver ("")
628
640
- "reconnect.addressHandler": Handler to implement retrieval of the database address ("")
629
641
- "reconnect.portHandler": Handler to implement retrieval of the database port ("")
630
642
- "reconnect.databaseHandler": Handler to implement retrieval of the database name ("")
643
+
- "reconnect.tablesHandler": Handler to implement retrieval of the table names ("")
631
644
- "reconnect.usernameHandler": Handler to implement retrieval of the database username ("")
632
645
- "reconnect.passwordHandler": Handler to implement retrieval of the database password ("")
633
646
- "authorization.tableHandler": Handler to implement table authorization rules ("")
@@ -756,11 +769,30 @@ You can also change the `url` variable, used to test the API with authentication
756
769
First you need to create a Firebase project on the [Firebase console](https://console.firebase.google.com/).
757
770
Add a web application to this project and grab the code snippet for later use.
758
771
759
-
Then you have to configure the `jwtAuth.secrets` configuration in your `api.php` file.
760
-
Grab the public key via this [URL](https://www.googleapis.com/robot/v1/metadata/x509/[email protected]).
761
-
There may be several certificates, just grab the one corresponding to your `kid` (if you don't
762
-
know what it is, just test them all until you will be logged in).
763
-
Now, just fill `jwtAuth.secrets` with your public key.
772
+
Then you have to configure the `jwtAuth.secrets` configuration in your `api.php` file.
773
+
This can be done as follows:
774
+
775
+
a. Log a user in to your Firebase-based app, get an authentication token for that user
776
+
b. Go to [https://jwt.io/](https://jwt.io/) and paste the token in the decoding field
777
+
c. Read the decoded header information from the token, it will give you the correct `kid`
778
+
d. Grab the public key via this [URL](https://www.googleapis.com/robot/v1/metadata/x509/[email protected]), which corresponds to your `kid` from previous step
779
+
e. Now, just fill `jwtAuth.secrets` with your public key in the `api.php`
780
+
781
+
Here is an example of what it should look like in the configuration:
0 commit comments