Sort Ordering Usings and Add Support for User ID in OpenActions ...

This commit is contained in:
2026-10-30 00:15:51 +03:30
parent bc49b0aa86
commit 3b099a3089
10 changed files with 64 additions and 85 deletions
+6 -6
View File
@@ -1,15 +1,15 @@
using System;
using xIds.Models;
using xIds.Constants;
using System.Reflection;
using xIds.Configurations;
using xCommons.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using xIdentityModels.Configurations;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using MySql.EntityFrameworkCore.Infrastructure;
using xCommons.Extensions;
using xIdentityModels.Configurations;
using xIds.Configurations;
using xIds.Constants;
using xIds.Models;
using Microsoft.EntityFrameworkCore.Infrastructure;
namespace xIds.Extensions
{
@@ -1,11 +1,11 @@
using xIds.Constants;
using xCommons.Models;
using System.Reflection;
using System.Security.Cryptography.X509Certificates;
using xCommons.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using xCommons.Extensions;
using xCommons.Models;
using xIds.Constants;
using System.Security.Cryptography.X509Certificates;
namespace xIds.Extensions
{
-18
View File
@@ -1,18 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using xCommons.Extensions;
using xExceptions.Constants;
using xModels.Base;
using xIds.Constants;
namespace xIds.Extensions
{
public static class IQueryableExtensions
{
}
}
+10 -10
View File
@@ -1,20 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using xIds.Models;
using xIds.Constants;
using xIds.Interfaces;
using xCommons.Extensions;
using System.Threading.Tasks;
using IdentityServer4.EntityFramework.DbContexts;
using IdentityServer4.EntityFramework.Mappers;
using System.Collections.Generic;
using xIdentityModels.Extensions;
using xIdentityModels.Descriptors;
using Microsoft.Extensions.Logging;
using Microsoft.AspNetCore.Builder;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using IdentityServer4.EntityFramework.Mappers;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using xCommons.Extensions;
using xIdentityModels.Descriptors;
using xIdentityModels.Extensions;
using xIds.Constants;
using xIds.Interfaces;
using xIds.Models;
using IdentityServer4.EntityFramework.DbContexts;
namespace xIds.Extensions
{
+4 -4
View File
@@ -1,11 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using xCommons.Extensions;
using xDataService.Configuration;
using System.Threading.Tasks;
using xIdentityModels.Models;
using System.Collections.Generic;
using xDataService.Configuration;
using Microsoft.EntityFrameworkCore;
namespace xIds.Extensions
{
+2 -2
View File
@@ -87,9 +87,9 @@ namespace xIds.Helpers
var result = new TokenValidationParameters
{
ValidIssuer = issuer,
ValidAudience = audience,
IssuerSigningKey = key,
ValidateLifetime = true,
IssuerSigningKey = key
ValidAudience = audience,
};
//
+2 -28
View File
@@ -1,8 +1,6 @@
using System;
using IdentityModel;
using xIds.Interfaces;
using System.Threading;
using xCommons.Constants;
using xCommons.Extensions;
using xExceptions.Constants;
using System.Security.Claims;
@@ -11,12 +9,10 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Http;
using xIdentityModels.Constants;
using xIdentityService.Constants;
using System.Collections.Generic;
using xIdentityModels.Extensions;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.DependencyInjection;
using xIdentityModels.Dtos;
using xIdentityService.Extensions;
namespace xIds.Providers
{
@@ -142,29 +138,7 @@ namespace xIds.Providers
//
// Creating Claims ...
var claims = new List<Claim> {
//
// Owner Identifier of API Key ...
new(ClaimTypes.Name, validationResult.OwnerId),
new(JwtClaimTypes.Subject, validationResult.OwnerId),
//
// Application Id ...
new(XCustomClaims.ApplicationId, validationResult.ApplicationId.ToString()),
//
// Authentication Type ...
new(XCustomClaims.AuthType, apiKeyAuthentication),
};
//
// Add Scopes ...
if (validationResult.Scopes != null)
{
//
foreach (var scope in validationResult.Scopes)
{
claims.Add(new Claim(JwtClaimTypes.Scope, scope));
}
}
var claims = validationResult.ToXClaims();
//
// Create Principal and Ticket ...
@@ -304,8 +304,8 @@ namespace xIds.Providers
newExpiration = TimeSpan
.FromMinutes(apiKeyConfiguration.DefaultExpirationMinutes);
}
expiredDate = DateTime.UtcNow.Add(newExpiration.Value);
expiredDate = DateTime.UtcNow.Add(newExpiration.Value);
//
if (!expiredDate.HasValue)
{
@@ -431,8 +431,8 @@ namespace xIds.Providers
//
// Here we Have to Parse Allowed Ips and Scopes ...
var allowedIps = keyModel.AllowedIPs.IsNullOrEmpty()
? []
var allowedIps = keyModel.AllowedIPs.IsNullOrEmpty()
? []
: keyModel.AllowedIPs.ParseListString<string>();
var allowedScopes = keyModel.AllowedScopes.IsNullOrEmpty()
? []
@@ -499,7 +499,7 @@ namespace xIds.Providers
}
//
var requiredScopes =
var requiredScopes =
requiredScope.IsNullOrEmpty()
? []
: requiredScope.ParseListString<string>();
@@ -507,10 +507,10 @@ namespace xIds.Providers
//
// Check Scope and IP is Valid or not ...
var isIpValid = allowedIps.IsClientIpPassed(clientIP);
var isScopeValid =
var isScopeValid =
allowedScopes
.IsScopePassed(requiredScopes);
var isScopeIpValid =
var isScopeIpValid =
isIpValid &&
isScopeValid
;
@@ -537,6 +537,27 @@ namespace xIds.Providers
isApplicationActive;
if (isValid)
{
//
// Handle Attach Owner ...
try
{
//
var user = await identityManager.GetUserAsync(
containsDetail: true,
userSelectByParam: application.OwnerId
);
//
var owner = user.ToXPerson();
result.Owner = owner;
}
catch (Exception ex)
{
//
result.Errors.Add($"exception occured: {ex.Message}");
return result;
}
result.Errors.Clear();
}
@@ -246,10 +246,11 @@ namespace xIds.Providers
// Generate a Dynamic Object ...
var result = new XOpenActionUserInfoDto
{
UserId = userProfile.UserId,
Avatar = userProfile.Avatar,
Username = userProfile.UserName,
Firstname = userProfile.FirstName,
Lastname = userProfile.LastName,
Avatar = userProfile.Avatar
Firstname = userProfile.FirstName,
};
//
@@ -276,6 +277,7 @@ namespace xIds.Providers
);
var result = profiles.Select(x => new XOpenActionUserInfoDto
{
UserId = x.UserId,
Avatar = x.Avatar,
Username = x.UserName,
Lastname = x.LastName,
+4 -4
View File
@@ -1,11 +1,11 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using IdentityServer4.EntityFramework.DbContexts;
using IdentityServer4.EntityFramework.Mappers;
using IdentityServer4.Models;
using IdentityServer4.Stores;
using System.Threading.Tasks;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using IdentityServer4.EntityFramework.Mappers;
using IdentityServer4.EntityFramework.DbContexts;
namespace xIds.Stores
{