gaojianli2333/radius-manager

By gaojianli2333

β€’Updated 9 months ago

A modern RADIUS user management system with complete user management features for FreeRADIUS.

Image
Networking
0

1.3K

gaojianli2333/radius-manager repository overview

⁠🌐 RADIUS Manager

License: MIT Go Version Vue Version TypeScript

A modern RADIUS user management system built with CloudWeGo Hertz and Vue 3. Provides complete user authentication, authorization, and management features for FreeRADIUS with a responsive web interface.

The codes are all written by Claude code.

中文文摣⁠

⁠✨ Project Highlights

  • 🎨 Modern UI: Responsive interface based on Arco Design, perfect support for desktop and mobile
  • πŸ” Security & Reliability: SHA256+Salt password encryption, JWT authentication, role-based access control
  • ⚑ High Performance: CloudWeGo Hertz high-performance framework with concurrent processing support
  • 🌍 Standard Compatible: Fully compatible with FreeRADIUS authentication flow and RADIUS protocol
  • πŸ“¦ Containerized Deployment: Docker Compose one-click deployment, ready to use out of the box
  • πŸ“± Mobile Friendly: Complete mobile adaptation with touch operations and responsive layout

β πŸš€ Features

⁠πŸ–₯️ Modern Web Management Interface
  • ✨ Built with Vue 3 + TypeScript + Arco Design for modern interface
  • πŸ“± Complete mobile adaptation with touch operations and responsive layout
  • 🎨 Intuitive and user-friendly interface, simple and easy to understand
  • ⚑ Real-time data display and operation feedback with hot updates
β πŸ”§ Powerful Backend Features
  • πŸ” Secure user authentication and password management system
  • πŸ‘₯ Complete user lifecycle management (create, edit, ban, delete)
  • πŸ›‘οΈ Role-based fine-grained permission control system
  • πŸ”’ SHA256+Salt password encryption following security best practices
  • 🎯 JWT stateless authentication supporting distributed deployment
  • πŸ”Œ RESTful API design, easy to integrate and extend
  • πŸ“Š Detailed authentication logs and statistical analysis
  • 🌐 Fully compatible with FreeRADIUS authentication flow
  • πŸ“¦ Docker Compose one-click deployment supporting containerized environments

β πŸ’» Tech Stack

⁠🎨 Frontend Tech Stack
  • Core Framework: Vue 3.4+ + TypeScript 5.3+
  • UI Component Library: Arco Design 2.56+ (officially recommended enterprise-level component library)
  • State Management: Pinia (next-generation Vuex)
  • Router Management: Vue Router 4.2+
  • HTTP Requests: Axios 1.6+ (supports interceptors and automatic retry)
  • Development Tools: Vite 5.0+ (lightning-fast hot reload and building)
  • Code Quality: TypeScript type checking + Unplugin auto-import
