
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
nestjs-api-keys
Advanced tools
A NestJS API keys utility which allows you to secure APIs using an API Key based system.
This library only works in APIs made with NestJS.
Install the package using:
npm i nestjs-api-keys
or
yarn add nestjs-api-keys
First, you need to register the ApiKeysModule. You can do that by going to your AppModule and calling the register static method of the ApiKeysModule class:
@Module({
imports: [
ApiKeysModule.register({
apiKeys: [],
}),
],
})
export class AppModule {}
In the apiKeys array you need to provide all available API Keys.
ApiKeysModule.register({
apiKeys: [
{
name: 'For reading users', // Descriptive name
keys: ['supersecretapikey'], // API keys composing this key
permissions: ['users.read'], // Permissions given to this key
},
],
}),
REMEMBER: it is recommended that you DON'T provide directly here these values in production. You should get keys from a .ENV file or any other secure source.
In production you should (for example):
ApiKeysModule.register({
apiKeys: JSON.parse(process.env.API_KEYS_JSON_STRING),
}),
You can secure any endpoint by using the ApiKeyGuard guard:
@UseGuards(
ApiKeyGuard({
permissions: ['users.read'],
}),
)
@Get('users')
async getUsers() {
// Fetch users
}
FAQs
A NestJS utility that allows API keys based security
The npm package nestjs-api-keys receives a total of 11 weekly downloads. As such, nestjs-api-keys popularity was classified as not popular.
We found that nestjs-api-keys demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.