mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2025-06-03 11:11:12 +00:00
Add auth support (#21)
* Updates * Update * Update * Update * Update * Yarn sometimes prefers npmrc, so use same token * Description * Update readme * Feedback * Add type * new toolkit and scoped registries * npmrc in RUNNER_TEMP * Dont always auth * Try exporting blank token * Get auth working for now pending runner changes * Fix string interpolation for auth token. * Don't export both userconfigs * Update authutil.js * Add single quotes for authString * Fix the registry string. * Use userconfig and append trailing slash * Keep in root of repo * Try just adding auth token * Remove auth token * Try changes again * Add tests * Npm and GPR samples * Add types
This commit is contained in:
parent
0675b87d74
commit
78148dae50
391 changed files with 79848 additions and 43 deletions
node_modules/@octokit/rest/plugins/authentication-deprecated
40
node_modules/@octokit/rest/plugins/authentication-deprecated/before-request.js
generated
vendored
Normal file
40
node_modules/@octokit/rest/plugins/authentication-deprecated/before-request.js
generated
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
module.exports = authenticationBeforeRequest
|
||||
|
||||
const btoa = require('btoa-lite')
|
||||
const uniq = require('lodash.uniq')
|
||||
|
||||
function authenticationBeforeRequest (state, options) {
|
||||
if (!state.auth.type) {
|
||||
return
|
||||
}
|
||||
|
||||
if (state.auth.type === 'basic') {
|
||||
const hash = btoa(`${state.auth.username}:${state.auth.password}`)
|
||||
options.headers['authorization'] = `Basic ${hash}`
|
||||
return
|
||||
}
|
||||
|
||||
if (state.auth.type === 'token') {
|
||||
options.headers['authorization'] = `token ${state.auth.token}`
|
||||
return
|
||||
}
|
||||
|
||||
if (state.auth.type === 'app') {
|
||||
options.headers['authorization'] = `Bearer ${state.auth.token}`
|
||||
const acceptHeaders = options.headers['accept'].split(',')
|
||||
.concat('application/vnd.github.machine-man-preview+json')
|
||||
options.headers['accept'] = uniq(acceptHeaders).filter(Boolean).join(',')
|
||||
return
|
||||
}
|
||||
|
||||
options.url += options.url.indexOf('?') === -1 ? '?' : '&'
|
||||
|
||||
if (state.auth.token) {
|
||||
options.url += `access_token=${encodeURIComponent(state.auth.token)}`
|
||||
return
|
||||
}
|
||||
|
||||
const key = encodeURIComponent(state.auth.key)
|
||||
const secret = encodeURIComponent(state.auth.secret)
|
||||
options.url += `client_id=${key}&client_secret=${secret}`
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue