|
@@ -91,9 +91,8 @@ These limitation were also present in v1:
|
91
|
91
|
- Composite primary or foreign keys are not supported
|
92
|
92
|
- Complex writes (transactions) are not supported
|
93
|
93
|
- Complex queries calling functions (like "concat" or "sum") are not supported
|
94
|
|
- - MySQL storage engine must be either InnoDB or XtraDB
|
95
|
|
- - Only MySQL, PostgreSQL and SQLServer support spatial/GIS functionality
|
96
|
|
-
|
|
94
|
+ - Database must support and define foreign key constraints
|
|
95
|
+
|
97
|
96
|
## Features
|
98
|
97
|
|
99
|
98
|
These features match features in v1 (see branch "v1"):
|
|
@@ -120,7 +119,7 @@ These features match features in v1 (see branch "v1"):
|
120
|
119
|
- [x] Spatial/GIS fields and filters supported with WKT
|
121
|
120
|
- [ ] Unstructured data support through JSON/JSONB
|
122
|
121
|
- [ ] Generate API documentation using OpenAPI tools
|
123
|
|
- - [ ] Authentication via JWT token or username/password
|
|
122
|
+ - [x] Authentication via JWT token or username/password
|
124
|
123
|
- [ ] ~~SQLite support~~
|
125
|
124
|
|
126
|
125
|
NB: No checkmark means: not yet implemented. Striken means: will not be implemented.
|
|
@@ -141,28 +140,31 @@ These features are new and were not included in v1.
|
141
|
140
|
|
142
|
141
|
You can enable the following middleware using the "middlewares" config parameter:
|
143
|
142
|
|
|
143
|
+- "firewall": Limit access to specific IP addresses
|
144
|
144
|
- "cors": Support for CORS requests (enabled by default)
|
145
|
|
-- "authorization": Restrict access to certain tables or columns
|
|
145
|
+- "jwtAuth": Support for "Basic Authentication"
|
146
|
146
|
- "basicAuth": Support for "Basic Authentication"
|
147
|
|
-- "firewall": Limit access to specific IP addresses
|
|
147
|
+- "authorization": Restrict access to certain tables or columns
|
148
|
148
|
- "validation": Return input validation errors for custom rules
|
149
|
149
|
- "sanitation": Apply input sanitation on create and update
|
150
|
150
|
|
151
|
151
|
The "middlewares" config parameter is a comma separated list of enabled middlewares.
|
152
|
152
|
You can tune the middleware behavior using middleware specific configuration parameters:
|
153
|
153
|
|
|
154
|
+- "firewall.reverseProxy": Set to "true" when a reverse proxy is used ("")
|
|
155
|
+- "firewall.allowedIpAddresses": List of IP addresses that are allowed to connect ("")
|
154
|
156
|
- "cors.allowedOrigins": The origins allowed in the CORS headers ("*")
|
155
|
157
|
- "cors.allowHeaders": The headers allowed in the CORS request ("Content-Type, X-XSRF-TOKEN")
|
156
|
158
|
- "cors.allowMethods": The methods allowed in the CORS request ("OPTIONS, GET, PUT, POST, DELETE, PATCH")
|
157
|
159
|
- "cors.allowCredentials": To allow credentials in the CORS request ("true")
|
158
|
160
|
- "cors.maxAge": The time that the CORS grant is valid in seconds ("1728000")
|
|
161
|
+- "jwtAuth.leeway": The acceptable number of seconds of clock skew ("5")
|
|
162
|
+- "jwtAuth.ttl": The number of seconds the token is valid ("30")
|
|
163
|
+- "jwtAuth.secret": The shared secret used to sign the JWT token with ("")
|
|
164
|
+- "basicAuth.passwordFile": The file to read for username/password combinations (".htpasswd")
|
159
|
165
|
- "authorization.tableHandler": Handler to implement table authorization rules ("")
|
160
|
166
|
- "authorization.columnHandler": Handler to implement column authorization rules ("")
|
161
|
167
|
- "authorization.recordHandler": Handler to implement record authorization filter rules ("")
|
162
|
|
-- "basicAuth.passwordFile": The file to read for username/password combinations (".htpasswd")
|
163
|
|
-- "basicAuth.realm": Message shown when asking for credentials ("Username and password required")
|
164
|
|
-- "firewall.reverseProxy": Set to "true" when a reverse proxy is used ("")
|
165
|
|
-- "firewall.allowedIpAddresses": List of IP addresses that are allowed to connect ("")
|
166
|
168
|
- "validation.handler": Handler to implement validation rules for input values ("")
|
167
|
169
|
- "sanitation.handler": Handler to implement sanitation rules for input values ("")
|
168
|
170
|
|
|
@@ -553,6 +555,44 @@ For spatial support there is an extra set of filters that can be applied on geom
|
553
|
555
|
|
554
|
556
|
These filters are based on OGC standards and so is the WKT specification in which the geometry columns are represented.
|
555
|
557
|
|
|
558
|
+### Authentication
|
|
559
|
+
|
|
560
|
+Authentication is done by means of sending a "Authorization" header. It identifies the user and stores this in the `$_SESSION` super global.
|
|
561
|
+This variable can be used in the authorization handlers to decide wether or not sombeody should have read or write access to certain tables, columns or records.
|
|
562
|
+Currently there are two types of authentication supported: "Basic" and "JWT".
|
|
563
|
+
|
|
564
|
+#### Basic authentication
|
|
565
|
+
|
|
566
|
+The Basic type supports a file that holds the users and their (hashed) passwords separated by a colon (':').
|
|
567
|
+When the passwords are entered in plain text they fill be automatically hashed.
|
|
568
|
+The authenticated username will be stored in the `$_SESSION['username']` variable.
|
|
569
|
+You need to send an "Authorization" header containing a base64 url encoded and colon separated username and password after the word "Basic".
|
|
570
|
+
|
|
571
|
+ Authorization: Basic dXNlcm5hbWUxOnBhc3N3b3JkMQ
|
|
572
|
+
|
|
573
|
+This example sends the string "username1:password1".
|
|
574
|
+
|
|
575
|
+#### JWT authentication
|
|
576
|
+
|
|
577
|
+The JWT type requires another (SSO/Identity) server to sign a token that contains claims.
|
|
578
|
+Both servers share a secret so that they can either sign or verify that the signature is valid.
|
|
579
|
+Claims are stored in the `$_SESSION['claims']` variable.
|
|
580
|
+You need to send an "Authorization" header containing a base64 url encoded and dot separated token header, body and signature after the word "Bearer" (read more abou).
|
|
581
|
+
|
|
582
|
+ Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlhdCI6IjE1MzgyMDc2MDUiLCJleHAiOjE1MzgyMDc2MzV9.Z5px_GT15TRKhJCTHhDt5Z6K6LRDSFnLj8U5ok9l7gw
|
|
583
|
+
|
|
584
|
+This example sends the signed string:
|
|
585
|
+
|
|
586
|
+ {
|
|
587
|
+ "sub": "1234567890",
|
|
588
|
+ "name": "John Doe",
|
|
589
|
+ "admin": true,
|
|
590
|
+ "iat": "1538207605",
|
|
591
|
+ "exp": 1538207635
|
|
592
|
+ }
|
|
593
|
+
|
|
594
|
+NB: The JWT implementation only supports the hash based algorithms HS256, HS384 and HS512.
|
|
595
|
+
|
556
|
596
|
### Authorizing tables, columns and records
|
557
|
597
|
|
558
|
598
|
By default all tables are reflected. If you want to restrict access to some tables you may add the 'authorization' middleware
|