New:Microsoft Teams Notifications Are Now Available in Socket.Learn more →
Get Started

padlock-auth

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

padlock-auth

Middleware & Services to implement token creation & validation for express app.

latest
Source
npmnpm
Version
2.1.0
Version published
Maintainers
1
Created
Source

🔒 padlock-auth

Middleware & Services to implement token creation & validation for express app.

🚀 Quick start

  • Install the package:
npm install padlock-auth
  • create the .env file in the project root:
touch .env
  • define the JWT_SECRET_KEY variable in the .env file:
JWT_SECRET_KEY = "<your-random-string>"
  • Set the middleware for all protected routes:
router.post('/api/users', verifyTokenMiddleware, createUserController);
  • Create the token where you need it:
const token = Token.create({ userId: user.id });
  • (Optional) define the time the token will expire in the .env file (by default expires in 2 hours):
JWT_EXPIRES_IN = '2h'
  • (Optional and not recomendable) define if you want to disable the token verification in the .env file:
VERIFY_TOKEN = 'false'

Keywords

auth

FAQs

Package last updated on 03 May 2024

Related posts