mirror of
https://github.com/yawaflua/yaflay.ru.git
synced 2025-12-11 16:16:26 +02:00
make backend for my site
This commit is contained in:
@@ -3,12 +3,12 @@ using System.Text.Encodings.Web;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.Options;
|
||||
using yaflay.ru.Database.Tables;
|
||||
using yaflay.ru.Models;
|
||||
using yaflay.ru.Models.Tables;
|
||||
using yawaflua.ru.Database.Tables;
|
||||
using yawaflua.ru.Models;
|
||||
using yawaflua.ru.Models.Tables;
|
||||
|
||||
|
||||
namespace yaflay.ru.Auth;
|
||||
namespace yawaflua.ru.Auth;
|
||||
|
||||
public class ApiKeyAuthantication : AuthenticationHandler<AuthenticationSchemeOptions>
|
||||
{
|
||||
@@ -29,7 +29,9 @@ public class ApiKeyAuthantication : AuthenticationHandler<AuthenticationSchemeOp
|
||||
|
||||
protected override async Task<AuthenticateResult> HandleAuthenticateAsync()
|
||||
{
|
||||
if (!Request.Headers.TryGetValue("Authorization", out var apiKeyHeaderValues))
|
||||
if (!Request.Host.Value.StartsWith("api"))
|
||||
return AuthenticateResult.NoResult();
|
||||
if (!Request.Headers.TryGetValue("Authorization", out var apiKeyHeaderValues) && Request.Host.Value.StartsWith("api"))
|
||||
return AuthenticateResult.Fail("API Key was not provided.");
|
||||
|
||||
string? providedApiKey = apiKeyHeaderValues.FirstOrDefault()?.Replace("Bearer ", "");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace yaflay.ru.Auth
|
||||
namespace yawaflua.ru.Auth
|
||||
{
|
||||
|
||||
public enum ApiKeyTypes
|
||||
|
||||
Reference in New Issue
Block a user