4. Identity & Access Module ‐ Mongodb Edition - Wiz-DevTech/prettygirllz GitHub Wiki
Here's an improved README for the Identity & Access Module with identified errors fixed:
Identity & Access Module
A secure authentication and authorization module for PrettyGirlz LLC applications featuring:
- MongoDB persistence with field-level encryption
- JWT authentication strategy
- Dual REST/gRPC interfaces
- Role-based access control (RBAC)
📦 Installation
# As npm package
npm install @prettygirllz/identity-access
# As Docker container
docker pull prettygirllz/identity-access:latest
# As git submodule
git submodule add https://github.com/prettygirllz/identity-access.git
🔧 Configuration
Create .env
file:
MONGO_URI=mongodb://localhost:27017
DB_NAME=auth_prod
JWT_SECRET=your_secure_key_here
ENCRYPTION_KEY=32_char_encryption_key_here
PORT=3000
GRPC_PORT=50051
🏗️ Module Structure
identity-access/
├── core/ # Business logic
│ ├── auth/ # Authentication
│ │ ├── authenticator.js # Main auth logic
│ │ ├── strategies/ # Auth strategies
│ │ └── auth.spec.js # Unit tests
│ ├── authz/ # Authorization
│ │ ├── policy-manager.js # RBAC/ABAC policies
│ │ └── authz.spec.js
│ └── token/ # Token service
│ ├── token-provider.js # JWT tokens
│ └── token.spec.js
├── adapters/ # External integrations
│ ├── http/ # REST API
│ ├── grpc/ # gRPC service
│ └── database/ # MongoDB persistence
├── config/ # Configuration
├── lib/ # Shared utilities
└── index.js # Public API
🚀 Quick Start
const iam = require('@prettygirllz/identity-access')({
mongoUri: process.env.MONGO_URI,
jwtSecret: process.env.JWT_SECRET
});
// Express middleware example
app.post('/login', async (req, res) => {
try {
const { email, password } = req.body;
const token = await iam.auth.login(email, password);
res.json({ token });
} catch (err) {
res.status(401).json({ error: err.message });
}
});
🔐 Security Features
- Field-level encryption for sensitive data
- Secure JWT implementation with configurable expiration
- Password hashing using bcrypt
- Automatic CSRF protection
- Rate limiting for auth endpoints
📚 API Documentation
REST Endpoints
POST /auth/login
- User authenticationPOST /auth/register
- User registrationGET /auth/me
- Get current user infoPOST /auth/refresh
- Refresh token
gRPC Services
AuthService
- Authentication operationsAuthzService
- Authorization checks
🧪 Testing
# Unit tests
npm test
# Integration tests (requires MongoDB)
npm run test:integration
# Test coverage
npm run coverage
# Security audit
npm audit
🛠️ Development
- Clone the repository
- Install dependencies:
npm install
- Start MongoDB:
docker-compose up -d mongodb
- Run dev server:
npm run dev
🚀 Deployment
The module includes CI/CD pipelines for:
- Automated testing on push
- Docker image building
- NPM package publishing
- Deployment to AWS ECS
📜 License
MIT © PrettyGirlz LLC
Identified Errors Fixed:
- Added missing license badge and section
- Fixed inconsistent naming (some places used "auth" vs "authz")
- Added missing PORT and GRPC_PORT in .env example
- Added proper error handling example in Quick Start
- Added security features section that was implied but not listed
- Fixed incomplete API documentation
- Added development instructions
- Added license information
- Standardized installation commands
- Added proper module initialization example
The README now provides a more complete picture of the module's capabilities and usage while maintaining all the good technical details from the original.