1.1.10 • Published 10 months ago

@fluidauth/express v1.1.10

Weekly downloads
-
License
ISC
Repository
github
Last release
10 months ago

Fluid Auth Express

fluidauth-express makes adding authentication to your Express app easy. Follow these steps to get started quickly.

Documentation

For a comprehensive guide on using FluidAuth Express, including installation, setup, and API reference, please visit the official documentation:

FluidAuth Documentation

Key Points

  • Body Parser Required: You need to use body-parser to handle request data.
  • Cookie Parser Required: You need to use cookie-parser to handle cookies.

  • Initialize Middleware: Use authService.initialize() after setting up the session middleware to configure necessary helper functions.

Quick Start

// Import GithubProvider from FluidAuth-Express
const { GithubProvider } = require("@fluidauth/express/providers");

// Initialize GitHub provider with credentials
const Github = new GithubProvider({
  credential: {
    clientId: "your-client-id",
    clientSecret: "your-client-secret",
    redirectUri: "your-redirect-uri",
  },
  async verifyUser(data) {
    const user = await findUserByEmail(data.email);
    return user ? { user } : { user: null, info: { message: "User not found" } };
  }
});
// Express server setup
const express = require('express');
const cookieParser = require('cookie-parser');
const { AuthService, Session } = require('@fluidauth/express');

const app = express();
const authService = new AuthService({
  providers: [Github],
  session: new Session({ secret: "your-session-secret" }),
  redirect: { onLoginSuccess: "/dashboard" },
});

app.use(express.json());
app.use(cookieParser());
app.use(authService.session());
app.use(authService.initialize());

app.listen(3000, () => console.log("Server running on port 3000"));

Module Support

FluidAuth Express supports both CommonJS and ES Modules, allowing flexibility in how you import the package.

CommonJS

If you're using CommonJS, you can require the package like this:

const { AuthService } = require("@fluidauth/express");

ES Modules

For projects using ES Modules, you can import the package like this:

import { AuthService } from "@fluidauth/express";

Both module systems are fully supported to ensure compatibility with various environments.

1.1.9

10 months ago

1.1.8

10 months ago

1.1.7

10 months ago

1.1.6

10 months ago

1.1.5

10 months ago

1.1.4

10 months ago

1.1.3

10 months ago

1.1.2

10 months ago

1.1.10

10 months ago

1.1.1

10 months ago

1.1.0

10 months ago

1.0.8

10 months ago

1.0.7

10 months ago

1.0.6

10 months ago

1.0.5

10 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago

1.0.0-beta.2

11 months ago

1.0.0-beta.1

11 months ago

1.0.0-beta.0

11 months ago

1.0.0-alpha.7

11 months ago

1.0.0-alpha.6

11 months ago

1.0.0-alpha.5

11 months ago

1.0.0-alpha.4

11 months ago

1.0.0-alpha.3

11 months ago

1.0.0-alpha.2

11 months ago

1.0.0-alpha.1

11 months ago