ProMilesV5.SharedOps
1.4.4
See the version list below for details.
Install-Package ProMilesV5.SharedOps -Version 1.4.4
dotnet add package ProMilesV5.SharedOps --version 1.4.4
<PackageReference Include="ProMilesV5.SharedOps" Version="1.4.4" />
paket add ProMilesV5.SharedOps --version 1.4.4
#r "nuget: ProMilesV5.SharedOps, 1.4.4"
// Install ProMilesV5.SharedOps as a Cake Addin
#addin nuget:?package=ProMilesV5.SharedOps&version=1.4.4
// Install ProMilesV5.SharedOps as a Cake Tool
#tool nuget:?package=ProMilesV5.SharedOps&version=1.4.4
ProMilesV5.SharedOps
Shared .NET 8.0 class library for ProMiles projects.
Features
- Company Services: Shared company validation and fuel tax ID operations with environment awareness
- Claims Processing: Authentication claims parsing for application access and feature management with URL resolution
- Database-Backed URL Lookup: Primary database lookup only for application URLs
- Environment Awareness: Automatic environment detection and URL resolution with database-only approach
- URL Management: Database-only URL resolution for environment-specific application URLs
- Reseller Information: Reseller code and ID extraction from authentication claims
- Common Operations: Utilities and shared functionality across ProMiles applications
- Zero Configuration: Consumer apps only need to register services - no URL configuration required
- Docker Ready: Optimized for containerized workflows
Getting Started
Build
dotnet build
Usage
Reference this library in your .NET projects:
<ItemGroup>
<PackageReference Include="ProMilesV5.SharedOps" Version="1.4.4" />
</ItemGroup>
Dependency Injection Setup
using ProMilesV5.SharedOps.DI;
// In your Program.cs or Startup.cs
builder.Services.AddProMilesV5SharedOps();
The service automatically detects the environment and uses appropriate connection strings from your appsettings.json:
AuthDefault- Default connection stringAuthDev- Development environmentAuthBeta- Beta environmentAuthStaging- Staging environmentAppsMasterDefault- AppsMaster database defaultAppsMasterDev- AppsMaster database developmentAppsMasterBeta- AppsMaster database betaAppsMasterStaging- AppsMaster database staging
Claims Processing
The library provides comprehensive claims processing functionality for client applications to parse authentication claims and extract application access and feature information.
Key Components
AuthClaimsUtility: Static utility class for parsing claimsIClaimsService: Service interface for dependency injectionClaimsService: Service implementation with comprehensive claims processing and URL resolutionIdentityInformation: Convenience container for parsed claims dataIAppUrlResolver: Service for resolving environment-specific application URLsIEnvironmentResolver: Service for environment detection and normalization
Models
FeatureAccessDto: Represents feature access claimsFeatureValueDto: Represents feature value claimsResolvedFeature: Represents resolved features with precedenceIdentityInformation: Complete parsed claims containerClaimsProcessingResult: Legacy result container for claims processingRegistrationData: User registration data extracted from claimsSharedOpsEnvironment: Enum representing normalized environment types
Environment Awareness
The library automatically detects the current environment and resolves application URLs accordingly. No consumer configuration is required.
Environment Detection
The library normalizes environment names as follows:
dev,development→Developmentbeta→Betastage,staging→Staging- All others →
Production
URL Resolution
Application URLs are automatically resolved based on the current environment using database lookup with JSON fallback:
// Get applications with their URLs (JSON-based)
var appsWithUrls = claimsService.GetApplicationAccessWithURL(user);
// Returns: { "FTO": "https://fto.promiles.com", "PMO": "https://pmo.promiles.com" }
// Get applications with database-backed URLs (NEW)
var appsWithDbUrls = await claimsService.GetApplicationAccessWithUrlDynamicAsync(user);
// Returns: Dictionary with ApplicationUrlResult containing URL and source (Database/Json)
// Get reseller information (NEW)
var identityInfo = claimsService.CreateIdentityInformation(user, companyId);
var resellerCode = identityInfo.ResellerCode; // e.g., "RES001"
var resellerId = identityInfo.ResellerId; // e.g., "12345"
Supported Applications
The embedded URL catalog includes URLs for:
- FTO: Fuel Tax Online
- PMO: ProMiles Online
- DM: Driver Management
- FLEET: Fleet Management
- REPORTS: Reporting System
Usage Examples
Basic Claims Processing
using ProMilesV5.SharedOps.Services;
using ProMilesV5.SharedOps.Utilities;
// Using the service (recommended for DI)
var claimsService = serviceProvider.GetRequiredService<IClaimsService>();
var identityInfo = claimsService.CreateIdentityInformation(user, companyId);
// Get applications with their URLs (NEW)
var appsWithUrls = claimsService.GetApplicationAccessWithURL(user);
// Returns: { "FTO": "https://fto.promiles.com", "PMO": "https://pmo.promiles.com" }
// Using the utility directly
var apps = AuthClaimsUtility.GetApps(user);
var features = AuthClaimsUtility.GetRelevantFeatureValuesForCompany(user, companyId);
Working with IdentityInformation
var identityInfo = claimsService.CreateIdentityInformation(user, companyId);
// Access application list
foreach (var app in identityInfo.ApplicationAccess)
{
Console.WriteLine($"User has access to: {app}");
}
// Check specific features
if (identityInfo.HasFeature("AdvancedReporting", "Enabled"))
{
// Enable advanced reporting features
}
// Access all resolved features
foreach (var feature in identityInfo.FeaturesForCompany)
{
Console.WriteLine($"Feature: {feature.Role}, Value: {feature.Value}");
}
Comprehensive Claims Processing
For applications that need comprehensive claims processing with registration data:
using ProMilesV5.SharedOps.Services;
using ProMilesV5.SharedOps.Models.Claims;
// Using the claims service for comprehensive processing
var claimsService = serviceProvider.GetRequiredService<IClaimsService>();
var result = claimsService.ProcessClaims(claims);
// Access results
foreach (var app in result.ApplicationAccess)
{
Console.WriteLine($"User has access to: {app}");
}
foreach (var feature in result.ResellerFeatures)
{
Console.WriteLine($"Feature: {feature.Key}, Value: {feature.Value}");
}
// Access registration data
var regData = result.RegistrationData;
Console.WriteLine($"User: {regData.FirstName} {regData.LastName}");
Console.WriteLine($"Company: {regData.Company}");
Claims Structure
The library expects claims in the following format:
Role Claims
- Type:
ClaimTypes.Role - Value: Application name (e.g., "App1", "App2")
Feature Access Claims
- Type:
"FeatureAccess" - Value: JSON object with
role,assigned, andcompanyIdproperties
Feature Value Claims
- Type:
"FeatureValue" - Value: JSON object with
role,value,companyId, andscopeproperties
Assignment Precedence
Features are resolved with the following precedence order:
- User - User-specific assignments
- Company - Company-specific assignments (exact company ID match)
- All Users - Global user assignments
- App - Application-level assignments
Configuration
- Place your settings in
appsettings.json,appsettings.Development.json, orappsettings.Beta.jsonas needed. - Files are copied to output automatically.
Docker
Build the Docker image:
docker build -t promilesv5-sharedops .
Development
- Target Framework: .NET 8.0
- Nullable enabled, implicit usings enabled
Authors
ProMiles
License
[Specify your license here]
-
net8.0
- Microsoft.EntityFrameworkCore.SqlServer (>= 8.0.18)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Http (>= 8.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.3)
- System.Text.Json (>= 8.0.6)
NuGet packages
This package is not used by any NuGet packages.
| Version | Downloads | Last updated |
|---|---|---|
| 1.4.23 | 0 | 10/22/2025 |
| 1.4.22 | 0 | 10/17/2025 |
| 1.4.21 | 0 | 10/17/2025 |
| 1.4.20 | 0 | 10/17/2025 |
| 1.4.19 | 0 | 10/16/2025 |
| 1.4.18 | 0 | 10/16/2025 |
| 1.4.17 | 0 | 10/16/2025 |
| 1.4.16 | 0 | 10/16/2025 |
| 1.4.14 | 0 | 10/16/2025 |
| 1.4.12 | 0 | 10/16/2025 |
| 1.4.11 | 0 | 10/15/2025 |
| 1.4.10 | 0 | 10/15/2025 |
| 1.4.8 | 0 | 10/15/2025 |
| 1.4.7 | 0 | 10/15/2025 |
| 1.4.6 | 0 | 10/15/2025 |
| 1.4.5 | 0 | 10/15/2025 |
| 1.4.4 | 0 | 10/15/2025 |
| 1.4.3 | 0 | 10/15/2025 |
| 1.4.2 | 0 | 10/15/2025 |
| 1.4.1 | 0 | 10/10/2025 |
| 1.4.0 | 0 | 10/10/2025 |
| 1.3.8 | 0 | 10/3/2025 |
| 1.3.7 | 0 | 10/3/2025 |
| 1.3.6 | 0 | 10/3/2025 |
| 1.3.5 | 0 | 10/2/2025 |
| 1.3.4 | 0 | 10/2/2025 |
| 1.3.3 | 0 | 10/2/2025 |
| 1.3.2 | 0 | 10/2/2025 |
| 1.3.0 | 0 | 9/18/2025 |
| 1.2.7 | 0 | 9/18/2025 |
| 1.2.6 | 0 | 9/18/2025 |
| 1.2.5 | 0 | 9/18/2025 |
| 1.2.3 | 0 | 9/17/2025 |
See CHANGELOG.md for detailed release notes