Socket
Socket
Sign inDemoInstall

mongodb-auth-aws-improved

Package Overview
Dependencies
98
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    mongodb-auth-aws-improved

MONGODB-AWS authentication with arbitrary refrshing credentials


Version published
Weekly downloads
331
increased by41.45%
Maintainers
1
Install size
474 kB
Created
Weekly downloads
 

Readme

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

Last updated on 03 Aug 2022

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc