TrustIdentity.AI
1.0.2
dotnet add package TrustIdentity.AI --version 1.0.2
NuGet\Install-Package TrustIdentity.AI -Version 1.0.2
<PackageReference Include="TrustIdentity.AI" Version="1.0.2" />
<PackageVersion Include="TrustIdentity.AI" Version="1.0.2" />
<PackageReference Include="TrustIdentity.AI" />
paket add TrustIdentity.AI --version 1.0.2
#r "nuget: TrustIdentity.AI, 1.0.2"
#:package TrustIdentity.AI@1.0.2
#addin nuget:?package=TrustIdentity.AI&version=1.0.2
#tool nuget:?package=TrustIdentity.AI&version=1.0.2
TrustIdentity.AI
AI-powered fraud detection and behavioral analysis
📦 Overview
TrustIdentity.AI provides AI and machine learning capabilities for fraud detection, behavioral analysis, and adaptive authentication. This is a unique feature not available in Duende IdentityServer.
✨ Features
- ✅ Real-time Fraud Detection - ML-based anomaly detection
- ✅ Behavioral Analysis - User behavior profiling
- ✅ Risk Scoring - Composite risk calculation
- ✅ Adaptive Authentication - AI-driven MFA triggers
- ✅ Device Fingerprinting - Track user devices
- ✅ Anomaly Detection - Unusual access patterns
🚀 Installation
dotnet add package TrustIdentity.AI
dotnet add package TrustIdentity.ML # Optional: ML.NET integration
🔧 Usage
Basic Setup
using TrustIdentity.AspNetCore.Extensions;
builder.Services.AddTrustIdentity(options =>
{
options.IssuerUri = "https://localhost:5001";
options.EnableAI = true;
options.EnableFraudDetection = true;
})
.AddAIFraudDetection()
.AddBehaviorAnalysis()
.AddRiskScoring();
Advanced Configuration
builder.Services.AddTrustIdentity(options =>
{
options.EnableAI = true;
options.EnableFraudDetection = true;
// AI Configuration
options.AIOptions = new AIOptions
{
FraudDetectionThreshold = 0.7,
EnableBehavioralAnalysis = true,
EnableDeviceFingerprinting = true,
EnableAnomalyDetection = true,
RiskScoreThreshold = 0.8
};
});
🧠 AI Services
IFraudDetectionService
Detects fraudulent login attempts in real-time.
public interface IFraudDetectionService
{
Task<FraudDetectionResult> AnalyzeLoginAttemptAsync(LoginAttempt attempt);
Task<bool> IsSuspiciousAsync(string userId, string ipAddress);
}
Usage:
public class LoginController
{
private readonly IFraudDetectionService _fraudDetection;
public async Task<IActionResult> Login(LoginModel model)
{
var attempt = new LoginAttempt
{
UserId = model.Username,
IpAddress = HttpContext.Connection.RemoteIpAddress?.ToString(),
UserAgent = Request.Headers["User-Agent"],
Timestamp = DateTime.UtcNow
};
var result = await _fraudDetection.AnalyzeLoginAttemptAsync(attempt);
if (result.IsFraudulent)
{
// Block login or require additional verification
return Forbid("Suspicious activity detected");
}
// Continue with normal login
}
}
IBehaviorAnalysisService
Analyzes user behavior patterns.
public interface IBehaviorAnalysisService
{
Task<BehaviorProfile> GetUserProfileAsync(string userId);
Task UpdateBehaviorAsync(string userId, UserActivity activity);
Task<bool> IsAnomalousAsync(string userId, UserActivity activity);
}
Usage:
var profile = await _behaviorAnalysis.GetUserProfileAsync(userId);
var activity = new UserActivity
{
UserId = userId,
IpAddress = ipAddress,
Location = location,
DeviceId = deviceId,
Timestamp = DateTime.UtcNow
};
if (await _behaviorAnalysis.IsAnomalousAsync(userId, activity))
{
// Trigger MFA or additional verification
}
Risk Scoring
Calculate composite risk scores:
var riskScore = await _riskScoring.CalculateRiskScoreAsync(new RiskContext
{
UserId = userId,
IpAddress = ipAddress,
DeviceId = deviceId,
Location = location,
TimeOfDay = DateTime.UtcNow.TimeOfDay
});
if (riskScore > 0.8)
{
// High risk - require MFA
}
else if (riskScore > 0.5)
{
// Medium risk - additional verification
}
else
{
// Low risk - allow login
}
🎯 Use Cases
1. Adaptive MFA
Trigger MFA based on risk score:
var riskScore = await _riskScoring.CalculateRiskScoreAsync(context);
if (riskScore > 0.7)
{
// Require MFA
return RedirectToAction("MFA");
}
2. Fraud Prevention
Block suspicious login attempts:
var fraudResult = await _fraudDetection.AnalyzeLoginAttemptAsync(attempt);
if (fraudResult.IsFraudulent)
{
await _logger.LogSecurityEventAsync("Fraudulent login blocked", userId);
return Forbid();
}
3. Device Tracking
Track and verify user devices:
var deviceId = await _deviceFingerprinting.GetDeviceIdAsync(request);
var isKnownDevice = await _deviceTracking.IsKnownDeviceAsync(userId, deviceId);
if (!isKnownDevice)
{
// New device - send verification email
await _emailService.SendNewDeviceNotificationAsync(userId, deviceId);
}
📊 AI Models
Fraud Detection Model
- Algorithm: Isolation Forest
- Features: IP address, location, time of day, device, user agent
- Training: Continuous learning from login patterns
Behavioral Analysis Model
- Algorithm: LSTM (Long Short-Term Memory)
- Features: Login times, locations, devices, access patterns
- Training: Per-user behavior profiling
Risk Scoring Model
- Algorithm: Ensemble (Random Forest + Gradient Boosting)
- Features: Composite of fraud and behavior scores
- Training: Supervised learning on labeled data
🔧 Configuration
appsettings.json
{
"TrustIdentity": {
"AI": {
"EnableFraudDetection": true,
"EnableBehavioralAnalysis": true,
"EnableRiskScoring": true,
"FraudDetectionThreshold": 0.7,
"RiskScoreThreshold": 0.8,
"ModelUpdateInterval": 3600,
"EnableDeviceFingerprinting": true
}
}
}
🏗️ Architecture
TrustIdentity.AI/
├── Analyzers/ # AI analyzers
│ ├── FraudDetectionService.cs
│ ├── BehaviorAnalysisService.cs
│ └── RiskScoringService.cs
├── Models/ # ML models
├── Services/ # AI services
└── Extensions/ # Configuration extensions
📚 Documentation
- Setup Guide - General setup
- Main Documentation - Overview
📄 License
Apache 2.0 - See LICENSE
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.ML (>= 5.0.0)
- TrustIdentity.Abstractions (>= 1.0.2)
- TrustIdentity.Core (>= 1.0.2)
- TrustIdentity.ML (>= 1.0.2)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on TrustIdentity.AI:
| Package | Downloads |
|---|---|
|
TrustIdentity.AspNetCore
ASP.NET Core middleware, tag helpers, and integration for TrustIdentity server. |
|
|
TrustIdentity.Server
Complete Enterprise IAM Server - OAuth 2.0, OIDC, SAML, WS-Fed |
GitHub repositories
This package is not used by any popular GitHub repositories.
- Full implementation of OAuth 2.0 and OpenID Connect 1.0.
- Integrated SAML 2.0 and WS-Federation support.
- Advanced AI/ML-driven fraud detection and behavioral analysis.
- FAPI 1.0 & 2.0 (Security Profile) compliance.
- Support for PKCE, DPoP, Mutual TLS, PAR, and JAR.
- Entity Framework Core support for SQL Server, PostgreSQL, MySQL, and SQLite.
- Multi-tenant isolation and Backend-for-Frontend (BFF) patterns.
- Complete Admin UI and REST API for identity management.