diff --git a/Controllers/Account/AccountController+Open.cs b/Controllers/Account/AccountController+Open.cs index 71d114c..02266a2 100644 --- a/Controllers/Account/AccountController+Open.cs +++ b/Controllers/Account/AccountController+Open.cs @@ -15,6 +15,12 @@ namespace xIds.Controllers // #region Open Actions ... + /// + /// Get Open Action ... + /// + /// + /// + /// [AllowAnonymous] [RequireXPowered] [HttpGet("Open")] diff --git a/Controllers/Account/AccountController+Test.cs b/Controllers/Account/AccountController+Test.cs index 14a78f3..cb6f9a2 100644 --- a/Controllers/Account/AccountController+Test.cs +++ b/Controllers/Account/AccountController+Test.cs @@ -15,7 +15,7 @@ namespace xIds.Controllers // #region Test Actions ... /// - /// API Read Scope + /// API Read Scope ... /// /// string message [RequireXPowered] @@ -28,7 +28,7 @@ namespace xIds.Controllers } /// - /// API Write Scope + /// API Write Scope ... /// /// string message [RequireXPowered] @@ -41,7 +41,7 @@ namespace xIds.Controllers } /// - /// API Admin Scope + /// API Admin Scope ... /// /// string message [RequireXPowered] @@ -54,7 +54,7 @@ namespace xIds.Controllers } /// - /// API Manage Scop + /// API Manage Scop ... /// /// string message [RequireXPowered] @@ -67,7 +67,7 @@ namespace xIds.Controllers } /// - /// a simple Action which returns a List of Authenticated User Claims + /// a simple Action which returns a List of Authenticated User Claims ... /// /// string message which represent current user's claims [RequireXPowered] @@ -92,7 +92,7 @@ namespace xIds.Controllers } /// - /// a simple Hello User for Checking Authentication and Policy + /// a simple Hello User for Checking Authentication and Policy ... /// /// string message which contains authenticated user name [RequireXPowered] @@ -109,7 +109,7 @@ namespace xIds.Controllers } /// - /// a simple Hello User for Checking Authentication and Policy + /// a simple Hello User for Checking Authentication and Policy ... /// /// string message which contains authenticated user name [RequireXPowered] @@ -126,7 +126,7 @@ namespace xIds.Controllers } /// - /// a simple Hello User for Checking Authentication and Policy + /// a simple Hello User for Checking Authentication and Policy ... /// /// string message which contains authenticated user name [RequireXPowered] @@ -143,7 +143,7 @@ namespace xIds.Controllers } /// - /// a simple Hello User for Checking Authentication and Policy + /// a simple Hello User for Checking Authentication and Policy ... /// /// string message which contains authenticated user name [RequireXPowered] @@ -159,11 +159,15 @@ namespace xIds.Controllers return Ok(result); } + /// + /// a simple Hello for Accessing ApiKey Authorization ... + /// + /// + [XApiKeyAccess] [AllowAnonymous] [RequireXPowered] [HttpGet("Test/HiApiKeyAccess")] [Authorize(LocalApi.PolicyName)] - [XApiKeyAccess(scopes: [XApiKeyScope.Manage])] public ActionResult HiApiKeyAccess() { // @@ -173,11 +177,15 @@ namespace xIds.Controllers return Ok(result); } + /// + /// a simple Hello for Accessing ApiKey Read Access ... + /// + /// [AllowAnonymous] [RequireXPowered] [Authorize(LocalApi.PolicyName)] [HttpGet("Test/HiApiKeyReadAccess")] - [XApiKeyAccess(scopes: [XApiKeyScope.Read])] + [XApiKeyAccess(Scopes = [XApiKeyScope.Read])] public ActionResult HiApiKeyReadAccess() { // @@ -187,6 +195,10 @@ namespace xIds.Controllers return Ok(result); } + /// + /// a simple Hello for Accessing ApiKey Write Access ... + /// + /// [AllowAnonymous] [RequireXPowered] [Authorize(LocalApi.PolicyName)] @@ -201,6 +213,10 @@ namespace xIds.Controllers return Ok(result); } + /// + /// a simple Hello for Accessing ApiKey Manage Access ... + /// + /// [AllowAnonymous] [RequireXPowered] [Authorize(LocalApi.PolicyName)] @@ -215,6 +231,10 @@ namespace xIds.Controllers return Ok(result); } + /// + /// a simple Hello for Accessing ApiKey Admin Access ... + /// + /// [AllowAnonymous] [RequireXPowered] [Authorize(LocalApi.PolicyName)] diff --git a/Controllers/Applications/ApplicationsController+ApiKey.cs b/Controllers/Applications/ApplicationsController+ApiKey.cs index ed90f59..077f8b5 100644 --- a/Controllers/Applications/ApplicationsController+ApiKey.cs +++ b/Controllers/Applications/ApplicationsController+ApiKey.cs @@ -1,8 +1,8 @@ using System; using System.Linq; using xModels.Dtos; -using System.Threading; using xIdentityHelper; +using System.Threading; using xCommons.Attributes; using xCommons.Extensions; using xIdentityModels.Dtos; diff --git a/Providers/XApiKeyAccessAttribute.cs b/Providers/XApiKeyAccessAttribute.cs index 22aac55..f833874 100644 --- a/Providers/XApiKeyAccessAttribute.cs +++ b/Providers/XApiKeyAccessAttribute.cs @@ -1,6 +1,7 @@ using System; using IdentityModel; using xIds.Interfaces; +using System.Threading; using xCommons.Constants; using xCommons.Extensions; using xExceptions.Constants; @@ -13,7 +14,6 @@ using xIdentityService.Constants; using System.Collections.Generic; using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.Authorization; -using System.Threading; namespace xIds.Providers { @@ -36,7 +36,7 @@ namespace xIds.Providers // if (!scopes.HasChild()) { - scopes = [XApiKeyScope.Manage]; + scopes = [XApiKeyScope.Read]; } // @@ -84,7 +84,7 @@ namespace xIds.Providers { // error.Message = "Api Key Service not Registered ..."; - context.Result = new UnauthorizedObjectResult(error.ToJSON()); + context.Result = new UnauthorizedObjectResult(error); return; } @@ -95,7 +95,7 @@ namespace xIds.Providers { // error.Message = "ApiKey not Exists ..."; - context.Result = new UnauthorizedObjectResult(error.ToJSON()); + context.Result = new UnauthorizedObjectResult(error); return; } @@ -106,7 +106,7 @@ namespace xIds.Providers { // error.Message = "ApiKey not Provided ..."; - context.Result = new UnauthorizedObjectResult(error.ToJSON()); + context.Result = new UnauthorizedObjectResult(error); return; } @@ -131,9 +131,9 @@ namespace xIds.Providers if (validationResult.Errors.HasChild()) { // - var message = validationResult.Errors.ToListString('\n'); + var message = validationResult.Errors.ToListString(','); error.Message = message; - context.Result = new UnauthorizedObjectResult(error.ToJSON()); + context.Result = new UnauthorizedObjectResult(error); return; } @@ -175,7 +175,7 @@ namespace xIds.Providers { // error.Message = "ApiKey authorization failed ..."; - context.Result = new UnauthorizedObjectResult(error.ToJSON()); + context.Result = new UnauthorizedObjectResult(error); } } } diff --git a/Providers/XApplicationProvider/XApplicationProvider+Custom.cs b/Providers/XApplicationProvider/XApplicationProvider+Custom.cs index 21c39fa..b3ba941 100644 --- a/Providers/XApplicationProvider/XApplicationProvider+Custom.cs +++ b/Providers/XApplicationProvider/XApplicationProvider+Custom.cs @@ -512,13 +512,10 @@ namespace xIds.Providers var isIpValid = !allowedIps.HasChild() || allowedIps.Contains(clientIP); - var isScopeValid = - !allowedScopes.HasChild() || - requiredScope.IsNullOrEmpty() || - requiredScopes - .All(ts => allowedScopes - .Any(asc => asc.ToNormalString() == ts.ToNormalString())); - var isScopeIpValid = + var isScopeValid = + allowedScopes + .IsScopePassed(requiredScopes); + var isScopeIpValid = isIpValid && isScopeValid ; diff --git a/Providers/XIdentityManager/XIdentityManager+Open.cs b/Providers/XIdentityManager/XIdentityManager+Open.cs index cac2d35..cdc963e 100644 --- a/Providers/XIdentityManager/XIdentityManager+Open.cs +++ b/Providers/XIdentityManager/XIdentityManager+Open.cs @@ -1,10 +1,10 @@ using System; -using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; using xCommons.Extensions; -using xExceptions.Constants; using xIdentityModels.Dtos; +using xExceptions.Constants; +using System.Threading.Tasks; +using System.Collections.Generic; namespace xIds.Providers { @@ -12,6 +12,11 @@ namespace xIds.Providers { // #region OpenGet ... + /// + /// Get Open Action ... + /// + /// + /// public async Task OpenGet( XOpenActionInnerDto model ) @@ -32,7 +37,12 @@ namespace xIds.Providers ); } - // + /// + /// Get Open Action ... + /// + /// + /// + /// public async Task OpenGet( string token, string actionRequest @@ -119,6 +129,11 @@ namespace xIds.Providers } #endregion + /// + /// Get User Info For Open Actions ... + /// + /// + /// public async Task GetUserInfo( XOpenActionRequestDto model ) @@ -147,6 +162,11 @@ namespace xIds.Providers return result; } + /// + /// Retrieve a Collection of Open Actions User Info by Providing Ids ... + /// + /// + /// public async Task> GetUserInfos( XOpenActionRequestDto model ) @@ -174,6 +194,12 @@ namespace xIds.Providers // #region Private ... + /// + /// Parse Models ... + /// + /// + /// + /// private XOpenActionRequestDto ParseModel( string token, string request