Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@azure/core-auth
Advanced tools
Provides low-level interfaces and helper methods for authentication in Azure SDK
The @azure/core-auth package provides a standard way to manage authentication and authorization across the Azure SDKs in JavaScript. It includes a set of interfaces and classes that can be used to implement authentication mechanisms such as token credentials, and to integrate with various Azure services that require authentication.
TokenCredential Interface
The TokenCredential interface is a core component that allows for the implementation of custom authentication mechanisms. When you implement this interface, you can use it with Azure SDKs that accept credential objects for authentication. The code sample demonstrates how to create a custom credential class that extends TokenCredential.
class MyCredential extends TokenCredential {
async getToken(scopes, options) {
// Your logic to acquire a token
return { token: 'your_token', expiresOnTimestamp: 12345 };
}
}
DefaultAzureCredential
DefaultAzureCredential is a class that provides a seamless authentication experience across Azure services. It tries multiple credentials in a specific order, attempting to find the best one that works for the current environment. This code sample shows how to instantiate DefaultAzureCredential, which can then be passed to other Azure SDK clients for authentication.
const { DefaultAzureCredential } = require('@azure/identity');
const credential = new DefaultAzureCredential();
The AWS SDK for JavaScript provides a similar set of functionalities for AWS services as @azure/core-auth does for Azure. It includes mechanisms for authenticating against AWS services. However, it is specifically tailored for AWS and not directly compatible with Azure services.
This library offers authentication and authorization utilities for Google Cloud services. Similar to @azure/core-auth, it provides a way to obtain credentials and authenticate API requests. The main difference lies in the ecosystem it targets, focusing on Google Cloud instead of Azure.
The @azure/core-auth
package provides core interfaces and helper methods for authenticating with Azure services using Azure Active Directory and other authentication schemes common across the Azure SDK. As a "core" library, it shouldn't need to be added as a dependency to any user code, only other Azure SDK libraries.
Install this library using npm as follows
npm install @azure/core-auth
The TokenCredential
interface represents a credential capable of providing an authentication token. The @azure/identity
package contains various credentials that implement the TokenCredential
interface.
The AzureKeyCredential
is a static key-based credential that supports key rotation via the update
method. Use this when a single secret value is needed for authentication, e.g. when using a shared access key.
The AzureNamedKeyCredential
is a static name/key-based credential that supports name and key rotation via the update
method. Use this when both a secret value and a label are needed, e.g. when using a shared access key and shared access key name.
The AzureSASCredential
is a static signature-based credential that supports updating the signature value via the update
method. Use this when using a shared access signature.
const { AzureKeyCredential } = require("@azure/core-auth");
const credential = new AzureKeyCredential("secret value");
// prints: "secret value"
console.log(credential.key);
credential.update("other secret value");
// prints: "other secret value"
console.log(credential.key);
const { AzureNamedKeyCredential } = require("@azure/core-auth");
const credential = new AzureNamedKeyCredential("ManagedPolicy", "secret value");
// prints: "ManagedPolicy, secret value"
console.log(`${credential.name}, ${credential.key}`);
credential.update("OtherManagedPolicy", "other secret value");
// prints: "OtherManagedPolicy, other secret value"
console.log(`${credential.name}, ${credential.key}`);
const { AzureSASCredential } = require("@azure/core-auth");
const credential = new AzureSASCredential("signature1");
// prints: "signature1"
console.log(credential.signature);
credential.update("signature2");
// prints: "signature2"
console.log(credential.signature);
You can build and run the tests locally by executing rushx test
. Explore the test
folder to see advanced usage and behavior of the public classes.
If you run into issues while using this library, please feel free to file an issue.
If you'd like to contribute to this library, please read the contributing guide to learn more about how to build and test the code.
FAQs
Provides low-level interfaces and helper methods for authentication in Azure SDK
The npm package @azure/core-auth receives a total of 1,948,819 weekly downloads. As such, @azure/core-auth popularity was classified as popular.
We found that @azure/core-auth demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.