Support Apple Remote Desktop auth via account username+password
RoyalVNCKit prioritizes .diffieHellman (ARD) over .vnc during handshake when both are offered. My delegate adapter was passing an empty username to VNCUsernamePasswordCredential, so any Mac with user-account screen sharing enabled rejected the credential before .vnc fallback could happen. Fix: persist a username on SavedConnection and pipe it through to the credential callback. Leave blank to use the VNC-only password path. AddConnection footer now explains the two Mac paths: • User account (ARD) — macOS short name + full account password • VNC-only password — blank username + ≤8 char password Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -24,6 +24,7 @@ public struct AddConnectionView: View {
|
||||
@State private var displayName = ""
|
||||
@State private var host = ""
|
||||
@State private var port = "5900"
|
||||
@State private var username = ""
|
||||
@State private var password = ""
|
||||
@State private var revealPassword = false
|
||||
@State private var colorTag: ColorTag = .blue
|
||||
@@ -45,6 +46,17 @@ public struct AddConnectionView: View {
|
||||
!host.trimmingCharacters(in: .whitespaces).isEmpty
|
||||
}
|
||||
|
||||
private var authFooterText: String {
|
||||
if isEditing {
|
||||
return "Leave password blank to keep the current one. Stored in iOS Keychain (this device only)."
|
||||
}
|
||||
return """
|
||||
Two Mac paths:
|
||||
• User account (ARD) — enter your macOS short name + full account password. No length limit. Enabled in System Settings → Sharing → Screen Sharing → Allow access for…
|
||||
• VNC-only password — leave the username blank; macOS truncates to 8 characters. Enabled via Screen Sharing → ⓘ → "VNC viewers may control screen with password".
|
||||
"""
|
||||
}
|
||||
|
||||
public var body: some View {
|
||||
NavigationStack {
|
||||
Form {
|
||||
@@ -75,12 +87,17 @@ public struct AddConnectionView: View {
|
||||
}
|
||||
|
||||
Section {
|
||||
TextField("Username (optional)", text: $username)
|
||||
#if os(iOS)
|
||||
.textInputAutocapitalization(.never)
|
||||
#endif
|
||||
.autocorrectionDisabled()
|
||||
HStack {
|
||||
Group {
|
||||
if revealPassword {
|
||||
TextField("VNC password", text: $password)
|
||||
TextField("Password", text: $password)
|
||||
} else {
|
||||
SecureField(isEditing ? "Replace password" : "VNC password",
|
||||
SecureField(isEditing ? "Replace password" : "Password",
|
||||
text: $password)
|
||||
}
|
||||
}
|
||||
@@ -96,9 +113,7 @@ public struct AddConnectionView: View {
|
||||
} header: {
|
||||
Text("Authentication")
|
||||
} footer: {
|
||||
Text(isEditing
|
||||
? "Leave blank to keep the current password. Stored in iOS Keychain (this device only)."
|
||||
: "macOS Screen Sharing's VNC password is limited to 8 characters. Stored in iOS Keychain (this device only).")
|
||||
Text(authFooterText)
|
||||
}
|
||||
|
||||
Section {
|
||||
@@ -199,6 +214,7 @@ public struct AddConnectionView: View {
|
||||
displayName = existing.displayName
|
||||
host = existing.host
|
||||
port = String(existing.port)
|
||||
username = existing.username
|
||||
colorTag = existing.colorTag
|
||||
quality = existing.quality
|
||||
inputMode = existing.inputMode
|
||||
@@ -214,10 +230,12 @@ public struct AddConnectionView: View {
|
||||
|
||||
private func save() {
|
||||
let portInt = Int(port) ?? 5900
|
||||
let trimmedUsername = username.trimmingCharacters(in: .whitespaces)
|
||||
if let existing = editing {
|
||||
existing.displayName = displayName
|
||||
existing.host = host
|
||||
existing.port = portInt
|
||||
existing.username = trimmedUsername
|
||||
existing.colorTag = colorTag
|
||||
existing.quality = quality
|
||||
existing.inputMode = inputMode
|
||||
@@ -232,6 +250,7 @@ public struct AddConnectionView: View {
|
||||
displayName: displayName,
|
||||
host: host,
|
||||
port: portInt,
|
||||
username: trimmedUsername,
|
||||
colorTag: colorTag,
|
||||
quality: quality,
|
||||
inputMode: inputMode,
|
||||
|
||||
Reference in New Issue
Block a user