deleted all allowanonymous
This commit is contained in:
@@ -9,8 +9,7 @@ public class CreateAuthorEndpoint(LibraryDbContext database) : Endpoint<CreateAu
|
||||
public override void Configure()
|
||||
{
|
||||
Post("/authors");
|
||||
AllowAnonymous();
|
||||
// Roles("admin");
|
||||
Roles("admin");
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CreateAuthorDto req, CancellationToken ct)
|
||||
|
||||
@@ -15,8 +15,7 @@ public class DeleteAuthorEndpoint(LibraryDbContext database) : Endpoint<DeleteAu
|
||||
public override void Configure()
|
||||
{
|
||||
Delete("/authors/{@Id}", x => new {x.Id});
|
||||
// Roles("admin");
|
||||
AllowAnonymous();
|
||||
Roles("admin");
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(DeleteAuthorRequest req, CancellationToken ct)
|
||||
|
||||
@@ -10,8 +10,7 @@ public class GetAllAuthorsEndpoint(LibraryDbContext database) : EndpointWithoutR
|
||||
public override void Configure()
|
||||
{
|
||||
Get("/authors");
|
||||
// Roles("viewer", "admin", "librarian");
|
||||
AllowAnonymous();
|
||||
Roles("viewer", "admin", "librarian");
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CancellationToken ct)
|
||||
|
||||
@@ -16,8 +16,7 @@ public class GetAuthorEndpoint(LibraryDbContext database) : Endpoint<GetAuthorRe
|
||||
public override void Configure()
|
||||
{
|
||||
Get("/authors/{@Id}", x => new {x.Id});
|
||||
// Roles("viewer", "admin", "librarian");
|
||||
AllowAnonymous();
|
||||
Roles("viewer", "admin", "librarian");
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(GetAuthorRequest req, CancellationToken ct)
|
||||
|
||||
@@ -11,8 +11,7 @@ public class UpdateAuthorEndpoint(LibraryDbContext database) : Endpoint<UpdateAu
|
||||
public override void Configure()
|
||||
{
|
||||
Put("/authors/{@Id}", x => new {x.Id});
|
||||
// Roles("admin");
|
||||
AllowAnonymous();
|
||||
Roles("admin");
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(UpdateAuthorDto req, CancellationToken ct)
|
||||
|
||||
@@ -10,8 +10,7 @@ public class CreateBookEndpoint(LibraryDbContext database) : Endpoint<CreateBook
|
||||
public override void Configure()
|
||||
{
|
||||
Post("/books");
|
||||
AllowAnonymous();
|
||||
// Roles("admin");
|
||||
Roles("admin");
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CreateBookDto req, CancellationToken ct)
|
||||
|
||||
@@ -16,8 +16,7 @@ public class DeleteBookEndpoint(LibraryDbContext database) : Endpoint<DeleteBook
|
||||
public override void Configure()
|
||||
{
|
||||
Delete("/books/{@Id}", x => new {x.Id});
|
||||
// Roles("admin");
|
||||
AllowAnonymous();
|
||||
Roles("admin");
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(DeleteBookRequest req, CancellationToken ct)
|
||||
|
||||
@@ -9,8 +9,7 @@ public class GetAllBooksEndpoint(LibraryDbContext database) : EndpointWithoutReq
|
||||
public override void Configure()
|
||||
{
|
||||
Get("/books");
|
||||
// Roles("viewer", "admin", "librarian");
|
||||
AllowAnonymous();
|
||||
Roles("viewer", "admin", "librarian");
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CancellationToken ct)
|
||||
|
||||
@@ -14,8 +14,7 @@ public class GetBookEndpoint(LibraryDbContext database) : Endpoint<GetBookReques
|
||||
public override void Configure()
|
||||
{
|
||||
Get("/books/{@Id}", x => new {x.Id});
|
||||
// Roles("viewer", "admin", "librarian");
|
||||
AllowAnonymous();
|
||||
Roles("viewer", "admin", "librarian");
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(GetBookRequest req, CancellationToken ct)
|
||||
|
||||
@@ -10,8 +10,7 @@ public class UpdateBookEndpoint(LibraryDbContext database) : Endpoint<UpdateBook
|
||||
public override void Configure()
|
||||
{
|
||||
Put("/books/{@Id}", x => new {x.Id});
|
||||
// Roles("admin");
|
||||
AllowAnonymous();
|
||||
Roles("admin");
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(UpdateBookDto req, CancellationToken ct)
|
||||
|
||||
@@ -10,8 +10,7 @@ public class CreateLoanEndpoint(LibraryDbContext database) : Endpoint<CreateLoan
|
||||
public override void Configure()
|
||||
{
|
||||
Post("/loans");
|
||||
// Roles("admin", "librarian");
|
||||
AllowAnonymous();
|
||||
Roles("admin", "librarian");
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CreateLoanDto req, CancellationToken ct)
|
||||
|
||||
@@ -16,8 +16,7 @@ public class DeleteLoanEndpoint(LibraryDbContext database) : Endpoint<DeleteLoan
|
||||
public override void Configure()
|
||||
{
|
||||
Delete("/loans/{@Id}", x => new {x.Id});
|
||||
// Roles("admin");
|
||||
AllowAnonymous();
|
||||
Roles("admin");
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(DeleteLoanRequest req, CancellationToken ct)
|
||||
|
||||
@@ -9,8 +9,7 @@ public class GetAllLoanEndpoint(LibraryDbContext database) : EndpointWithoutRequ
|
||||
public override void Configure()
|
||||
{
|
||||
Get("/loans");
|
||||
// Roles("viewer", "admin", "librarian");
|
||||
AllowAnonymous();
|
||||
Roles("viewer", "admin", "librarian");
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CancellationToken ct)
|
||||
|
||||
@@ -14,8 +14,7 @@ public class GetLoanEndpoint(LibraryDbContext database) : Endpoint<GetLoanReques
|
||||
public override void Configure()
|
||||
{
|
||||
Get("/loans/{@Id}", x => new {x.Id});
|
||||
// Roles("viewer", "admin", "librarian");
|
||||
AllowAnonymous();
|
||||
Roles("viewer", "admin", "librarian");
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(GetLoanRequest req, CancellationToken ct)
|
||||
|
||||
@@ -10,8 +10,7 @@ public class PatchLoanEndpoint(LibraryDbContext database) : Endpoint<PatchLoanDt
|
||||
public override void Configure()
|
||||
{
|
||||
Patch("/loans/{@Id}/EffectiveReturningDate", x => new {x.Id});
|
||||
// Roles("admin", "librarian");
|
||||
AllowAnonymous();
|
||||
Roles("admin", "librarian");
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(PatchLoanDto req, CancellationToken ct)
|
||||
|
||||
@@ -10,8 +10,7 @@ public class UpdateLoanEndpoint(LibraryDbContext database) : Endpoint<UpdateLoan
|
||||
public override void Configure()
|
||||
{
|
||||
Put("/loans/{@Id}", x => new {x.Id});
|
||||
// Roles("admin", "librarian");
|
||||
AllowAnonymous();
|
||||
Roles("admin", "librarian");
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(UpdateLoanDto req, CancellationToken ct)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using ApiEfCoreLibrary.DTO.Login.Response;
|
||||
using ApiEfCoreLibrary.DTO.Refresh.Request;
|
||||
using ApiEfCoreLibrary.DTO.Refresh.Response;
|
||||
using FastEndpoints;
|
||||
|
||||
@@ -9,8 +9,7 @@ public class CreateUserEndpoint(LibraryDbContext database) : Endpoint<CreateUser
|
||||
public override void Configure()
|
||||
{
|
||||
Post("/users");
|
||||
// Roles("admin");
|
||||
AllowAnonymous();
|
||||
Roles("admin");
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CreateUserDto req, CancellationToken ct)
|
||||
|
||||
@@ -15,8 +15,7 @@ public class DeleteUserEndpoint(LibraryDbContext database) : Endpoint<DeleteUser
|
||||
public override void Configure()
|
||||
{
|
||||
Delete("/users/{@Id}", x => new {x.Id});
|
||||
// Roles("admin");
|
||||
AllowAnonymous();
|
||||
Roles("admin");
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(DeleteUserRequest req, CancellationToken ct)
|
||||
|
||||
@@ -10,8 +10,7 @@ public class GetAllUsersEndpoint(LibraryDbContext database) : EndpointWithoutReq
|
||||
public override void Configure()
|
||||
{
|
||||
Get("/users");
|
||||
// Roles("viewer", "admin", "librarian");
|
||||
AllowAnonymous();
|
||||
Roles("viewer", "admin", "librarian");
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CancellationToken ct)
|
||||
|
||||
@@ -16,8 +16,7 @@ public class GetUserEndpoint(LibraryDbContext database) : Endpoint<GetUserReques
|
||||
public override void Configure()
|
||||
{
|
||||
Get("/users/{@Id}", x => new {x.Id});
|
||||
// Roles("viewer", "admin", "librarian");
|
||||
AllowAnonymous();
|
||||
Roles("viewer", "admin", "librarian");
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(GetUserRequest req, CancellationToken ct)
|
||||
|
||||
@@ -10,8 +10,7 @@ public class UpdateUserEndpoint(LibraryDbContext database) : Endpoint<UpdateUser
|
||||
public override void Configure()
|
||||
{
|
||||
Put("/users/{@Id}", x => new {x.Id});
|
||||
// Roles("admin");
|
||||
AllowAnonymous();
|
||||
Roles("admin");
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(UpdateUserDto req, CancellationToken ct)
|
||||
|
||||
@@ -7,8 +7,8 @@ WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// On ajoute ici FastEndpoints, un framework REPR et Swagger aux services disponibles dans le projet
|
||||
builder.Services
|
||||
//.AddAuthenticationJwtBearer(s => s.SigningKey = "ThisIsASuperSecretJwtKeyThatIsAtLeast32CharsLong")
|
||||
//.AddAuthorization()
|
||||
.AddAuthenticationJwtBearer(s => s.SigningKey = "ThisIsASuperSecretJwtKeyThatIsAtLeast32CharsLong")
|
||||
.AddAuthorization()
|
||||
.AddFastEndpoints()
|
||||
.AddCors(options =>
|
||||
{
|
||||
@@ -29,8 +29,8 @@ builder.Services.AddDbContext<LibraryDbContext>();
|
||||
|
||||
// On construit l'application en lui donnant vie
|
||||
WebApplication app = builder.Build();
|
||||
app//.UseAuthentication()
|
||||
//.UseAuthorization()
|
||||
app.UseAuthentication()
|
||||
.UseAuthorization()
|
||||
.UseFastEndpoints(options =>
|
||||
{
|
||||
options.Endpoints.ShortNames = true;
|
||||
@@ -38,7 +38,7 @@ app//.UseAuthentication()
|
||||
})
|
||||
.UseSwaggerGen();
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
// app.UseHttpsRedirection();
|
||||
|
||||
app.UseCors();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user