mirror of
https://github.com/Eugeny/tabby.git
synced 2025-09-17 13:54:34 +00:00
agent auth
This commit is contained in:
@@ -30,7 +30,7 @@
|
|||||||
"native-process-working-directory": "^1.0.2",
|
"native-process-working-directory": "^1.0.2",
|
||||||
"npm": "6",
|
"npm": "6",
|
||||||
"rxjs": "^7.5.7",
|
"rxjs": "^7.5.7",
|
||||||
"russh": "^0.0.1-alpha.9",
|
"russh": "^0.0.1-alpha.10",
|
||||||
"source-map-support": "^0.5.20",
|
"source-map-support": "^0.5.20",
|
||||||
"v8-compile-cache": "^2.3.0",
|
"v8-compile-cache": "^2.3.0",
|
||||||
"yargs": "^17.7.2"
|
"yargs": "^17.7.2"
|
||||||
|
@@ -3613,10 +3613,10 @@ run-queue@^1.0.0, run-queue@^1.0.3:
|
|||||||
dependencies:
|
dependencies:
|
||||||
aproba "^1.1.1"
|
aproba "^1.1.1"
|
||||||
|
|
||||||
russh@^0.0.1-alpha.9:
|
russh@^0.0.1-alpha.10:
|
||||||
version "0.0.1-alpha.9"
|
version "0.0.1-alpha.10"
|
||||||
resolved "https://registry.yarnpkg.com/russh/-/russh-0.0.1-alpha.9.tgz#d7b11f70bcdbd54caa13cf0a4f3748a185cb0b08"
|
resolved "https://registry.yarnpkg.com/russh/-/russh-0.0.1-alpha.10.tgz#5d90ca214be37ef6b527dcee66ef72ca04744c84"
|
||||||
integrity sha512-CfA6T7YsIvPdT1fgtCMqoLkiJnNbjI1V5xsq8aZLe8SevIiIJSMgg8jUl8hJgQX7hR9pUNhG646BPuv/I/1OCA==
|
integrity sha512-yi7te2CcasiD16RpDKVUIEbvnJ4o66z4+BGg+fQjMGw378AWJ+6e0z+JXccgrKPsEOGDzvSTR5DwPCfea7X3CA==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@napi-rs/cli" "^2.18.3"
|
"@napi-rs/cli" "^2.18.3"
|
||||||
|
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
import * as fs from 'mz/fs'
|
// import * as fs from 'mz/fs'
|
||||||
import * as crypto from 'crypto'
|
import * as crypto from 'crypto'
|
||||||
import colors from 'ansi-colors'
|
import colors from 'ansi-colors'
|
||||||
import stripAnsi from 'strip-ansi'
|
import stripAnsi from 'strip-ansi'
|
||||||
import * as shellQuote from 'shell-quote'
|
import * as shellQuote from 'shell-quote'
|
||||||
import { Injector } from '@angular/core'
|
import { Injector } from '@angular/core'
|
||||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
|
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
|
||||||
import { ConfigService, FileProvidersService, HostAppService, NotificationsService, Platform, PlatformService, PromptModalComponent, LogService, Logger, TranslateService } from 'tabby-core'
|
import { ConfigService, FileProvidersService, HostAppService, NotificationsService, PlatformService, PromptModalComponent, LogService, Logger, TranslateService } from 'tabby-core'
|
||||||
import { Socket } from 'net'
|
import { Socket } from 'net'
|
||||||
import { Subject, Observable } from 'rxjs'
|
import { Subject, Observable } from 'rxjs'
|
||||||
import { HostKeyPromptModalComponent } from '../components/hostKeyPromptModal.component'
|
import { HostKeyPromptModalComponent } from '../components/hostKeyPromptModal.component'
|
||||||
@@ -19,7 +19,7 @@ import { X11Socket } from './x11'
|
|||||||
import { supportedAlgorithms } from '../algorithms'
|
import { supportedAlgorithms } from '../algorithms'
|
||||||
import * as russh from 'russh'
|
import * as russh from 'russh'
|
||||||
|
|
||||||
const WINDOWS_OPENSSH_AGENT_PIPE = '\\\\.\\pipe\\openssh-ssh-agent'
|
// const WINDOWS_OPENSSH_AGENT_PIPE = '\\\\.\\pipe\\openssh-ssh-agent'
|
||||||
|
|
||||||
export interface Prompt {
|
export interface Prompt {
|
||||||
prompt: string
|
prompt: string
|
||||||
@@ -90,7 +90,6 @@ export class SSHSession {
|
|||||||
private hostApp: HostAppService
|
private hostApp: HostAppService
|
||||||
private platform: PlatformService
|
private platform: PlatformService
|
||||||
private notifications: NotificationsService
|
private notifications: NotificationsService
|
||||||
// private zone: NgZone
|
|
||||||
private fileProviders: FileProvidersService
|
private fileProviders: FileProvidersService
|
||||||
private config: ConfigService
|
private config: ConfigService
|
||||||
private translate: TranslateService
|
private translate: TranslateService
|
||||||
@@ -108,7 +107,6 @@ export class SSHSession {
|
|||||||
this.hostApp = injector.get(HostAppService)
|
this.hostApp = injector.get(HostAppService)
|
||||||
this.platform = injector.get(PlatformService)
|
this.platform = injector.get(PlatformService)
|
||||||
this.notifications = injector.get(NotificationsService)
|
this.notifications = injector.get(NotificationsService)
|
||||||
// this.zone = injector.get(NgZone)
|
|
||||||
this.fileProviders = injector.get(FileProvidersService)
|
this.fileProviders = injector.get(FileProvidersService)
|
||||||
this.config = injector.get(ConfigService)
|
this.config = injector.get(ConfigService)
|
||||||
this.translate = injector.get(TranslateService)
|
this.translate = injector.get(TranslateService)
|
||||||
@@ -123,26 +121,26 @@ export class SSHSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async init (): Promise<void> {
|
async init (): Promise<void> {
|
||||||
if (this.hostApp.platform === Platform.Windows) {
|
// TODO if (this.hostApp.platform === Platform.Windows) {
|
||||||
if (this.config.store.ssh.agentType === 'auto') {
|
// if (this.config.store.ssh.agentType === 'auto') {
|
||||||
if (await fs.exists(WINDOWS_OPENSSH_AGENT_PIPE)) {
|
// if (await fs.exists(WINDOWS_OPENSSH_AGENT_PIPE)) {
|
||||||
this.agentPath = WINDOWS_OPENSSH_AGENT_PIPE
|
// this.agentPath = WINDOWS_OPENSSH_AGENT_PIPE
|
||||||
} else {
|
// } else {
|
||||||
if (
|
// if (
|
||||||
await this.platform.isProcessRunning('pageant.exe') ||
|
// await this.platform.isProcessRunning('pageant.exe') ||
|
||||||
await this.platform.isProcessRunning('gpg-agent.exe')
|
// await this.platform.isProcessRunning('gpg-agent.exe')
|
||||||
) {
|
// ) {
|
||||||
this.agentPath = 'pageant'
|
// this.agentPath = 'pageant'
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
} else if (this.config.store.ssh.agentType === 'pageant') {
|
// } else if (this.config.store.ssh.agentType === 'pageant') {
|
||||||
this.agentPath = 'pageant'
|
// this.agentPath = 'pageant'
|
||||||
} else {
|
// } else {
|
||||||
this.agentPath = this.config.store.ssh.agentPath || WINDOWS_OPENSSH_AGENT_PIPE
|
// this.agentPath = this.config.store.ssh.agentPath || WINDOWS_OPENSSH_AGENT_PIPE
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
this.agentPath = process.env.SSH_AUTH_SOCK!
|
// this.agentPath = process.env.SSH_AUTH_SOCK!
|
||||||
}
|
// }
|
||||||
|
|
||||||
this.remainingAuthMethods = [{ type: 'none' }]
|
this.remainingAuthMethods = [{ type: 'none' }]
|
||||||
if (!this.profile.options.auth || this.profile.options.auth === 'publicKey') {
|
if (!this.profile.options.auth || this.profile.options.auth === 'publicKey') {
|
||||||
@@ -171,11 +169,11 @@ export class SSHSession {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!this.profile.options.auth || this.profile.options.auth === 'agent') {
|
if (!this.profile.options.auth || this.profile.options.auth === 'agent') {
|
||||||
if (!this.agentPath) {
|
// if (!this.agentPath) {
|
||||||
this.emitServiceMessage(colors.bgYellow.yellow.black(' ! ') + ` Agent auth selected, but no running agent is detected`)
|
// this.emitServiceMessage(colors.bgYellow.yellow.black(' ! ') + ` Agent auth selected, but no running agent is detected`)
|
||||||
} else {
|
// } else {
|
||||||
this.remainingAuthMethods.push({ type: 'agent' })
|
this.remainingAuthMethods.push({ type: 'agent' })
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
if (!this.profile.options.auth || this.profile.options.auth === 'password') {
|
if (!this.profile.options.auth || this.profile.options.auth === 'password') {
|
||||||
this.remainingAuthMethods.push({ type: 'password' })
|
this.remainingAuthMethods.push({ type: 'password' })
|
||||||
@@ -545,6 +543,17 @@ export class SSHSession {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (method.type === 'agent') {
|
||||||
|
try {
|
||||||
|
const result = await this.ssh.authenticateWithAgent(this.authUsername)
|
||||||
|
if (result) {
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
this.emitServiceMessage(colors.bgYellow.yellow.black(' ! ') + ` Failed to authenticate using agent: ${e}`)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user