Appearance
GrydAuth Module
See Remote consumer and separated authority for the registration and migration changes in the next release. See Profile image processing for image formats, validation limits, animation behavior, and native host packaging. See Password reset email delivery for SMTP configuration and delivery behavior. See Read-only readers for host composition without the authentication or write stack.
GrydAuth is a complete authentication and authorization module for .NET applications. It provides JWT/OAuth2 authentication, role-based access control (RBAC), permission-based authorization, and multi-tenancy support out of the box.
✨ Features
| Feature | Description |
|---|---|
| 🔐 JWT Authentication | Complete JWT token lifecycle with access/refresh tokens |
| 👥 User Management | User registration, authentication, password management |
| 🎭 Role-Based Access | Flexible role system with hierarchical permissions |
| 🔑 Permission System | Granular permission-based authorization with policies |
| 🏢 Multi-Tenancy | Built-in support for tenant isolation and federation |
| 🌐 Federation | Google, Microsoft and Apple social providers, plus enterprise OIDC connections |
| 📍 Security Features | Rate limiting, audit logging, geo-location tracking |
| 🔄 Token Invalidation | Real-time token blacklisting and version control |
📦 Packages
GrydAuth is organized in multiple packages following Clean Architecture:
📦 GrydAuth
├── GrydAuth.Domain # Entities, Value Objects, Domain Events
├── GrydAuth.Application # Commands, Queries, Interfaces
├── GrydAuth.Infrastructure # JWT, Repositories, External Services
└── GrydAuth.API # Controllers, Middlewares, Filters🚀 Quick Start
For a new Auth API, use the maintained gryd-api template with --IncludeAuth true. The Getting Started guide links its exact composition root and README, including controller discovery, API versioning, PostgreSQL configuration, Development migrations, and local secret setup. The template is compiled by the repository's template validation workflow.
🏗️ Architecture Overview
┌─────────────────────────────────────────────────────────────────┐
│ GrydAuth.API │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────────┐ │
│ │ Controllers │ │ Middlewares │ │ Exception Handlers │ │
│ └─────────────┘ └─────────────┘ └─────────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ GrydAuth.Application │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────────┐ │
│ │ Commands │ │ Queries │ │ Interfaces │ │
│ │ - Login │ │ - GetUser │ │ - IAuthService │ │
│ │ - Register │ │ - GetRoles │ │ - ITokenService │ │
│ │ - Refresh │ │ - GetPerms │ │ - IPermissionService │ │
│ └─────────────┘ └─────────────┘ └─────────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ GrydAuth.Infrastructure │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────────┐ │
│ │ JWT Svc │ │ Repositories│ │ Permission Handler │ │
│ │ - Generate │ │ - User │ │ - Policy Provider │ │
│ │ - Validate │ │ - Role │ │ - Auth Handler │ │
│ │ - Refresh │ │ - Tenant │ │ - Claim Builder │ │
│ └─────────────┘ └─────────────┘ └─────────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ GrydAuth.Domain │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────────┐ │
│ │ Entities │ │Value Objects│ │ Domain Events │ │
│ │ - User │ │ - Email │ │ - UserCreatedEvent │ │
│ │ - Role │ │ - Password │ │ - RoleAssignedEvent │ │
│ │ - Tenant │ │ - Token │ │ - PermissionChanged │ │
│ └─────────────┘ └─────────────┘ └─────────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘📊 Entity Relationship Diagram
The following diagram shows the complete data model for GrydAuth, including all entities and their relationships:
100% 💡 Use Ctrl + Scroll para zoom | Arraste para navegar
Entity Descriptions
| Entity | Type | Description |
|---|---|---|
| User | Aggregate Root | Global user entity, not tied to specific tenants |
| Tenant | Aggregate Root | Organization/company in multi-tenancy system |
| UserTenant | Aggregate Root | User-Tenant relationship with roles and permissions |
| Role | Aggregate Root | Groups permissions together (tenant-scoped) |
| Permission | Aggregate Root | Defines actions that can be performed (tenant-scoped) |
| UserRole | Entity | Links UserTenant to Role |
| UserPermission | Entity | Direct permission assignment to UserTenant |
| RolePermission | Entity | Links Role to Permission (tenant-scoped) |
| UserAppId | Entity | Multi-app support - links User to application IDs |
| UserPasswordHistory | Entity | Password history for reuse prevention |
| FailedLoginAttempt | Entity | Security tracking for brute-force protection |
| PasswordResetToken | Entity | Token for password reset flow |
| UserPreference | Entity | User-specific settings per tenant (theme, language, sidebar state, etc.) |
| UserMenuFavorite | Entity | Bookmarked menu items with custom display order per tenant |
Key Relationships
User ↔ Tenant (Many-to-Many via UserTenant)
- Users exist globally, not tied to tenants
- UserTenant manages the relationship with roles/permissions per tenant
Role ↔ Permission (Many-to-Many via RolePermission)
- Roles group permissions together
- Both are tenant-scoped
UserTenant ↔ Role/Permission
- Users can have roles AND direct permissions per tenant
- Permissions are evaluated from both sources
User ↔ AppId (One-to-Many)
- Users can access multiple applications
- AppId is validated during login
User ↔ UserPreference (One-to-Many, Tenant-Scoped)
- Each user can have multiple preferences per tenant
- Unique constraint on (UserId, TenantId, Key)
- Used for storing settings like theme, language, sidebar state
User ↔ UserMenuFavorite (One-to-Many, Tenant-Scoped)
- Each user can bookmark multiple menu items per tenant
- Unique constraint on (UserId, TenantId, MenuItemId)
- Ordered by customizable DisplayOrder
API Endpoints Documentation
For a complete reference of all REST API endpoints with request/response schemas, authentication requirements, and examples:
- Auth Endpoints Reference — Authentication, Preferences, Menu Favorites
- CRUD Endpoints Reference — Users, Roles, Permissions, Tenants, Security, Circuit Breaker
📖 Documentation Sections
🚀
Getting Started
Step-by-step guide to set up GrydAuth in your application.
🔐
Authentication
JWT tokens, login, registration, and password management.
🔑
Authorization
Roles, permissions, and policy-based access control.
🏢
Multi-Tenancy
Tenant isolation, federation, and cross-tenant access.
🛡️
Security Features
Rate limiting, audit logging, and geo-location.
🔐
Auth Endpoints
Authentication, token management, preferences, and menu favorites.
🔌
CRUD Endpoints
Users, Roles, Permissions, Tenants, Security, and Circuit Breaker.
🔗 Related Links
- Gryd.Core Documentation - Foundation utilities
- Gryd.Domain Documentation - DDD building blocks
- GrydCrud Module - CRUD operations with auth integration