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

@harperdb/hdb-cf-auth-azuread

Package Overview
Dependencies
Maintainers
5
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@harperdb/hdb-cf-auth-azuread

Azure AD auth for HarperDB Custom Functions

  • 1.0.1
  • latest
  • npm
  • Socket score

Version published
Maintainers
5
Created
Source

HarperDB Azure Active Directory Authentication

This package is an Active Directory authentication validator for a HaperDB Custom Function.

This adds the ability to secure database access with an Azure Active Directory application to validate against AD Users and Roles.

How To Use

  1. Create an Azure Active Directory application with the desired users and roles.
  2. Include the ClientID, AuthorityURL, and ClientSecret as environment variables.
  3. Include this package in the routes defition file (i.e. $CUSTOM_FUNCTION_DIR/routes/index.js)
  4. Add the validate function to the prevalidation handler for endpoints that should use AAD Authentication.

Environment Variables

AAD_CLIENT_ID="the client id for the AAD app" AAD_AUTH_URL="the authority url for the AAD app" AAD_CLIENT_SECRET="the client secret for the AAD app"

Example Route and POST

Route Definition

// /routes/index.js

const aadAuth = require('harperdb-active-directory-auth')

module.exports = async (server, { hdbCore, logger }) => {
  // CREATE A DATA RECORD
  server.route({
    url: '/:schema/:table',
    preValidation: (request, response, next) => aadAuth.validate(request, response, next, hdbCore, logger),
    method: 'POST',
    handler: (request) => {
      const { schema, table } = request.params;
      const { records } = request.body;
      request.body = {
         operation: 'insert',
         schema,
         table,
         records,
         hdb_user: request.body.hdb_user,
      }

      return hdbCore.request(request)
    }
  })
})

cURL POST

curl -X POST http://127.0.0.1:9926/cool-app/dev_schema/dogs_table \
   -H 'Content-Type: application/json' \
   -d '{
      "username":"dog@harperdb.io",
      "password":"D0G5RUL3!",
      "records":[{"name": "Bruno", "breed": "awesome"}]
   }'
   

Keywords

FAQs

Package last updated on 11 Jul 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