New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mongodb-auth-aws-improved

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongodb-auth-aws-improved

MONGODB-AWS authentication with arbitrary refrshing credentials

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

MongoDB-AWS Auth with arbitrary AWS.Credentials

MongoDB authentication with AWS IAM is a very convenient means of authentication with MongoDB Atlas that allows one to delegate database authentication to AWS IAM, reducing the number of auth systems one needs to manage.

However, the native implementation of this authentication, as provided by MongoDB's published client libraries, only support static credentials to login, and a subset of the mechanisms by which refreshing credentials are generated (namely, EC2 instance credentials and ECS agent credentials). This makes the client libraries very difficult to use for other types of credentials which expire and are automatically refreshed over time, such as credentials for EKS pods generated by IAM roles for service accounts, credentials provided via SAML or OIDC, or any role assumed via role chaining. When a Mongo connection is established using AWS IAM authentication with one of these role types, the connection initially succeeds, but reconnections or scaling up the connection pool later on will fail when the initial set of credentials has expired.

The AWS SDK provides Credentials objects that automatically refresh, but the MongoDB drivers cannot utilize these; this project aims to fix that by patching the behavior of the Mongo driver to use the dynamic credentials of a AWS.Credentials object to establish new connections.

Example

const { MongoClient } = require('mongodb');
const { getMongoAwsAuth } = require('mongodb-auth-aws-improved');

// ... retrieve AWS credentials
let credentialsOrProvider; // can be an AWS.Credentials from aws-sdk v2, or a CredentialProvider from aws-sdk v3

const client = await new MongoClient(uri, { auth: getMongoAwsAuth(credentialsOrProvider) }).connect();

FAQs

Package last updated on 03 Aug 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc