feat(webui / rest api): Add basic HTTP authentication for WebUI + REST API #197
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add Basic HTTP authentication scheme for WebUI and REST API endpoints
Configuration
The authentication for WebUI and REST API needs to be configured via WebUI:
Settings > Configuration > Section 'WebUI' > Authentication
or during initial setup procedure (Initial Setup Wizard).Default Configuration
Authentication disabled (Opt-In feature, not breaking anything; may change in newer releases)
WebUI Security
The authentication process is handled using web browsers default solution (built-in basic authentication popup). After authentication was successful the browser is caching the credentials for the requested domain / realm. As long browsing the same domain / security area, no more authentication is required, cached authentication data is used instead. This cache is usually cleared by e.g. closing the browser.
REST API Endpoint Security
Usage
Authorization
header to REST API endpoint requestBasic
concatenated with Base64 encodedUSERNAME:PASSWORD
, e.g.Basic abcdefghijklnm=
http://{USERNAME}:{PASSWORD}@{IP-ADDRESS}/{REST API Endpoint}
, e.g.http://username:password@192.168.4.1/info
Endpoint Response
If authorization is enabled and
Authorization
header is missing or authorization is rejected, system is respondingwith status
401 Unauthorized
. Check REST API response message to get more details / rejection reason.Further adaptions
param_tooltip.css
(style is already used in 3 files)Usage statistics
Before (based on ESP32):
RAM: [= ] 14.3% (used 46972 bytes from 327680 bytes)
Flash: [========= ] 87.9% (used 1710949 bytes from 1945600 bytes)
After:
RAM: [= ] 14.4% (used 47116 bytes from 327680 bytes)
Flash: [========= ] 88.1% (used 1713489 bytes from 1945600 bytes)
Authentication implementation is derived/inspired from jomjol#2241. Thanks to @crasu for the template.