MaPSCDAService is a microservice designed for handling requests related to user authentication as well as helping the client to initiate the FIND journey.
- Token Generation: Generates secure tokens for user sessions using PKCE (Proof Key for Code Exchange).
- Redirect Management: Provides the client with an endpoint with which to initiate the FIND journey.
- Claims Gathering: Provides the client with an endpoint to complete the authentication process.
- Validation: Ensures that incoming requests contain valid data before processing.
- Logging: Implements robust logging for tracking requests and errors.
The service follows a modular architecture with clear separation of concerns. Key components include:
- Controllers: Handle incoming HTTP requests and orchestrate responses.
- wwwroot: Contains a dynamic Open Api spec for this service's Api. This document reflects any changes to the controller's endpoints
- Models: Define the structure of data being transmitted and received.
- Utilities: Contain reusable functions and helper classes.
The MaPSCDAService is built using the following technologies:
- .NET 8.0: The core framework for building the microservice, supporting modern C# features and performance improvements.
- C#: The primary programming language used for service development.
- MhpdCommon: A shared library for models and utilities used across the MHPD ecosystem.
- Azure.Extensions.AspNetCore.Configuration.Secrets: For accessing secrets in Azure during application configuration.
- Azure.Identity: For authenticating with Azure services.
- Microsoft.Azure.AppConfiguration.AspNetCore: For managing application settings in Azure App Configuration.
- Newtonsoft.Json: For JSON serialization and deserialization.
- System.Configuration.ConfigurationManager: For configuration management in .NET applications.
- System.IdentityModel.Tokens.Jwt: For handling JWT tokens for authentication.
- XUnit: For unit testing the service.
- Moq: For mocking dependencies in unit tests.
The MaPSCDAService has the following key service dependencies:
- Token Integration Service: Used to obtain an authentication token.
- PEI Integration Service: Calls this service in order to trigger the claims gathering process.
These dependencies are crucial for the functionality and operation of the MaPSCDAService, allowing it to interact with other services in the MHPD ecosystem effectively.
To set up the MaPSCDAService locally, follow these steps:
- Clone the Repository:
git clone https://github.com/moneyadviceservice/mhpd-backend-cda-service.git
cd app- Restore Dependencies:
dotnet restore- Configure Application Settings:
{
"Logging": {
"LogLevel": {
"Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware": "Information",
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"ApplicationInsights": {
"ConnectionString": "$(AppInsightsConnString)"
},
"AllowedHosts": "*",
"TokenIntegrationServiceUrl": "$(TokenIntegrationServiceEndpoint)",
"PeiIntegrationServiceUrl": "$(PeiIntegrationServiceEndpoint)",
"OpenApiServerUrl": "$(OpenApiServerUrl)",
"JwtSettings": {
"PrivateKey": "$(maps_cda_service_private_key)",
"ExpiryInSeconds": "$(maps_cda_service_expiry)",
"Audience": "$(maps_cda_service_audience)",
"Kid": "$(maps_cda_service_kid)",
"Roles": "owner"
},
"UriSettings": {
"redirectTargetUrl": "$(maps_cda_service_redirect_target_url)"
},
"CosmosBusinessConfiguration": {
"DatabaseId": "$(DatabaseId)",
"UserSessionDataContainer": "$(UserSessionDataContainer)"
},
"ConnectionStrings": {
"CosmosDBConnectionString": "$(CosmosDBConnectionString)"
}
}
# Make sure to replace the placeholder values with actual settings for your environment.- Build the Service:
dotnet build- Run the Service:
dotnet runUnit tests are implemented to ensure the reliability of the service. To run the tests, navigate to the tests directory and execute:
cd tests
dotnet testLogging is configured to capture detailed information about requests and errors. Logs are written using the ILogger interface, providing insights into the operation of the service
Submit a pull request or open an issue for any enhancements or bug fixes.
- Added CSRF support .
- Applied industry standard security response headers.
- Updated logging output consistency to improve traceability.
- Service to communicate with internal services
- Service network rules changed to allow traffic from other apps on the vnet
- Upgraded to .Net 10
- Updated correlation logging for .Net 10.
- Moved session storage from Cosmos DB to Redis.