feat: add reauthentication - #36
Conversation
WalkthroughThe changes introduce a new "Reauthenticate" feature to the Tailscale plugin, allowing users to force a reauthentication of their Tailscale node. The UI now displays whether the current connection is established via Tailscale and conditionally disables critical actions (like erasing config or reauthenticating) when connected via Tailscale to prevent accidental disconnection. Backend logic is added to handle immediate key expiration, with safeguards to prevent this action if currently connected via Tailscale. New localization strings are introduced for the updated UI elements and informational labels. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant SettingsPage
participant JSFunction
participant ConfigPHP
participant LocalAPI
participant InfoPHP
User->>SettingsPage: Clicks "Reauthenticate" button
SettingsPage->>JSFunction: Calls expireTailscaleKeyNow()
JSFunction->>ConfigPHP: POST /plugins/tailscale/include/data/Config.php (action=expire-key)
ConfigPHP->>InfoPHP: Calls connectedViaTS()
alt Not connected via Tailscale
ConfigPHP->>LocalAPI: Calls expireKey()
LocalAPI->>LocalAPI: POST to tailscale API (set-expiry-sooner?expiry=0)
ConfigPHP-->>JSFunction: Success (page reload)
else Connected via Tailscale
ConfigPHP-->>JSFunction: Error (exception thrown)
end
JSFunction->>SettingsPage: Reloads page
Poem
Tip ⚡💬 Agentic Chat (Pro Plan, General Availability)
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (6)
🧰 Additional context used🧬 Code Graph Analysis (2)src/usr/local/emhttp/plugins/tailscale/include/Pages/Info.php (2)
src/usr/local/emhttp/plugins/tailscale/include/Pages/Settings.php (1)
🪛 PHPStan (2.0.3)src/usr/local/emhttp/plugins/tailscale/include/Pages/Info.php35-35: Cannot call method connectedViaTS() on mixed. (method.nonObject) 35-35: Cannot call method tr() on mixed. (method.nonObject) 35-35: Cannot call method tr() on mixed. (method.nonObject) 35-35: Cannot call method tr() on mixed. (method.nonObject) 35-35: Parameter #1 $title of static method Tailscale\Utils::printRow() expects string, mixed given. (argument.type) 35-35: Parameter #2 $value of static method Tailscale\Utils::printRow() expects string, mixed given. (argument.type) src/usr/local/emhttp/plugins/tailscale/include/data/Config.php236-236: Cannot call method connectedViaTS() on mixed. (method.nonObject) src/usr/local/emhttp/plugins/tailscale/include/Tailscale/Info.php378-378: Argument of an invalid type mixed supplied for foreach, only iterables are supported. (foreach.nonIterable) 393-393: Argument of an invalid type mixed supplied for foreach, only iterables are supported. (foreach.nonIterable) 394-394: Cannot access property $ExitNode on mixed. (property.nonObject) 395-395: Cannot access property $ID on mixed. (property.nonObject) 395-395: Method Tailscale\Info::getCurrentExitNode() should return string but returns mixed. (return.type) 404-404: Parameter #2 $haystack of function in_array expects array, mixed given. (argument.type) src/usr/local/emhttp/plugins/tailscale/include/Pages/Settings.php17-17: Cannot access property $Enable on mixed. (property.nonObject) 18-18: Parameter #1 $tr of class Tailscale\Info constructor expects Tailscale\Translator, mixed given. (argument.type) 19-19: Cannot call method connectedViaTS() on mixed. (method.nonObject) 173-173: Cannot call method tr() on mixed. (method.nonObject) 173-173: Parameter #1 (mixed) of echo cannot be converted to string. (echo.nonString) 176-176: Cannot call method tr() on mixed. (method.nonObject) 176-176: Parameter #1 (mixed) of echo cannot be converted to string. (echo.nonString) 178-178: Cannot call method tr() on mixed. (method.nonObject) 178-178: Parameter #1 (mixed) of echo cannot be converted to string. (echo.nonString) 182-182: Cannot call method tr() on mixed. (method.nonObject) 182-182: Parameter #1 (mixed) of echo cannot be converted to string. (echo.nonString) 187-187: Cannot call method tr() on mixed. (method.nonObject) 187-187: Parameter #1 (mixed) of echo cannot be converted to string. (echo.nonString) 189-189: Cannot call method tr() on mixed. (method.nonObject) 189-189: Cannot call method tr() on mixed. (method.nonObject) 189-189: Parameter #1 (mixed) of echo cannot be converted to string. (echo.nonString) 189-189: Parameter #1 (mixed) of echo cannot be converted to string. (echo.nonString) 🔇 Additional comments (14)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
Warning Docstrings generation is only available on the Pro tier. |
Summary by CodeRabbit