From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH proxmox-login-manager] login: fix login for saved ipv6 addresses
Date: Thu, 1 Dec 2022 10:27:34 +0100 [thread overview]
Message-ID: <20221201092734.1171699-1-d.csapak@proxmox.com> (raw)
Since we only string concatenated the host + port, ipv6 addresses were
invalid because their missing [] around the ip. To fix that, use
'Uri's 'toString' method but strip the 'https://' prefix when creating
an Uri object again
This now also allows to enter the 'https://' prefix manually
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
lib/proxmox_login_form.dart | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/lib/proxmox_login_form.dart b/lib/proxmox_login_form.dart
index 706315f..41bf68f 100644
--- a/lib/proxmox_login_form.dart
+++ b/lib/proxmox_login_form.dart
@@ -197,8 +197,7 @@ class _ProxmoxLoginPageState extends State<ProxmoxLoginPage> {
_progressModel
..inProgress = true
..message = 'Connection test...';
- _originController.text =
- '${userModel.origin?.host}:${userModel.origin?.port}';
+ _originController.text = userModel.origin?.toString() ?? '';
_accessDomains = _getAccessDomains();
_usernameController.text = userModel.username!;
if (widget.ticket!.isNotEmpty && userModel.activeSession) {
@@ -279,15 +278,13 @@ class _ProxmoxLoginPageState extends State<ProxmoxLoginPage> {
if (value == null || value.isEmpty) {
return 'Please enter origin';
}
- if (value.startsWith('https://') ||
- value.startsWith('http://')) {
- return 'Do not prefix with scheme';
- }
try {
- Uri.https(value, '');
+ normalizeUrl(value);
return null;
} on FormatException catch (_) {
return 'Invalid URI';
+ } on Exception catch (e) {
+ return 'Invalid URI: $e';
}
},
usernameController: _usernameController,
@@ -412,7 +409,7 @@ class _ProxmoxLoginPageState extends State<ProxmoxLoginPage> {
final settings = await ProxmoxGeneralSettingsModel.fromLocalStorage();
//cleaned form fields
- final origin = Uri.https(_originController.text.trim(), '');
+ final origin = normalizeUrl(_originController.text.trim());
final username = _usernameController.text.trim();
final password =
ticket.isNotEmpty ? ticket : _passwordController.text.trim();
@@ -502,7 +499,7 @@ class _ProxmoxLoginPageState extends State<ProxmoxLoginPage> {
..message = 'Connection test...';
});
var host = _originController.text.trim();
- var apiBaseUrl = Uri.https(host, '');
+ var apiBaseUrl = normalizeUrl(host);
RegExp portRE = new RegExp(r":\d{1,5}$");
@@ -667,3 +664,14 @@ class ProxmoxCertificateErrorDialog extends StatelessWidget {
);
}
}
+
+Uri normalizeUrl(String urlText) {
+ if (urlText.startsWith('https://')) {
+ urlText = urlText.substring('https://'.length);
+ }
+ if (urlText.startsWith('http://')) {
+ throw new Exception("HTTP without TLS is not supported");
+ }
+
+ return Uri.https(urlText, '');
+}
--
2.30.2
next reply other threads:[~2022-12-01 9:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-01 9:27 Dominik Csapak [this message]
2023-03-15 8:19 ` [pve-devel] applied: " Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221201092734.1171699-1-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.