mirror of
https://github.com/Caraxi/mare.server.git
synced 2025-12-14 03:24:15 +01:00
remove anonymous
This commit is contained in:
parent
9e0ac74de7
commit
4477e186a3
2 changed files with 2 additions and 19 deletions
|
|
@ -7,8 +7,6 @@ using System.Text.Encodings.Web;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MareSynchronosServer.Data;
|
using MareSynchronosServer.Data;
|
||||||
using Microsoft.AspNetCore.Authentication;
|
using Microsoft.AspNetCore.Authentication;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
|
@ -22,13 +20,8 @@ namespace MareSynchronosServer.Authentication
|
||||||
|
|
||||||
protected override async Task<AuthenticateResult> HandleAuthenticateAsync()
|
protected override async Task<AuthenticateResult> HandleAuthenticateAsync()
|
||||||
{
|
{
|
||||||
var endpoint = Context.GetEndpoint();
|
if (!Request.Headers.ContainsKey("Authorization"))
|
||||||
var endpointMetaData = endpoint?.Metadata?.GetMetadata<IAllowAnonymous>();
|
|
||||||
|
|
||||||
if (!Request.Headers.ContainsKey("Authorization") && endpointMetaData == null)
|
|
||||||
return AuthenticateResult.Fail("Failed Authorization");
|
return AuthenticateResult.Fail("Failed Authorization");
|
||||||
else if (!Request.Headers.ContainsKey("Authorization") && endpointMetaData != null)
|
|
||||||
return AuthenticateResult.NoResult();
|
|
||||||
|
|
||||||
var authHeader = Request.Headers["Authorization"].ToString();
|
var authHeader = Request.Headers["Authorization"].ToString();
|
||||||
|
|
||||||
|
|
@ -44,10 +37,6 @@ namespace MareSynchronosServer.Authentication
|
||||||
{
|
{
|
||||||
return AuthenticateResult.Fail("Failed Authorization");
|
return AuthenticateResult.Fail("Failed Authorization");
|
||||||
}
|
}
|
||||||
else if (endpointMetaData != null && uid == null)
|
|
||||||
{
|
|
||||||
return AuthenticateResult.NoResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
var claims = new List<Claim> {
|
var claims = new List<Claim> {
|
||||||
new Claim(ClaimTypes.NameIdentifier, uid)
|
new Claim(ClaimTypes.NameIdentifier, uid)
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ using MareSynchronosServer.Data;
|
||||||
using MareSynchronosServer.Metrics;
|
using MareSynchronosServer.Metrics;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Http.Features;
|
|
||||||
using Microsoft.AspNetCore.SignalR;
|
using Microsoft.AspNetCore.SignalR;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|
@ -34,6 +33,7 @@ namespace MareSynchronosServer.Hubs
|
||||||
}
|
}
|
||||||
|
|
||||||
[HubMethodName(Api.InvokeHeartbeat)]
|
[HubMethodName(Api.InvokeHeartbeat)]
|
||||||
|
[Authorize(AuthenticationSchemes = SecretKeyAuthenticationHandler.AuthScheme)]
|
||||||
public async Task<ConnectionDto> Heartbeat(string characterIdentification)
|
public async Task<ConnectionDto> Heartbeat(string characterIdentification)
|
||||||
{
|
{
|
||||||
MareMetrics.InitializedConnections.Inc();
|
MareMetrics.InitializedConnections.Inc();
|
||||||
|
|
@ -79,12 +79,6 @@ namespace MareSynchronosServer.Hubs
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
[HubMethodName(Api.InvokeGetSystemInfo)]
|
|
||||||
public async Task<SystemInfoDto> GetSystemInfo()
|
|
||||||
{
|
|
||||||
return _systemInfoService.SystemInfoDto;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Task OnConnectedAsync()
|
public override Task OnConnectedAsync()
|
||||||
{
|
{
|
||||||
var feature = Context.Features.Get<IHttpContextAccessor>();
|
var feature = Context.Features.Get<IHttpContextAccessor>();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue