Socket
Socket
Sign inDemoInstall

@iad-os/aemon-oidc-introspect

Package Overview
Dependencies
23
Maintainers
3
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @iad-os/aemon-oidc-introspect

Aemon Oidc Introspect


Version published
Maintainers
3
Created

Readme

Source

OIDC Smart Introspect middleware

Add dependency to project

npm i @iad-os/aemon-oidc-introspect

Configure

import aemonOidcIntrospect from '@iad-os/aemon-oidc-introspect';

//...

const expressApp = express()
  // other middleware ...
  .use(
    aemonOidcIntrospect({
      issuers: [
        {
          issuer: 'https://XXX/auth/realms/YYY',
          introspection_endpoint:
            'https://XXX/auth/realms/YYY/protocol/openid-connect/token/introspect',
          client: {
            client_id: 'client_id',
            client_secret: 'aClientSecret',
          },
        },
      ],
      extractToken: (req: Request): string => {
        
        // Bearer token example (Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c)

        const authorization = req.headers['authorization'];
        if (!authorization) return;
        const [, token] = authorization.split(' ');
        return token;
      },
      doPost: async (
          req: Request,
          url: string,
          queryString: string,
          options?: { headers: Record<string, string> }
        ) => {
          return await axios.create().post(url, queryString, options);
        },
      logger: (req: Request, level: string, msg: string, payload?: any) =>
        logger[level](msg, payload),
    })
  );

Usage

const myMiddleware: RequestHandler = function (req, res, next) {
  // ... code here
  if (!req.uid) {
    logger.info('User IDentity not found.');
    return next(null);
  }

  sendEmail(req.uid.email)
};

Keywords

FAQs

Last updated on 30 Nov 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