Commit Graph

26 Commits

Author SHA1 Message Date
DL6ER 92ec8e8d70 Update civetweb v1.12 -> v1.13 (and simplify auth-cookie handling)
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-11-06 12:59:01 +01:00
DL6ER 67a0395390 Redirect PH7 errors into pihole-FTL.log (instead of showing in the browser output) and define gethostname() PHP function.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-06-02 08:52:55 +02:00
DL6ER c92a0e4bc4 Generally assume authentication to ease the development phase until we are actually able to add authentication.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-05-29 20:54:30 +02:00
DL6ER ef5cfe0a17 Add /api/stats/database/upstreams
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-05-27 00:37:16 +02:00
DL6ER c639cf9b6d Actively free expired user sessions to make room for new ones.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-05-27 00:28:30 +02:00
DL6ER c38285461f Automatically log in users when there is no (or an empty) password set in setupVars.conf
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-05-27 00:28:30 +02:00
DL6ER c389f06944 Make HTTP/API session timeout configurable through pihole-FTL.conf
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-05-27 00:28:30 +02:00
DL6ER 8742e140c0 Update user cookie when session is still running.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-05-27 00:28:30 +02:00
DL6ER 76bcef3771 Update timestamp of known client when we see them again.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-05-27 00:28:30 +02:00
DL6ER 2a07c992ab Add option for whether authentication is needed for localhost requests. Defaults to false. (API_AUTH_FOR_LOCALHOST)
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-05-27 00:26:55 +02:00
DL6ER 07285934cd Add more convenience functions and return 400 Bad Request responses when invalid parameters are given to the /api/stats endpoints.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-05-27 00:26:54 +02:00
DL6ER 5bb6a8e82d Add send_json_success() as yet another short convenience function.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-05-27 00:24:20 +02:00
DL6ER 1f78f2f276 Add new send_json_error() and send_json_unauthorized() routines everywhere we are sending an error.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-05-27 00:24:20 +02:00
DL6ER d9aa8bd45f Allow password-less login if WEBPASSWORD is not set or set to an empty string in setupVars.conf.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-05-27 00:24:20 +02:00
DL6ER 3efb39c3af Rename api/http.{c,h} to api/http-common.{c,h}. Separate routing function into api/routes.c.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-05-27 00:24:20 +02:00
DL6ER 0634bf363b Implement correct API response for failed auth requests.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-05-27 00:22:51 +02:00
DL6ER 14a2df5ae2 Print reason for Auth Failure.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-05-27 00:22:51 +02:00
DL6ER 004fb93bbe Add authentication requirement for most API endpoints. Some endpoints are special, e.g., /api/status where GET is allowed for anyone, however, POST is only allowed for authenticated users.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-05-27 00:22:51 +02:00
DL6ER d45ae84ec5 Add attribute malloc as the returned pointer cannot alias any other pointer valid when the function returns.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-05-27 00:22:51 +02:00
DL6ER 34c9091c4a Read actual password from setupVars.conf instead of always substituting 'A'.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-05-27 00:22:51 +02:00
DL6ER 243cfb0c81 Add support for adding domains through the FTL HTTP API.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-05-27 00:15:46 +02:00
DL6ER e51a069d48 Implement DELETE for /api/auth to allow users to actually log out.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-05-27 00:14:46 +02:00
DL6ER 411cf85ef7 Only allow login with correct password.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-05-27 00:14:46 +02:00
DL6ER 99cfb92d63 Add /api/auth/salt
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-05-27 00:14:46 +02:00
DL6ER 0cee19659e Implement client validation in the API. Both, the IP address and the set cookie have to be correct, otherwise the authorization is denied. We also check for the validity of the cookie before permitting the user.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-05-27 00:14:46 +02:00
DL6ER 0a3424bcff Add simple /api/auth implementation. Currently, all passwords are accepted and a login session is valid for 5 minutes.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-05-27 00:14:46 +02:00