-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
253 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -369,4 +369,4 @@ FodyWeavers.xsd | |
|
||
# User | ||
.idea/ | ||
Tests/ | ||
/Tests/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.Filters; | ||
|
||
namespace SteamOrganizer.Server.Filters; | ||
|
||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)] | ||
public sealed class ApiKeyAttribute : Attribute, IActionFilter | ||
{ | ||
public void OnActionExecuting(ActionExecutingContext context) | ||
{ | ||
if (!context.HttpContext.Request.Query.TryGetValue(Defines.ApiKeyParamName, out var extractedApiKey)) | ||
{ | ||
context.Result = new BadRequestObjectResult(new { Message = "Api key was not provided" }); | ||
return; | ||
} | ||
|
||
var key = extractedApiKey.ToString(); | ||
if(key.Length != Defines.SteamApiKeyLength) | ||
{ | ||
context.Result = new BadRequestObjectResult(new { Message = "Invalid api key" }); | ||
} | ||
} | ||
|
||
public void OnActionExecuted(ActionExecutedContext context) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
SteamOrganizer.Server/Lib/JsonConverters/ToNumberConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace SteamOrganizer.Server.Lib.JsonConverters; | ||
|
||
public sealed class ToNumberConverter : JsonConverter<ulong> | ||
{ | ||
public override ulong Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | ||
{ | ||
if (reader.TokenType == JsonTokenType.String && ulong.TryParse(reader.GetString(), out var value)) | ||
{ | ||
return value; | ||
} | ||
throw new JsonException("Unable to convert string to ulong."); | ||
} | ||
|
||
public override void Write(Utf8JsonWriter writer, ulong value, JsonSerializerOptions options) | ||
{ | ||
writer.WriteNumberValue(value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 14 additions & 1 deletion
15
SteamOrganizer.Server/Services/SteamParser/Responses/PlayerBans.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.