@hsuite/auth - Authentication Module
🔐 Comprehensive NestJS authentication module providing unified Web2 & Web3 authentication solutions
A robust, enterprise-grade authentication module that seamlessly integrates traditional username/password authentication with cutting-edge Web3 wallet-based authentication, designed specifically for the HSuite ecosystem.
Table of Contents
Quick Start
Installation
Basic Setup
Protect Your Routes
Architecture
Core Components
🛡️ Guards
JwtAuthGuard
- JWT-based route protectionRedisAuthGuard
- Redis session authenticationConfirmedAuthGuard
- Email confirmation requirement
🌐 Strategies
JwtStrategy
- Passport JWT strategy implementationRedisStrategy
- Redis-based session strategyWeb3Strategy
- Blockchain wallet authentication
🔧 Services
AuthService
- Core authentication logicAuthController
- REST API endpoints
Module Structure
API Reference
AuthModule
Static Methods
forRootAsync(options: AuthModuleAsyncOptions): DynamicModule
Configures the authentication module with async dependency injection.
AuthService
Core Methods
validateUser(username: string, password: string): Promise<any>
Validates user credentials for Web2 authentication
login(user: any): Promise<{ access_token: string }>
Generates JWT token for authenticated user
register(userData: CreateUserDto): Promise<User>
Registers new user with email confirmation
Guards Reference
JwtAuthGuard
RedisAuthGuard
ConfirmedAuthGuard
Guides
Web2 Authentication Guide
Learn how to implement traditional username/password authentication with email confirmation and 2FA. Configure user registration, login flows, password reset, and session management.
Web3 Authentication Guide
Implement blockchain wallet-based authentication with signature verification and token gating. Set up wallet connection, signature validation, and decentralized identity management.
Session Management Guide
Configure Redis-based session management for distributed applications. Implement session storage, expiration policies, and cross-service session sharing.
Guards & Strategies Guide
Deep dive into authentication guards and Passport strategies. Create custom guards, implement authorization logic, and manage authentication flows.
Examples
Complete Module Configuration
Multi-Guard Protection
Integration
Required Dependencies
Environment Variables
TypeScript Configuration
📝 Note: This module requires proper configuration of external services (Redis, PostgreSQL, SMTP, Twilio) for full functionality. See individual guides for detailed setup instructions.
Built with ❤️ by the HbarSuite Team Copyright © 2024 HbarSuite. All rights reserved.
Last updated