
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
@octokit/auth
Advanced tools
GitHub API authentication library for browsers and Node.js
GitHub supports 4 authentication strategies. They are all implemented in @octokit/auth
.
Browsers |
Load
|
---|---|
Node |
Install with
|
const auth = createBasicAuth({
username: "monatheoctocat",
password: "secret",
on2fa() {
return prompt("Two-factor authentication Code:");
}
});
Each function exported by @octokit/auth
returns an async auth
function.
The auth
function resolves with an authentication object. If multiple authentication types are supported, a type
parameter can be passed.
const { token } = await auth({ type: "token" });
Additionally, auth.hook()
can be used to directly hook into @octokit/request
. If multiple authentication types are supported, the right authentication type will be applied automatically based on the request URL.
const requestWithAuth = request.defaults({
request: {
hook: auth.hook
}
});
const { data: authorizations } = await requestWithAuth("GET /authorizations");
Module | Strategy Options | Auth Options | Authentication objects | ||
---|---|---|---|---|---|
|
|
|
| ||
|
|
|
|
|
|
|
|
|
|
| |
|
|
|
|
| |
|
|
|
|
Example
const auth = createTokenAuth("1234567890abcdef1234567890abcdef12345678");
const { token, tokenType } = await auth();
See @octokit/auth-token for more details.
Example
const auth = createBasicAuth({
username: "octocat",
password: "secret",
async on2Fa() {
// prompt user for the one-time password retrieved via SMS or authenticator app
return prompt("Two-factor authentication Code:");
}
});
const { token } = await auth();
const { totp } = await auth({
type: "basic"
});
See @octokit/auth-basic
for more details.
Example
const auth = createAppAuth({
id: 1,
privateKey: "-----BEGIN RSA PRIVATE KEY-----\n..."
});
const appAuthentication = await auth({ type: "auth" });
const installationAuthentication = await auth({
type: "installation",
installationId: 123
});
See @octokit/auth-app for more details.
Example
const auth = createOAuthAppAuth({
clientId: "1234567890abcdef1234",
clientSecret: "1234567890abcdef1234567890abcdef12345678",
code: "random123" // code from OAuth web flow, see https://git.io/fhd1D
});
const appAuthentication = await auth({
type: "oauth-app",
url: "/orgs/:org/repos"
});
const tokenAuthentication = await auth({ type: "token" });
See @octokit/auth-oauth-app for more details.
Example
// expects process.env.GITHUB_ACTION and process.env.GITHUB_TOKEN to be set
const auth = createActionAuth();
const { token } = await auth();
See @octokit/auth-action for more details.
FAQs
GitHub API authentication library for browsers and Node.js
The npm package @octokit/auth receives a total of 1,949 weekly downloads. As such, @octokit/auth popularity was classified as popular.
We found that @octokit/auth demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.