Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@iad-os/aemon-oidc-introspect

Package Overview
Dependencies
Maintainers
3
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@iad-os/aemon-oidc-introspect

Aemon Oidc Introspect

  • 0.2.14
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created
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

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