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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Nera.IAM.Common" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Nera.IAM.Common" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Nera.IAM.Common" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Nera.IAM.Common --version 1.0.0
                    
#r "nuget: Nera.IAM.Common, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Nera.IAM.Common@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Nera.IAM.Common&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Nera.IAM.Common&version=1.0.0
                    
Install as a Cake Tool

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:

  1. No Direct Dependencies: Services reference only this common package
  2. Strong Typing: Type-safe contracts for all interactions
  3. gRPC Support: Protobuf definitions for efficient communication
  4. 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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