Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion SecurityService/Controllers/ApiResourceController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
/*using System;

Check notice on line 1 in SecurityService/Controllers/ApiResourceController.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

SecurityService/Controllers/ApiResourceController.cs#L1

Remove this commented out code.
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
Expand Down Expand Up @@ -122,3 +122,4 @@
#endregion
}
}
*/
4 changes: 2 additions & 2 deletions SecurityService/Controllers/ApiScopeController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using MediatR;
/*using MediatR;

Check notice on line 1 in SecurityService/Controllers/ApiScopeController.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

SecurityService/Controllers/ApiScopeController.cs#L1

Remove this commented out code.
using Microsoft.AspNetCore.Http;
using SecurityService.BusinessLogic.RequestHandlers;
using SecurityService.BusinessLogic.Requests;
Expand Down Expand Up @@ -109,4 +109,4 @@

#endregion
}
}
}*/
4 changes: 2 additions & 2 deletions SecurityService/Controllers/ClientController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Http;
/*using Microsoft.AspNetCore.Http;

Check notice on line 1 in SecurityService/Controllers/ClientController.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

SecurityService/Controllers/ClientController.cs#L1

Remove this commented out code.
using Shared.Results.Web;
using SimpleResults;

Expand Down Expand Up @@ -155,4 +155,4 @@

#endregion
}
}
}*/
3 changes: 2 additions & 1 deletion SecurityService/Controllers/DeveloperController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Http;
/*using Microsoft.AspNetCore.Http;

Check notice on line 1 in SecurityService/Controllers/DeveloperController.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

SecurityService/Controllers/DeveloperController.cs#L1

Remove this commented out code.
using Microsoft.AspNetCore.Mvc;

namespace SecurityService.Controllers
Expand Down Expand Up @@ -64,3 +64,4 @@
#endregion
}
}
*/
4 changes: 2 additions & 2 deletions SecurityService/Controllers/IdentityResourceController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Http;
/*using Microsoft.AspNetCore.Http;

Check notice on line 1 in SecurityService/Controllers/IdentityResourceController.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

SecurityService/Controllers/IdentityResourceController.cs#L1

Remove this commented out code.
using Shared.Results.Web;
using SimpleResults;

Expand Down Expand Up @@ -140,4 +140,4 @@

#endregion
}
}
}*/
3 changes: 2 additions & 1 deletion SecurityService/Controllers/RoleController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
/*using System;

Check notice on line 1 in SecurityService/Controllers/RoleController.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

SecurityService/Controllers/RoleController.cs#L1

Remove this commented out code.
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
Expand Down Expand Up @@ -123,3 +123,4 @@
#endregion
}
}
*/
4 changes: 2 additions & 2 deletions SecurityService/Controllers/UserController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Http;
/*using Microsoft.AspNetCore.Http;

Check notice on line 1 in SecurityService/Controllers/UserController.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

SecurityService/Controllers/UserController.cs#L1

Remove this commented out code.
using Shared.Results;
using Shared.Results.Web;
using SimpleResults;
Expand Down Expand Up @@ -144,4 +144,4 @@

#endregion
}
}
}*/
21 changes: 21 additions & 0 deletions SecurityService/Endpoints/ApiResourceEndpoints.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Microsoft.AspNetCore.Routing;

namespace SecurityService.Endpoints
{
using Microsoft.AspNetCore.Builder;

public static class ApiResourceEndpoints
{
public static void MapApiResourceEndpoints(this IEndpointRouteBuilder endpoints)
{
endpoints.MapPost("api/apiresources", Handlers.ApiResourceHandler.CreateApiResource)
.WithName("CreateApiResource");

endpoints.MapGet("api/apiresources/{apiResourceName}", Handlers.ApiResourceHandler.GetApiResource)
.WithName("GetApiResource");

endpoints.MapGet("api/apiresources", Handlers.ApiResourceHandler.GetApiResources)
.WithName("GetApiResources");
}
}
}
21 changes: 21 additions & 0 deletions SecurityService/Endpoints/ApiScopeEndpoints.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Microsoft.AspNetCore.Routing;

