@uniauth/express-middleware

1.0.1 • Public • Published

Express Middleware

Ensure Build and Test

This middleware is used to quickly integrate UniAuth based applications into express applications. Below are all the configuration options that the package provides.

Usage

const uniAuth = new Auth([
  {
    name: 'server1',
    url: 'http://localhost:5000',
    clientId: '600ee6ec924dd75267384cb4',
    clientSecret: '986727d0-c253-4adb-a9b8-c233a89cdb25',
    redirectUri: 'http://localhost:3000/callback',
    processor: (profile, next) => {
      console.log('>>>>>', profile);
      next();
    },
    endpoint: {
      auth: 'account/o/login',
      profile: 'account/o/access',
    },
  },
]);

app.get('/login', uniAuth.authenticate('server1'));
app.get('/callback', uniAuth.callback('server1'), (req, res) => {
  res.json({ message: 'logged in' });
});

FAQ

  • This repo has a directory named sample which contains an express application with auth implemented.
  • The server is based on uniauth-backend and can be configured as per needs.
  • Need similar implementation in other languages? Open an issue and let us know.

Package Sidebar

Install

npm i @uniauth/express-middleware

Weekly Downloads

0

Version

1.0.1

License

AGPL-3.0-only

Unpacked Size

47 kB

Total Files

7

Last publish

Collaborators

  • yashkumarverma