simpleAPI HTTP Zugangsdaten übergeben#3339
Open
kevinwieland wants to merge 1 commit intomasterfrom
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the PHP simpleAPI so HTTP callers can optionally pass MQTT credentials, and it switches the API toward using the externally reachable MQTT endpoint instead of the internal one.
Changes:
- Added MQTT credential injection/testing paths in
MqttClientandAuthenticator. - Wired request-supplied
username/passwordintosimpleapi.phpand added read-response debug info. - Changed default configuration to use MQTT port
8883and enabled authentication by default.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
simpleAPI/src/MqttClient.php |
Adds runtime MQTT credential overrides and broker credential testing helpers. |
simpleAPI/src/Authenticator.php |
Expands authentication to validate against MQTT credentials and anonymous-broker access. |
simpleAPI/simpleapi.php |
Passes request credentials into the MQTT client and threads debug info into read responses. |
simpleAPI/config/config.php |
Changes default MQTT port and auth defaults for the simpleAPI configuration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+44
to
+48
| // Fallback: Prüfen ob MQTT Broker ohne Authentifizierung zugänglich ist | ||
| if ($this->checkMqttNoAuth()) { | ||
| return true; | ||
| } | ||
|
|
Comment on lines
+154
to
+156
| // Wenn keine lokalen Benutzer definiert sind oder MqttClient verfügbar ist: | ||
| // Anmeldedaten gegen MQTT Broker testen | ||
| if ($this->mqttClient && (empty($users) || !isset($users[$username]))) { |
Comment on lines
+79
to
+89
| // MQTT-Anmeldedaten aus Parametern übernehmen falls vorhanden | ||
| if (isset($params['username']) && isset($params['password'])) { | ||
| $this->mqttClient->setCredentials($params['username'], $params['password']); | ||
|
|
||
| if ($this->config['debug']) { | ||
| $debugInfo[] = "Using MQTT credentials from parameters: username={$params['username']}"; | ||
| } | ||
| } else { | ||
| // Keine Parameter-Anmeldedaten vorhanden | ||
| if ($this->config['debug']) { | ||
| $debugInfo[] = "No credentials provided via parameters, using config or anonymous access"; |
Comment on lines
+367
to
+370
| // Debug-Informationen hinzufügen wenn vorhanden | ||
| if (!empty($debugInfo) && $this->config['debug']) { | ||
| $result['debug_info'] = $debugInfo; | ||
| } |
| 'mqtt' => [ | ||
| 'server' => 'localhost', | ||
| 'port' => 1884, | ||
| 'port' => 8883, |
Contributor
Author
There was a problem hiding this comment.
@benderl ist es nicht so das 8883 immer verfügbar ist? 1883 geht aufjedenfall nicht, da bei aktiver BV deaktiviert.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Ermöglicht es bei Nutzung der HTTP Variante der simpleAPI optional Zugangsdaten zu übergeben wenn die Benutzerverwaltung genutzt wird.
In diesem Zuge greift die simpleAPI nicht mehr auf den internen Port sondern den von extern erreichbaren zu.
Eine Anonyme Anmeldung ohne Benutzerverwaltung ist nach wie vor möglich.