A high-performance gRPC authentication service for i-Ma'luum login operations, written in Rust. This service provides optimized HTTP client handling with connection pooling, cookie management, and efficient async I/O.
- 🚀 High Performance: Optimized with connection pooling, HTTP/2, and async I/O
- 🔒 Secure: Handles authentication cookies securely
- 🔄 Reusable HTTP Client: Singleton pattern with shared connection pool
- 📦 gRPC API: Modern protocol buffers interface
- 🛡️ Robust Error Handling: Comprehensive error types with detailed logging
- ⚡ Efficient: Minimal allocations and optimized for throughput
- Connection Pooling: Maintains up to 10 idle connections per host
- HTTP/2: Enables multiplexing for better performance
- Compression: Supports gzip, brotli, and deflate
- TCP Settings:
TCP_NODELAYfor reduced latency- TCP keepalive for long-lived connections
- Async I/O: Non-blocking operations with Tokio runtime
- Zero-Copy Operations: Minimal string allocations
- Rust 1.70+ (with 2024 edition support)
- Protocol Buffers compiler (protoc)
cargo build --release# With default settings (binds to [::1]:50052)
cargo run --release
# With custom bind address
BIND_ADDR="0.0.0.0:50051" cargo run --release
# With logging
RUST_LOG=info cargo run --releaseThe service exposes an Auth service with a Login method.
syntax = "proto3";
package grpc.gas.auth;
service Auth {
rpc Login(LoginRequest) returns (LoginResponse) {};
}
message LoginRequest {
string username = 1;
string password = 2;
}
message LoginResponse {
string token = 1;
string username = 2;
string password = 3;
}The login process follows a two-step authentication flow:
- Initialize Session: GET request to CAS page to establish session cookies
- Authenticate: POST request with credentials to obtain MOD_AUTH_CAS token
┌─────────┐ ┌──────────────┐ ┌─────────────┐
│ Client │ │ Auth Service │ │ i-Ma'luum │
└────┬────┘ └───────┬───────┘ └──────┬──────┘
│ │ │
│ gRPC Login(user, pass) │ │
├─────────────────────────────>│ │
│ │ GET /cas/login │
│ ├────────────────────────────────>│
│ │ Set-Cookie: SESSION │
│ │<────────────────────────────────┤
│ │ │
│ │ POST /cas/login (credentials) │
│ ├────────────────────────────────>│
│ │ Set-Cookie: MOD_AUTH_CAS │
│ │<────────────────────────────────┤
│ │ │
│ LoginResponse(token) │ │
│<─────────────────────────────┤ │
│ │ │
BIND_ADDR: Server bind address (default:[::1]:50052)RUST_LOG: Logging level (e.g.,debug,info,warn,error)
# Run all tests
cargo test
# Run with output
cargo test -- --nocapture
# Run specific test
cargo test test_auth_service_creation
# Run with logging
RUST_LOG=debug cargo test -- --nocaptureIf you encounter build errors:
# Update dependencies
cargo update
# Clean and rebuild
cargo clean && cargo build
# Check for missing tools
which protocIf login fails:
- Check network connectivity to i-Ma'luum servers
- Verify credentials are correct
- Check if i-Ma'luum servers are accessible
- Enable debug logging:
RUST_LOG=debug cargo run