mirror of
				https://github.com/actions/checkout.git
				synced 2025-11-01 02:28:40 +08:00 
			
		
		
		
	Support multiple tokens
This commit is contained in:
		
							parent
							
								
									b80ff79f17
								
							
						
					
					
						commit
						e5ddb3da76
					
				|  | @ -54,13 +54,22 @@ class GitAuthHelper { | ||||||
|     // Token auth header
 |     // Token auth header
 | ||||||
|     const serverUrl = urlHelper.getServerUrl(this.settings.githubServerUrl) |     const serverUrl = urlHelper.getServerUrl(this.settings.githubServerUrl) | ||||||
|     this.tokenConfigKey = `http.${serverUrl.origin}/.extraheader` // "origin" is SCHEME://HOSTNAME[:PORT]
 |     this.tokenConfigKey = `http.${serverUrl.origin}/.extraheader` // "origin" is SCHEME://HOSTNAME[:PORT]
 | ||||||
|  |     const authTokenArray = this.settings.authToken.split("\n") | ||||||
|  |     assert.ok(authTokenArray, "Token array not defined") | ||||||
|  |     this.tokenConfigValue = `` | ||||||
|  |     for (const aToken of authTokenArray) { | ||||||
|         const basicCredential = Buffer.from( |         const basicCredential = Buffer.from( | ||||||
|       `x-access-token:${this.settings.authToken}`, |               `x-access-token:${aToken}`, | ||||||
|               'utf8' |               'utf8' | ||||||
|             ).toString('base64') |             ).toString('base64') | ||||||
|         core.setSecret(basicCredential) |         core.setSecret(basicCredential) | ||||||
|     this.tokenPlaceholderConfigValue = `AUTHORIZATION: basic ***` |         if (this.tokenConfigValue == null) | ||||||
|             this.tokenConfigValue = `AUTHORIZATION: basic ${basicCredential}` |             this.tokenConfigValue = `AUTHORIZATION: basic ${basicCredential}` | ||||||
|  |         else | ||||||
|  |             this.tokenConfigValue.concat(`\nAUTHORIZATION: basic ${basicCredential}`) | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     this.tokenPlaceholderConfigValue = `AUTHORIZATION: basic ***` | ||||||
| 
 | 
 | ||||||
|     // Instead of SSH URL
 |     // Instead of SSH URL
 | ||||||
|     this.insteadOfKey = `url.${serverUrl.origin}/.insteadOf` // "origin" is SCHEME://HOSTNAME[:PORT]
 |     this.insteadOfKey = `url.${serverUrl.origin}/.insteadOf` // "origin" is SCHEME://HOSTNAME[:PORT]
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Julius Lehmann
						Julius Lehmann