Read-only mirror — the public repositories of the Forgejo instance, refreshed every 10 minutes. The live instance (fg.dieschoenewolke.de) is reachable only over the VPN; clone here with https://git.dieschoenewolke.de/git/<owner>/<repo>.git.
summaryrefslogtreecommitdiff
path: root/src/git-auth-helper.ts
diff options
context:
space:
mode:
authoreric sciple <ericsciple@users.noreply.github.com>2020-03-25 15:12:22 -0400
committerGitHub <noreply@github.com>2020-03-25 15:12:22 -0400
commit18fd0bc59958dd73f02ac7a98cb5995f83e6f1de (patch)
treeb7dd7374364d23c08a542687b7f9033c9e271bc5 /src/git-auth-helper.ts
parente8e736100be926c1708f65609a1458e5e36bda31 (diff)
changes to support ghes alpha release (#199)
Diffstat (limited to 'src/git-auth-helper.ts')
-rw-r--r--src/git-auth-helper.ts16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/git-auth-helper.ts b/src/git-auth-helper.ts
index 06e8912..92763b8 100644
--- a/src/git-auth-helper.ts
+++ b/src/git-auth-helper.ts
@@ -7,12 +7,12 @@ import * as os from 'os'
import * as path from 'path'
import * as regexpHelper from './regexp-helper'
import * as stateHelper from './state-helper'
+import * as urlHelper from './url-helper'
import {default as uuid} from 'uuid/v4'
import {IGitCommandManager} from './git-command-manager'
import {IGitSourceSettings} from './git-source-settings'
const IS_WINDOWS = process.platform === 'win32'
-const HOSTNAME = 'github.com'
const SSH_COMMAND_KEY = 'core.sshCommand'
export interface IGitAuthHelper {
@@ -33,15 +33,15 @@ export function createAuthHelper(
class GitAuthHelper {
private readonly git: IGitCommandManager
private readonly settings: IGitSourceSettings
- private readonly tokenConfigKey: string = `http.https://${HOSTNAME}/.extraheader`
+ private readonly tokenConfigKey: string
+ private readonly tokenConfigValue: string
private readonly tokenPlaceholderConfigValue: string
- private readonly insteadOfKey: string = `url.https://${HOSTNAME}/.insteadOf`
- private readonly insteadOfValue: string = `git@${HOSTNAME}:`
+ private readonly insteadOfKey: string
+ private readonly insteadOfValue: string
private sshCommand = ''
private sshKeyPath = ''
private sshKnownHostsPath = ''
private temporaryHomePath = ''
- private tokenConfigValue: string
constructor(
gitCommandManager: IGitCommandManager,
@@ -51,6 +51,8 @@ class GitAuthHelper {
this.settings = gitSourceSettings || (({} as unknown) as IGitSourceSettings)
// Token auth header
+ const serverUrl = urlHelper.getServerUrl()
+ this.tokenConfigKey = `http.${serverUrl.origin}/.extraheader` // "origin" is SCHEME://HOSTNAME[:PORT]
const basicCredential = Buffer.from(
`x-access-token:${this.settings.authToken}`,
'utf8'
@@ -58,6 +60,10 @@ class GitAuthHelper {
core.setSecret(basicCredential)
this.tokenPlaceholderConfigValue = `AUTHORIZATION: basic ***`
this.tokenConfigValue = `AUTHORIZATION: basic ${basicCredential}`
+
+ // Instead of SSH URL
+ this.insteadOfKey = `url.${serverUrl.origin}/.insteadOf` // "origin" is SCHEME://HOSTNAME[:PORT]
+ this.insteadOfValue = `git@${serverUrl.hostname}:`
}
async configureAuth(): Promise<void> {