Skip to content

Commit

Permalink
Merge pull request #80 from mspnp/dev
Browse files Browse the repository at this point in the history
2024-02-20 - BryanSoltis - v4.0.1 Updates
  • Loading branch information
BryanSoltis authored Feb 20, 2024
2 parents 6dcbf9f + c5f2120 commit 5cc1e12
Show file tree
Hide file tree
Showing 93 changed files with 2,706 additions and 902 deletions.
12 changes: 11 additions & 1 deletion src/Attributes/ApiKeyAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,20 @@

namespace AzureNamingTool.Attributes
{
/// <summary>
/// Attribute to validate API key for authorization.
/// </summary>
[AttributeUsage(validOn: AttributeTargets.Class)]
public class ApiKeyAttribute : Attribute, IAsyncActionFilter
{
private const string APIKEYNAME = "APIKey";

/// <summary>
/// Validates the API key for authorization.
/// </summary>
/// <param name="context">The action executing context.</param>
/// <param name="next">The action execution delegate.</param>
/// <returns>A task representing the asynchronous operation.</returns>
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
{
if (!context.HttpContext.Request.Headers.TryGetValue(APIKEYNAME, out var extractedApiKey))
Expand Down Expand Up @@ -37,7 +47,7 @@ public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionE
}
}
else
{
{
// Request is a POST. Make sure the provided API Key is for full access
if (!GeneralHelper.DecryptString(config.APIKey!, config.SALTKey!).Equals(extractedApiKey))
{
Expand Down
12 changes: 9 additions & 3 deletions src/Attributes/CustomHeaderSwaggerAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,19 @@

namespace AzureNamingTool.Attributes
{
/// <summary>
/// Represents a custom header Swagger attribute.
/// </summary>
public class CustomHeaderSwaggerAttribute : IOperationFilter
{
/// <summary>
/// Applies the custom header Swagger attribute to the specified operation.
/// </summary>
/// <param name="operation">The OpenApiOperation object representing the operation.</param>
/// <param name="context">The OperationFilterContext object representing the context of the operation.</param>
public void Apply(OpenApiOperation operation, OperationFilterContext context)
{
if (operation.Parameters == null)
operation.Parameters = new List<OpenApiParameter>();
operation.Parameters ??= new List<OpenApiParameter>();

operation.Parameters.Add(new OpenApiParameter
{
Expand All @@ -21,6 +28,5 @@ public void Apply(OpenApiOperation operation, OperationFilterContext context)
}
});
}

}
}
12 changes: 11 additions & 1 deletion src/Attributes/RateFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@

namespace AzureNamingTool.Attributes
{
/// <summary>
/// Represents a rate filter attribute that sets the minimum data rate for request and response.
/// </summary>
public class RateFilter : Attribute, IResourceFilter
{
/// <summary>
/// Executes the filter before a resource is executed.
/// </summary>
/// <param name="context">The resource executing context.</param>
public void OnResourceExecuting(ResourceExecutingContext context)
{
try
{

var minRequestRateFeature = context.HttpContext.Features.Get<IHttpMinRequestBodyDataRateFeature>();
var minResponseRateFeature = context.HttpContext.Features.Get<IHttpMinResponseDataRateFeature>();
//Default Bytes/s = 240, Default TimeOut = 5s
Expand All @@ -34,6 +40,10 @@ public void OnResourceExecuting(ResourceExecutingContext context)
}
}

/// <summary>
/// Executes the filter after a resource is executed.
/// </summary>
/// <param name="context">The resource executed context.</param>
public void OnResourceExecuted(ResourceExecutedContext context)
{
}
Expand Down
2 changes: 1 addition & 1 deletion src/AzureNamingTool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>4.0.0</Version>
<Version>4.0.1</Version>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<UserSecretsId>eca63fb9-b7f9-454f-910b-5088ae877085</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
Expand Down
2 changes: 1 addition & 1 deletion src/Components/App.razor
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<base href="/" />
<base href="/">
<link href="css/bootstrap/bootstrap.min.css" rel="stylesheet">
<link href="css/site.css" rel="stylesheet" />
<link href="AzureNamingTool.styles.css" rel="stylesheet" />
Expand Down
4 changes: 2 additions & 2 deletions src/Components/General/AnchorNavigation.razor
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@code {
protected override void OnInitialized()
{
NavigationManager.LocationChanged += OnLocationChanged;
NavigationManager.LocationChanged += OnLocationChanged!;
}

protected override async Task OnAfterRenderAsync(bool firstRender)
Expand All @@ -14,7 +14,7 @@

public void Dispose()
{
NavigationManager.LocationChanged -= OnLocationChanged;
NavigationManager.LocationChanged -= OnLocationChanged!;
}

private async void OnLocationChanged(object sender, LocationChangedEventArgs e)
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Modals/EditModal.razor
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@

try
{
ServiceResponse serviceResponse;
ServiceResponse serviceResponse = new();
switch (type)
{
case "ResourceComponent":
Expand Down
Loading

0 comments on commit 5cc1e12

Please sign in to comment.