Protect local Tailscale sign-in credentials

This commit is contained in:
Ian Gulliver
2026-10-21 07:11:55 -07:00
parent 4f88f8a4f4
commit 0d3ed1fdd3
4 changed files with 60 additions and 6 deletions
+5 -1
View File
@@ -331,7 +331,11 @@ enum Server {
}
static func tailnet(_ loopback: URL) async throws -> TailnetInfo {
let (data, response) = try await URLSession.shared.data(from: loopback.appending(path: "api/tailnet"))
let credential = URL.applicationSupportDirectory.appending(path: "byre/loopback-token")
let token = try String(contentsOf: credential, encoding: .utf8)
var request = URLRequest(url: loopback.appending(path: "api/tailnet"))
request.setValue("Bearer \(token)", forHTTPHeaderField: "Authorization")
let (data, response) = try await URLSession.shared.data(for: request)
guard (response as? HTTPURLResponse)?.statusCode == 200 else {
throw ProcessFailure(errorDescription: "\(loopback.absoluteString)/api/tailnet: \(String(decoding: data, as: UTF8.self))")
}