Nera.IAM.Common
1.0.0
dotnet add package Nera.IAM.Common --version 1.0.0
NuGet\Install-Package Nera.IAM.Common -Version 1.0.0
<PackageReference Include="Nera.IAM.Common" Version="1.0.0" />
<PackageVersion Include="Nera.IAM.Common" Version="1.0.0" />
<PackageReference Include="Nera.IAM.Common" />
paket add Nera.IAM.Common --version 1.0.0
#r "nuget: Nera.IAM.Common, 1.0.0"
#:package Nera.IAM.Common@1.0.0
#addin nuget:?package=Nera.IAM.Common&version=1.0.0
#tool nuget:?package=Nera.IAM.Common&version=1.0.0
Nera IAM Common
Common contracts, models, and protobuf definitions for Nera IAM Services.
Overview
This package provides shared contracts and models that enable loose coupling between IAM services while maintaining strong typing and consistent communication patterns.
Features
- Shared Enums: Common enumerations used across all IAM services
- Base Models: Response models, pagination, error handling
- Entity Models: User, Role, Permission, Token, Session, Organization models
- Service Contracts: Interfaces for inter-service communication
- Constants: Service names, cache keys, error codes, system roles/permissions
- Extensions: Utility methods for common operations
- gRPC Protobuf: Common message definitions for gRPC communication
Installation
<PackageReference Include="Nera.IAM.Common" Version="1.0.0" />
Usage
Service Contracts
Use the service contracts to communicate between IAM services:
public class AuthenticationService
{
private readonly IUserServiceClient _userService;
private readonly ITokenServiceClient _tokenService;
public async Task<TokenInfo> AuthenticateAsync(string email, string password)
{
var user = await _userService.GetUserByEmailAsync(email);
if (user?.Status.IsActive() == true)
{
var tokenId = await _tokenService.CreateTokenAsync(
user.UserId,
user.OrgId,
TokenType.AccessToken,
TokenType.AccessToken.GetDefaultExpiration()
);
return await _tokenService.GetTokenAsync(tokenId);
}
throw new UnauthorizedAccessException();
}
}
Common Models
Use shared models for consistent data structures:
public async Task<BaseResponse<UserInfo>> GetUserAsync(string userId)
{
try
{
var user = await _repository.GetAsync(userId);
return new BaseResponse<UserInfo>
{
Success = true,
Data = user.ToUserInfo(),
Message = "User retrieved successfully"
};
}
catch (Exception ex)
{
return new BaseResponse<UserInfo>
{
Success = false,
Message = ex.Message
};
}
}
Constants
Use predefined constants for consistency:
// Cache keys
var cacheKey = $"{IamConstants.CacheKeys.UserPrefix}{userId}";
// Service names for discovery
var serviceName = IamConstants.ServiceNames.UserService;
// Error codes
if (!user.Status.IsActive())
{
throw new BusinessException(IamConstants.ErrorCodes.UserInactive);
}
// System roles
await _roleService.AssignRoleAsync(userId, IamConstants.SystemRoles.User);
Extensions
Use extension methods for common operations:
// Check if user is active
if (user.Status.IsActive())
{
// Process active user
}
// Get default token expiration
var expiration = TokenType.AccessToken.GetDefaultExpiration();
// Check permission level
if (userPermission.AllowsAction(PermissionLevel.Write))
{
// Allow write operation
}
Service Integration
This package enables clean service-to-service communication:
- No Direct Dependencies: Services reference only this common package
- Strong Typing: Type-safe contracts for all interactions
- gRPC Support: Protobuf definitions for efficient communication
- Consistent Patterns: Standardized request/response models
Architecture Benefits
- Loose Coupling: Services depend only on contracts, not implementations
- Consistency: Shared models ensure consistent data structures
- Maintainability: Centralized contracts make changes easier to manage
- Type Safety: Compile-time checking of service interactions
- Performance: Efficient gRPC communication with protobuf
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- Google.Protobuf (>= 3.32.1)
- Grpc.AspNetCore (>= 2.71.0)
- Grpc.AspNetCore.Server.Reflection (>= 2.71.0)
- Grpc.Core.Api (>= 2.71.0)
- Grpc.Net.Client (>= 2.71.0)
- MassTransit (>= 8.5.4)
- MassTransit.AspNetCore (>= 7.3.1)
- MassTransit.RabbitMQ (>= 8.5.4)
- Nera.Lib.Grpc.Common (>= 1.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 193 | 10/13/2025 |