namespace SecurityService.Endpoints
{
using Microsoft.AspNetCore.Builder;

public static class ApiScopeEndpoints
{
public static void MapApiScopeEndpoints(this IEndpointRouteBuilder endpoints)
{
endpoints.MapPost("api/apiscopes", Handlers.ApiScopeHandler.CreateApiScope)
.WithName("CreateApiScope");

endpoints.MapGet("api/apiscopes/{apiScopeName}", Handlers.ApiScopeHandler.GetApiScope)
.WithName("GetApiScope");

endpoints.MapGet("api/apiscopes", Handlers.ApiScopeHandler.GetApiScopes)
.WithName("GetApiScopes");
}
}
}
21 changes: 21 additions & 0 deletions SecurityService/Endpoints/ClientEndpoints.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Microsoft.AspNetCore.Routing;

namespace SecurityService.Endpoints
{
using Microsoft.AspNetCore.Builder;

public static class ClientEndpoints
{
public static void MapClientEndpoints(this IEndpointRouteBuilder endpoints)
{
endpoints.MapPost("api/clients", Handlers.ClientHandler.CreateClient)
.WithName("CreateClient");

endpoints.MapGet("api/clients/{clientId}", Handlers.ClientHandler.GetClient)
.WithName("GetClient");

endpoints.MapGet("api/clients", Handlers.ClientHandler.GetClients)
.WithName("GetClients");
}
}
}
18 changes: 18 additions & 0 deletions SecurityService/Endpoints/DeveloperEndpoints.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Microsoft.AspNetCore.Routing;

namespace SecurityService.Endpoints
{
using Microsoft.AspNetCore.Builder;

public static class DeveloperEndpoints
{
public static void MapDeveloperEndpoints(this IEndpointRouteBuilder endpoints)
{
endpoints.MapGet("api/developer/lastemail", Handlers.DeveloperHandler.GetLastEmailMessage)
.WithName("GetLastEmailMessage");

endpoints.MapGet("api/developer/lastsms", Handlers.DeveloperHandler.GetLastSMSMessage)
.WithName("GetLastSMSMessage");
}
}
}
22 changes: 22 additions & 0 deletions SecurityService/Endpoints/IdentityResourceEndpoints.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Microsoft.AspNetCore.Routing;

namespace SecurityService.Endpoints
{
using Microsoft.AspNetCore.Builder;

public static class IdentityResourceEndpoints
{
public static void MapIdentityResourceEndpoints(this IEndpointRouteBuilder endpoints)
{
endpoints.MapPost("api/identityresources", Handlers.IdentityResourceHandler.CreateIdentityResource)
.WithName("CreateIdentityResource");


endpoints.MapGet("api/identityresources/{apiResourceName}", Handlers.IdentityResourceHandler.GetIdentityResource)
.WithName("GetIdentityResource");

endpoints.MapGet("api/identityresources", Handlers.IdentityResourceHandler.GetIdentityResources)
.WithName("GetIdentityResources");
}
}
}
21 changes: 21 additions & 0 deletions SecurityService/Endpoints/RoleEndpoints.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Microsoft.AspNetCore.Routing;

namespace SecurityService.Endpoints
{
using Microsoft.AspNetCore.Builder;

public static class RoleEndpoints
{
public static void MapRoleEndpoints(this IEndpointRouteBuilder endpoints)
{
endpoints.MapPost("api/roles", Handlers.RoleHandler.CreateRole)
.WithName("CreateRole");

endpoints.MapGet("api/roles/{roleId:guid}", Handlers.RoleHandler.GetRole)
.WithName("GetRole");

endpoints.MapGet("api/roles", Handlers.RoleHandler.GetRoles)
.WithName("GetRoles");
}
}
}
21 changes: 21 additions & 0 deletions SecurityService/Endpoints/UserEndpoints.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Microsoft.AspNetCore.Routing;

