chat: add initial GuildsController
This commit is contained in:
parent
7b4cbd4fb7
commit
727f2f6ba2
23 changed files with 248 additions and 38 deletions
|
@ -7,14 +7,14 @@ using Microsoft.EntityFrameworkCore;
|
|||
|
||||
namespace Foxchat.Chat.Middleware;
|
||||
|
||||
public class AuthenticationMiddleware(ILogger logger, ChatContext db, RequestSigningService requestSigningService)
|
||||
public class ServerAuthenticationMiddleware(ILogger logger, ChatContext db, RequestSigningService requestSigningService)
|
||||
: IMiddleware
|
||||
{
|
||||
public async Task InvokeAsync(HttpContext ctx, RequestDelegate next)
|
||||
{
|
||||
var endpoint = ctx.GetEndpoint();
|
||||
// Endpoints require server authentication by default, unless they have the [Unauthenticated] attribute.
|
||||
var metadata = endpoint?.Metadata.GetMetadata<UnauthenticatedAttribute>();
|
||||
var metadata = endpoint?.Metadata.GetMetadata<ServerUnauthenticatedAttribute>();
|
||||
if (metadata != null)
|
||||
{
|
||||
await next(ctx);
|
||||
|
@ -41,8 +41,11 @@ public class AuthenticationMiddleware(ILogger logger, ChatContext db, RequestSig
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attribute to be put on controllers or methods to indicate that it does <i>not</i> require a signed request.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
|
||||
public class UnauthenticatedAttribute : Attribute;
|
||||
public class ServerUnauthenticatedAttribute : Attribute;
|
||||
|
||||
public static class HttpContextExtensions
|
||||
{
|
Loading…
Add table
Add a link
Reference in a new issue