TrustIdentity.AI 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package TrustIdentity.AI --version 1.0.1
                    
NuGet\Install-Package TrustIdentity.AI -Version 1.0.1
                    
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="TrustIdentity.AI" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TrustIdentity.AI" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="TrustIdentity.AI" />
                    
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 TrustIdentity.AI --version 1.0.1
                    
#r "nuget: TrustIdentity.AI, 1.0.1"
                    
#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 TrustIdentity.AI@1.0.1
                    
#: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=TrustIdentity.AI&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=TrustIdentity.AI&version=1.0.1
                    
Install as a Cake Tool

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


📄 License

Apache 2.0 - See LICENSE

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.

Version Downloads Last Updated
1.0.2 120 2/5/2026
1.0.1 110 2/4/2026
1.0.0 120 1/22/2026

- 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.