namespace SecurityService.Endpoints
{
using Microsoft.AspNetCore.Builder;

public static class UserEndpoints
{
public static void MapUserEndpoints(this IEndpointRouteBuilder endpoints)
{
endpoints.MapPost("api/users", Handlers.UserHandler.CreateUser)
.WithName("CreateUser");

endpoints.MapGet("api/users/{userId:guid}", Handlers.UserHandler.GetUser)
.WithName("GetUser");

endpoints.MapGet("api/users", Handlers.UserHandler.GetUsers)
.WithName("GetUsers");
}
}
}
61 changes: 61 additions & 0 deletions SecurityService/Handlers/ApiResourceHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MediatR;
using SecurityService.BusinessLogic.Requests;
using Shared.Results;
using Shared.Results.Web;
using SimpleResults;

namespace SecurityService.Handlers
{
using DataTransferObjects.Requests;
using Factories;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SecurityService.BusinessLogic;

public static class ApiResourceHandler
{
public static async Task<IResult> CreateApiResource(IMediator mediator,
CreateApiResourceRequest createApiResourceRequest,
CancellationToken cancellationToken)
{
var command = new SecurityServiceCommands.CreateApiResourceCommand(
createApiResourceRequest.Name,
createApiResourceRequest.DisplayName,
createApiResourceRequest.Description,
createApiResourceRequest.Secret,
createApiResourceRequest.Scopes,
createApiResourceRequest.UserClaims);

Result result = await mediator.Send(command, cancellationToken);

return ResponseFactory.FromResult(result);
}

public static async Task<IResult> GetApiResource(IMediator mediator,
IModelFactory modelFactory,
string apiResourceName,
CancellationToken cancellationToken)
{
var query = new SecurityServiceQueries.GetApiResourceQuery(apiResourceName);

Result<Duende.IdentityServer.Models.ApiResource> result = await mediator.Send(query, cancellationToken);

return ResponseFactory.FromResult(result, modelFactory.ConvertFrom);
}

public static async Task<IResult> GetApiResources(IMediator mediator,
IModelFactory modelFactory,
CancellationToken cancellationToken)
{
var query = new SecurityServiceQueries.GetApiResourcesQuery();

Result<List<Duende.IdentityServer.Models.ApiResource>> result = await mediator.Send(query, cancellationToken);

return ResponseFactory.FromResult(result, modelFactory.ConvertFrom);
}
}
}
58 changes: 58 additions & 0 deletions SecurityService/Handlers/ApiScopeHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MediatR;
using SecurityService.BusinessLogic.Requests;
using Shared.Results;
using Shared.Results.Web;
using SimpleResults;

namespace SecurityService.Handlers
{
using DataTransferObjects.Requests;
using Factories;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SecurityService.BusinessLogic;

public static class ApiScopeHandler
{
public static async Task<IResult> CreateApiScope(IMediator mediator,
CreateApiScopeRequest createApiScopeRequest,
CancellationToken cancellationToken)
{
var command = new SecurityServiceCommands.CreateApiScopeCommand(
createApiScopeRequest.Name,
createApiScopeRequest.DisplayName,
createApiScopeRequest.Description);

Result result = await mediator.Send(command, cancellationToken);

return ResponseFactory.FromResult(result);
}

public static async Task<IResult> GetApiScope(IMediator mediator,
IModelFactory modelFactory,
string apiScopeName,
CancellationToken cancellationToken)
{
var query = new SecurityServiceQueries.GetApiScopeQuery(apiScopeName);

Result<Duende.IdentityServer.Models.ApiScope> result = await mediator.Send(query, cancellationToken);

return ResponseFactory.FromResult(result, modelFactory.ConvertFrom);
}

public static async Task<IResult> GetApiScopes(IMediator mediator,
IModelFactory modelFactory,
CancellationToken cancellationToken)
{
var query = new SecurityServiceQueries.GetApiScopesQuery();

Result<List<Duende.IdentityServer.Models.ApiScope>> result = await mediator.Send(query, cancellationToken);

return ResponseFactory.FromResult(result, modelFactory.ConvertFrom);
}
}
}
Loading
Loading