{
  "markdown": "#  Auth Infra\n\n**A Plug-and-Play Authentication Infrastructure for Spring Boot**\n\nAuth Infra is a modular authentication engine built using Hexagonal Architecture (Ports & Adapters) and exposed as a Spring Boot Starter. It eliminates repetitive authentication boilerplate so you can focus on business logic instead of authentication plumbing.\n\n[![JitPack](https://jitpack.io/v/ayushy738/auth-infra.svg)](https://jitpack.io/#ayushy738/auth-infra)\n\n---\n\n##  Project Goal\n\nModern backend applications repeatedly reimplement the same authentication infrastructure:\n\n- Configure Spring Security\n- Write JWT generation & validation\n- Manage refresh tokens\n- Handle logout via token revocation\n- Implement password encoding\n- Wire everything with dependency injection\n\n**This leads to:**\n- Duplicate code\n- Security mistakes\n- Slower MVP development\n- Inconsistent implementations across projects\n\n**Auth Infra solves this by providing a reusable, configurable authentication engine that works out-of-the-box.**\n\n> 1. Add one dependency\n> 2. Configure three properties\n> 3. Get production-ready JWT authentication\n\n---\n\n##  Features\n\n| Feature | Description |\n|---------|-------------|\n|  **JWT-Based Authentication** | Stateless access tokens with HMAC signing and configurable expiration |\n|  **Refresh Token Rotation** | Secure refresh flow with automatic token replacement |\n|  **Token Blacklist** | Immediate token invalidation for secure logout |\n|  **Password Security** | BCrypt password encoding and secure matching |\n|  **Audit Logging** | Track login success/failure with extensible logging interface |\n|  **Fully Configurable** | Customize secret key, token expiration, and more |\n|  **Plug & Play** | In-memory defaults included, no database required |\n\n---\n\n##  Architecture Overview\n\nAuth Infra follows **Clean Architecture** principles with framework-independent core logic.\n\n```\nApplication\n    ↓\nSpring Boot Auto Configuration\n    ↓\nAuth Infra Starter\n    ↓\nCore Engine (Pure Java)\n```\n\n### Module Structure\n\n```\nauth-infra/\n├── engine-core              # Pure Java domain & ports\n├── engine-spring-adapter    # Optional runtime app module\n└── engine-spring-starter    # Spring Boot auto-config starter\n```\n\n### Design Principles\n\n-  Framework-independent core logic\n-  Dependency inversion (ports & adapters)\n-  Default implementations with override capability\n-  Auto-configured infrastructure\n-  Minimal required setup\n\n---\n\n##  Installation\n\n### Step 1 — Add JitPack Repository\n\nAdd the following to your `pom.xml`:\n\n```xml\n<repositories>\n    <repository>\n        <id>jitpack.io</id>\n        <url>https://jitpack.io</url>\n    </repository>\n</repositories>\n```\n\n### Step 2 — Add Dependency\n\n```xml\n<dependency>\n    <groupId>com.github.ayushy738.auth-infra</groupId>\n    <artifactId>engine-spring-starter</artifactId>\n    <version>v1.0.3</version>\n</dependency>\n```\n\n\n---\n\n##  Configuration\n\nAdd the following to your `application.yml`:\n\n```yaml\nengine:\n  security:\n    jwt-secret: your-very-long-secure-secret-key\n    access-expiration: 900000        # 15 minutes\n    refresh-expiration: 604800000    # 7 days\n```\n\n**That's it.** No additional setup required.\n\n---\n\n##  Usage\n\n### Available Endpoints\n\n| Method | Endpoint | Description |\n|--------|----------|-------------|\n| `POST` | `/auth/register` | Register new user |\n| `POST` | `/auth/login` | Authenticate user |\n| `POST` | `/auth/refresh` | Refresh access token |\n| `POST` | `/auth/logout` | Invalidate token |\n\n### Protecting Routes\n\nCreate a controller:\n\n```java\n@RestController\npublic class TestController {\n\n    @GetMapping(\"/secure\")\n    public String secure() {\n        return \"Authenticated access\";\n    }\n}\n```\n\nAccess protected routes using:\n\n```\nAuthorization: Bearer <access_token>\n```\n\n---\n\n##  Default Implementations\n\nAuth Infra provides **default in-memory implementations** for:\n\n- `UserRepositoryPort`\n- `RefreshTokenRepositoryPort`\n- `TokenBlacklistPort`\n- `AuditLogPort`\n- `TokenServicePort`\n- `PasswordEncoderPort`\n\nAll are registered using `@ConditionalOnMissingBean`, meaning:\n\n> **If you provide your own implementation → it automatically overrides the default.**\n\n---\n\n##  Customizing Persistence\n\nTo replace in-memory storage with a database:\n\n```java\n@Bean\npublic UserRepositoryPort userRepositoryPort() {\n    return new JpaUserRepositoryAdapter();\n}\n```\n\nThe starter will automatically use your implementation.\n\n---\n\n##  How It Works\n\n### Security Flow\n\n1. **User registers** → Password is encoded using BCrypt\n2. **Access + refresh tokens** are generated\n3. **Protected routes** validate access token\n4. **Logout** blacklists access token\n5. **Refresh endpoint** rotates tokens securely\n\n### Core Layer\n\n- Pure Java\n- No Spring dependencies\n- Contains domain logic and service layer\n\n### Starter Layer\n\n- Auto-configures beans\n- Registers default adapters\n- Wires `AuthService`\n- Loads configuration properties\n\n---\n\n##  Development\n\n### Build Project\n\n```bash\nmvn clean install\n```\n\n\n---\n\n##  Use Cases\n\n-  Rapid MVP development\n-  Hackathon backend setup\n-  Microservice authentication base\n-  Educational clean architecture example\n-  Internal platform standardization\n\n---\n\n##  Production Considerations\n\nFor production environments:\n\n- Replace in-memory storage with persistent database adapters\n-  Use strong secret key (at least 256 bits)\n-  Use HTTPS only\n-  Configure token expiration according to security policy\n-  Add rate limiting if required\n-  Implement proper monitoring and alerting\n\n---\n\n##  Why This Project Matters\n\nAuth Infra demonstrates:\n\n- Clean Architecture principles\n- Modular system design\n- Dependency inversion\n- Framework-level thinking\n- Spring Boot auto-configuration\n- Reusable backend infrastructure\n\n**This is not just an authentication system.**  \n**It is an authentication infrastructure component.**\n\n---\n\n##  Author\n\n**Ayush Yadav**  \nBackend & Infrastructure Engineering\n\n---\n\n##  License\n\nThis project is licensed under the [MIT License](LICENSE).\n\n---\n\n##  Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n---\n\n##  Support\n\nIf you have any questions or need help, please:\n\n- Open an issue on GitHub\n- Check the documentation\n- Reach out to the maintainer\n\n---\n\n<div align=\"center\">\n\n If you find this project useful, please consider giving it a star! ⭐\n\nMade with ❤️ by Ayush Raj Yadav\n\n</div>",
  "bytes": 6625,
  "sha": "b9bd51c2c9d8a9515a7e7f414e66a3966ea819b5a91d46829a1f5fc976685713",
  "repo_slug": "ayushy738/auth-infra",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/okf_ayushy738_auth_infra_openwiki_index_md_0e868e1c/readme"
}