Coder Social home page Coder Social logo

lambda_ldap_api's Introduction

lambda_ldap_api

A serverless package that will securely host up an internal LDAP repository for reference use in Okta Workflows

Intended Use Case

Running queries against an AWS hosted LDAP repository for reference use in Okta workflows. For example when calculating a unique username, existing entries can be determined at runtime.

What's included

  • A lambda function for executing LDAP searches against the LDAP repository.

  • A simple API gateway for hosting the lambda function, secured via OAuth2 tokens.

  • Proper security roles for retrieving the encrypted LDAP password from AWS parameter store.

Pre-requisites

Quick Start

  1. Clone the repo.
git clone https://github.com/dancinnamon-okta/lambda_ldap_api.git
cd lambda_ldap_api
  1. Copy serverless.yml.example to serverless.yml
$ cp serverless.yml.example serverless.yml
  1. Update serverless.yml with the proper values for your deployment:
  • issuerUrl: This is the issuer of the OAuth2 server you're using to secure the endpoint.
  • Audience: This is the audience of the OAuth2 tokens we're expecting to be issued. In Okta this is part of the authorization server.
  • LDAP_HOST: Hostname or IP address of the LDAP server.
  • SEARCH_BASE: Base OU of the LDAP directory to limit our search to.
  • RETURN_ATTRIBUTES: What attributes to return in our search results.
  • BIND_DN: What service account (in DN format) to login to the directory as.
  • ldap password parameter ARN: Provide the ARN of the ldap password parameter in the AWS SSM parameter store.
  • Security Group ID(s): Provide the ID of a security group that has access to the LDAP server over port 389/636.
  • Subnet ID: Provide the ID of the subnet that the LDAP server is in.
  1. Install serverless via npm
$ npm install -g serverless

Deploy

NOTE: Serverless Framework cli needs to be setup.

In order to deploy the you endpoint simply run

serverless deploy

The expected result should be similar to:

Serverless: Packaging service...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading service .zip file to S3 (758 B)...
Serverless: Updating Stack...
Serverless: Checking Stack update progress...
..........
Serverless: Stack update finished...

Okta Setup

If you need an Okta tenant, Sign up here.

  1. Create an OIDC application in Okta that Workflows will use as a client.
  1. Create an authorization server, and create the ldap.read scope on that authorization server. ** Note - the "audience" parameter you use must be the same as the "Audience" used in the serverless.yml file you updated in step 2.

Okta Workflows Setup

TODO: provide flopack

  1. Create an HTTP connection, using the OAuth2 protocol for security.

  2. In the applicable workflow, update the HTTP card to use the new connection.

Usage

When the API deploys, you'll receive an HTTP API endpoint available at /searchLdap that will serve up the LDAP directory in a readonly fashion. You simply need to invoke this endpoint with an HTTP GET request, with your LDAP search criteria in the "q" querystring variable.

Example: https://api/searchLdap?q=(samaccountname=demo*) to pull back all objects with a samaccountname starting with "demo".

Example response:

{
  "users": [
    {
      "name": "CN=Dan Cinnamon,OU=zimt people,DC=zimt,DC=us",
      "sn": [
        "Cinnamon"
      ],
      "givenName": [
        "Dan"
      ],
      "sAMAccountName": [
        "DanCinnamon"
      ],
      "userPrincipalName": [
        "[email protected]"
      ]
    }
  ],
  "userCount": 1,
  "message": "Search Successful!"
}

lambda_ldap_api's People

Contributors

dancinnamon-okta avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.