β βš™οΈ Backend Tech Stack
  • High-Performance Framework: CloudWeGo Hertz 0.10+ (ByteDance's open-source enterprise-level framework)
  • Data Storage: MySQL 8.0+ (supports transactions and concurrency control)
  • ORM Framework: GORM 1.30+ (powerful Go ORM)
  • Authentication & Authorization: JWT (HMAC-SHA256 signature + automatic expiration refresh)
  • Password Security: SHA256 + 32-byte random salt encryption
  • Deployment: Docker & Docker Compose + Makefile automation
  • Cross-Origin Support: CORS middleware + RESTful API design

β πŸš€ Quick Start

  1. Clone the project and navigate to directory
git clone https://github.com/Gaojianli/radius-manager.git
cd radius-manager
  1. Start services
make docker-run
  1. Access web interface

Default admin account:

  • Username: admin
  • Password: admin123
β πŸ› οΈ Development Environment Setup
  1. Install dependencies
make install
  1. Configure environment variables
cp .env.example .env
# Edit .env file to set database connection information
  1. Start database (if using Docker)
docker-compose up -d mysql
  1. Build and run
# Build frontend
make build-frontend

# Run complete application
make run

# Or start frontend and backend separately for development
make dev-frontend  # Start frontend dev server (port 3000)
make dev-backend   # Start backend dev server (port 8080)

⁠🎯 Web Interface Features

β πŸ“± Mobile Optimization
  • Responsive Design: Adaptive to desktop, tablet, and mobile screens
  • Touch Optimization: Support for touch gestures, click feedback, and swipe operations
  • Mobile Navigation: Sidebar overlay design with gesture control and mask layer
  • Mobile Tables: Smart column hiding, horizontal scrolling, and touch optimization
  • Floating Actions: FAB (Floating Action Button) design following Material Design guidelines
  • Modal Adaptation: Mobile modal auto-adapts to screen size
β πŸ”‘ Login Page
  • πŸ”’ Secure user authentication and session management
  • ❌ Friendly error messages and form validation
  • πŸ’Ύ Automatic login state persistence with auto-login support
  • πŸ“± Perfect mobile adaptation and touch optimization
β πŸ“Š Dashboard
  • πŸ“ˆ Real-time system statistics and data visualization
  • πŸ‘₯ User activity and authorization statistics (supports display by role)
  • βš™οΈ System information and version display
  • 🎨 Responsive card layout adapting to screen size
⁠πŸ‘₯ User Management (Admin)
  • πŸ“‹ Paginated user list with search and filtering support
  • βž• Visual user creation form with real-time validation
  • πŸ” One-click user password reset (admin cannot see passwords)
  • 🚫 Flexible user ban/unban functionality
  • πŸ—‘οΈ Safe user deletion (with confirmation dialogs)
  • 🏷️ Real-time user status indicators and role management
  • πŸš€ Mobile FAB floating button supporting manual operations
β πŸ‘€ User Profile
  • πŸ—ΊοΈ Detailed personal information display (username, email, role, status)
  • πŸ” Secure password modification with password strength checking
  • πŸ›‘οΈ Built-in security tips and password security recommendations
  • πŸ“… Creation time and update time tracking
β πŸ“‹ Authentication Logs (Admin)
  • πŸ“Š Detailed authentication log records and analysis
  • πŸ” Support for filtering and searching by username
  • πŸ“… Time range queries and sorting
  • πŸ“± Mobile-adapted table display

β πŸ“‘ API Documentation

⁠Authentication
⁠User Login
POST /api/v1/auth/login
Content-Type: application/json

{
  "username": "admin",
  "password": "admin123"
}

Response:

{
  "code": 200,
  "expire": "2024-01-02T15:04:05Z",
  "token": "eyJhbGciOiJIUzI1NiIs..."
}
⁠Refresh Token
POST /api/v1/auth/refresh
Authorization: Bearer <token>
⁠User Management
⁠Get User Profile
GET /api/v1/user/profile
Authorization: Bearer <token>
⁠Change Password
PUT /api/v1/user/change-password
Authorization: Bearer <token>
Content-Type: application/json

{
  "old_password": "oldpass123",
  "new_password": "newpass123"
}
⁠Admin Functions
⁠Create User
POST /api/v1/admin/users
Authorization: Bearer <admin-token>
Content-Type: application/json

{
  "username": "newuser",
  "email": "[email protected]",
  "password": "password123",
  "is_admin": false
}
⁠Get All Users
GET /api/v1/admin/users?page=1&limit=20
Authorization: Bearer <admin-token>
⁠Ban/Unban User
PUT /api/v1/admin/users/{user_id}/ban
Authorization: Bearer <admin-token>
⁠Delete User
DELETE /api/v1/admin/users/{user_id}
Authorization: Bearer <admin-token>
⁠FreeRADIUS Integration

FreeRADIUS integration uses the standard Authorize β†’ Authenticate two-phase verification process:

⁠Authorization Interface

Used to check if a user is authorized to authenticate, without password verification.

POST /api/v1/radius/authorize
Content-Type: application/json

{
  "username": "testuser"
}

Response:

{
  "result": "accept",
  "username": "testuser", 
  "message": "User authorized to authenticate",
  "attrs": {
    "Auth-Type": "REST",
    "User-ID": "testuser",
    "User-Role": "user"
  }
}
⁠Authentication Interface

Used to verify user credentials (username and password).

POST /api/v1/radius/auth
Content-Type: application/json

{
  "username": "testuser",
  "password": "password123"
}

Response:

{
  "result": "accept",
  "username": "testuser",
  "message": "Authentication successful",
  "attrs": {
    "User-ID": "testuser",
    "User-Role": "user",
    "Session-Type": "authenticated"
  }
}

β πŸ”§ FreeRADIUS Integration

⁠Two-Phase Verification Process

FreeRADIUS uses a two-phase verification mode to ensure security and performance:

  1. Authorize Phase

    • Check if user exists
    • Verify account status (disabled, banned)
    • Set authentication type
    • No password verification, quickly filter invalid users
  2. Authenticate Phase

    • Verify user credentials (password)
    • Only execute for users who pass authorization
    • Return final authentication result
⁠Advantages
  • Performance Optimization: Invalid users are blocked in authorization phase, reducing password verification overhead
  • Security Enhancement: Banned users cannot enter authentication phase
  • Standard Compliant: Follows RADIUS protocol design philosophy
  • Easy to Monitor: Can separately track authorization and authentication success/failure rates

β πŸ“‹ Environment Variables

VariableDefaultDescription
DB_HOSTlocalhostMySQL host address
DB_PORT3306MySQL port
DB_USERrootMySQL username
DB_PASSWORD-MySQL password
DB_NAMEradius_mgntDatabase name
JWT_SECRETyour-secret-keyJWT signing key
SERVER_PORT:8080Server port

β πŸ”’ Security Features

  • Password Encryption: SHA256 + 32-byte random salt
  • JWT Authentication: HMAC-SHA256 signature
  • Access Control: Role-based access control
  • Password Policy: Minimum 6 characters
  • API Security: All sensitive operations require authentication
  • Frontend Route Guards: Unauthenticated users auto-redirect to login
  • Auto Login Expiration: Auto logout on token expiration

β πŸ—οΈ Project Structure

radius-manager/
β”œβ”€β”€ web/                    # Vue3 frontend project
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/     # Reusable components
β”‚   β”‚   β”œβ”€β”€ views/          # Page components
β”‚   β”‚   β”œβ”€β”€ layouts/        # Layout components
β”‚   β”‚   β”œβ”€β”€ stores/         # Pinia state management
β”‚   β”‚   β”œβ”€β”€ services/       # API services
β”‚   β”‚   └── router/         # Router configuration
β”‚   β”œβ”€β”€ package.json
β”‚   └── vite.config.ts
β”œβ”€β”€ static/                 # Static file server
β”‚   β”œβ”€β”€ dist/               # Frontend build output
β”‚   └── static.go           # Go embed static files
β”œβ”€β”€ config/                 # Configuration files
β”œβ”€β”€ controllers/            # Controllers
β”œβ”€β”€ dao/                    # Data access layer
β”œβ”€β”€ database/               # Database connection
β”œβ”€β”€ middleware/             # Middlewares
β”œβ”€β”€ models/                 # Data models
β”œβ”€β”€ routes/                 # Route configuration
β”œβ”€β”€ scripts/                # Build scripts
β”œβ”€β”€ docker-compose.yml      # Docker orchestration
β”œβ”€β”€ Dockerfile              # Container build
β”œβ”€β”€ Makefile               # Build commands
└── README.md              # Project documentation

β πŸ› οΈ Development Commands

make help              # Show all available commands
make install          # Install frontend and backend dependencies
make build            # Build entire project
make build-frontend   # Build frontend only
make build-backend    # Build backend only
make run              # Build and run project
make dev-frontend     # Start frontend dev server
make dev-backend      # Start backend dev server
make clean            # Clean build files
make docker-build     # Build Docker image
make docker-run       # Start with Docker Compose
make test             # Run tests
make format           # Format code
make lint             # Code linting

β πŸ› Troubleshooting

⁠Frontend Won't Load
  1. Ensure frontend is built: make build-frontend
  2. Check if static/dist/ directory has files
  3. Confirm server port configuration is correct
⁠API Request Failures
  1. Check if backend service is running on correct port
  2. Verify JWT token is valid
  3. Check browser network panel for error messages
⁠Database Connection Issues
  1. Confirm MySQL service status
  2. Check database configuration in .env file
  3. Verify database user permissions
⁠FreeRADIUS Authentication Failures
  1. Check REST module configuration is correct
  2. Verify API endpoint accessibility
  3. View FreeRADIUS debug output: sudo freeradius -X

⁠🀝 Contributing

We welcome contributions of all kinds! Whether it's bug reports, feature requests, documentation improvements, or code contributions.

β πŸ“‹ Contribution Process
  1. Fork the project: Click the Fork button in the top right
  2. Clone locally: git clone https://github.com/YOUR_USERNAME/radius-manager.git
  3. Create feature branch: git checkout -b feature/amazing-feature
  4. Local development:
    # Install dependencies
    make install
    
    # Start development environment
    make dev-frontend    # Frontend dev server
    make dev-backend     # Backend dev server
    
  5. Code standards:
    make format         # Format code
    make lint          # Code linting
    make test          # Run tests
    
  6. Commit changes:
    git add .
    git commit -m "✨ Add amazing feature: feature description"
    git push origin feature/amazing-feature
    
  7. Create Pull Request: Go back to GitHub to create PR
⁠🎯 Contribution Types
  • πŸ› Bug Fixes: Fix issues with existing functionality
  • ✨ New Features: Add new features
  • πŸ“š Documentation: Improve documentation and instructions
  • 🎨 UI/UX: Interface and user experience improvements
  • ⚑ Performance: Performance optimization and improvements
  • πŸ”§ Refactoring: Code refactoring and architecture optimization
β πŸ“ Code Standards
  • Go Code: Follow gofmt and golint standards
  • Vue Code: Use TypeScript and Vue 3 Composition API style
  • Commit Messages: Use Conventional Commits⁠ format
  • Documentation: All public APIs must have corresponding documentation

⁠🌟 Acknowledgments

Thanks to all developers who contributed to this project!

β πŸ“„ License

This project is licensed under the MIT License⁠.

MIT License

Copyright (c) 2024 RADIUS Manager Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

β πŸ“ž Contact


⭐ If this project helps you, please give us a Star!

Happy Coding! πŸŽ‰

Tag summary

Content type

Image

Digest

sha256:3aea8d47d…

Size

10.7 MB

Last updated

9 months ago

docker pull gaojianli2333/radius-manager