added alowanonymous
This commit is contained in:
@@ -20,5 +20,12 @@
|
|||||||
<jdbc-url>Server=romaric-thibault.fr,1433</jdbc-url>
|
<jdbc-url>Server=romaric-thibault.fr,1433</jdbc-url>
|
||||||
<working-dir>$ProjectFileDir$</working-dir>
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
</data-source>
|
</data-source>
|
||||||
|
<data-source source="LOCAL" name="@romaric-thibault.fr [3]" uuid="afc9949f-8c13-4d86-8c8c-8a2edf026c4e">
|
||||||
|
<driver-ref>sqlserver.jb</driver-ref>
|
||||||
|
<synchronize>true</synchronize>
|
||||||
|
<jdbc-driver>com.jetbrains.jdbc.sqlserver.SqlServerDriver</jdbc-driver>
|
||||||
|
<jdbc-url>Server=romaric-thibault.fr,1433</jdbc-url>
|
||||||
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
|
</data-source>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="db-tree-configuration">
|
<component name="db-tree-configuration">
|
||||||
<option name="data" value="---------------------------------------- 1:0:925a4572-e2f3-4d72-b3cf-a66d1965e808 2:0:694145f6-8002-442d-a3b3-5654b5fae22b " />
|
<option name="data" value="---------------------------------------- 1:0:925a4572-e2f3-4d72-b3cf-a66d1965e808 2:0:694145f6-8002-442d-a3b3-5654b5fae22b 3:0:afc9949f-8c13-4d86-8c8c-8a2edf026c4e " />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -9,7 +9,8 @@ public class CreateAuthorEndpoint(LibraryDbContext database) : Endpoint<CreateAu
|
|||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Post("/authors");
|
Post("/authors");
|
||||||
Roles("admin");
|
AllowAnonymous();
|
||||||
|
// Roles("admin");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(CreateAuthorDto req, CancellationToken ct)
|
public override async Task HandleAsync(CreateAuthorDto req, CancellationToken ct)
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ public class DeleteAuthorEndpoint(LibraryDbContext database) : Endpoint<DeleteAu
|
|||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Delete("/authors/{@Id}", x => new {x.Id});
|
Delete("/authors/{@Id}", x => new {x.Id});
|
||||||
Roles("admin");
|
// Roles("admin");
|
||||||
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(DeleteAuthorRequest req, CancellationToken ct)
|
public override async Task HandleAsync(DeleteAuthorRequest req, CancellationToken ct)
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ public class GetAllAuthorsEndpoint(LibraryDbContext database) : EndpointWithoutR
|
|||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get("/authors");
|
Get("/authors");
|
||||||
Roles("viewer", "admin", "librarian");
|
// Roles("viewer", "admin", "librarian");
|
||||||
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(CancellationToken ct)
|
public override async Task HandleAsync(CancellationToken ct)
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ public class GetAuthorEndpoint(LibraryDbContext database) : Endpoint<GetAuthorRe
|
|||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get("/authors/{@Id}", x => new {x.Id});
|
Get("/authors/{@Id}", x => new {x.Id});
|
||||||
Roles("viewer", "admin", "librarian");
|
// Roles("viewer", "admin", "librarian");
|
||||||
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(GetAuthorRequest req, CancellationToken ct)
|
public override async Task HandleAsync(GetAuthorRequest req, CancellationToken ct)
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ public class UpdateAuthorEndpoint(LibraryDbContext database) : Endpoint<UpdateAu
|
|||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Put("/authors/{@Id}", x => new {x.Id});
|
Put("/authors/{@Id}", x => new {x.Id});
|
||||||
Roles("admin");
|
// Roles("admin");
|
||||||
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(UpdateAuthorDto req, CancellationToken ct)
|
public override async Task HandleAsync(UpdateAuthorDto req, CancellationToken ct)
|
||||||
|
|||||||
@@ -9,8 +9,9 @@ public class CreateBookEndpoint(LibraryDbContext database) : Endpoint<CreateBook
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Post("/books");
|
Post("/books");
|
||||||
Roles("admin");
|
AllowAnonymous();
|
||||||
|
// Roles("admin");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(CreateBookDto req, CancellationToken ct)
|
public override async Task HandleAsync(CreateBookDto req, CancellationToken ct)
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ public class DeleteBookEndpoint(LibraryDbContext database) : Endpoint<DeleteBook
|
|||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Delete("/books/{@Id}", x => new {x.Id});
|
Delete("/books/{@Id}", x => new {x.Id});
|
||||||
Roles("admin");
|
// Roles("admin");
|
||||||
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(DeleteBookRequest req, CancellationToken ct)
|
public override async Task HandleAsync(DeleteBookRequest req, CancellationToken ct)
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ public class GetAllBooksEndpoint(LibraryDbContext database) : EndpointWithoutReq
|
|||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get("/books");
|
Get("/books");
|
||||||
Roles("viewer", "admin", "librarian"); }
|
// Roles("viewer", "admin", "librarian");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(CancellationToken ct)
|
public override async Task HandleAsync(CancellationToken ct)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,7 +14,9 @@ public class GetBookEndpoint(LibraryDbContext database) : Endpoint<GetBookReques
|
|||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get("/books/{@Id}", x => new {x.Id});
|
Get("/books/{@Id}", x => new {x.Id});
|
||||||
Roles("viewer", "admin", "librarian"); }
|
// Roles("viewer", "admin", "librarian");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(GetBookRequest req, CancellationToken ct)
|
public override async Task HandleAsync(GetBookRequest req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ public class UpdateBookEndpoint(LibraryDbContext database) : Endpoint<UpdateBook
|
|||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Put("/books/{@Id}", x => new {x.Id});
|
Put("/books/{@Id}", x => new {x.Id});
|
||||||
Roles("admin");
|
// Roles("admin");
|
||||||
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(UpdateBookDto req, CancellationToken ct)
|
public override async Task HandleAsync(UpdateBookDto req, CancellationToken ct)
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ public class CreateLoanEndpoint(LibraryDbContext database) : Endpoint<CreateLoan
|
|||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Post("/loans");
|
Post("/loans");
|
||||||
Roles("admin", "librarian");
|
// Roles("admin", "librarian");
|
||||||
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(CreateLoanDto req, CancellationToken ct)
|
public override async Task HandleAsync(CreateLoanDto req, CancellationToken ct)
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ public class DeleteLoanEndpoint(LibraryDbContext database) : Endpoint<DeleteLoan
|
|||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Delete("/loans/{@Id}", x => new {x.Id});
|
Delete("/loans/{@Id}", x => new {x.Id});
|
||||||
Roles("admin");
|
// Roles("admin");
|
||||||
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(DeleteLoanRequest req, CancellationToken ct)
|
public override async Task HandleAsync(DeleteLoanRequest req, CancellationToken ct)
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ public class GetAllLoanEndpoint(LibraryDbContext database) : EndpointWithoutRequ
|
|||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get("/loans");
|
Get("/loans");
|
||||||
Roles("viewer", "admin", "librarian"); }
|
// Roles("viewer", "admin", "librarian");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(CancellationToken ct)
|
public override async Task HandleAsync(CancellationToken ct)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,7 +14,9 @@ public class GetLoanEndpoint(LibraryDbContext database) : Endpoint<GetLoanReques
|
|||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get("/loans/{@Id}", x => new {x.Id});
|
Get("/loans/{@Id}", x => new {x.Id});
|
||||||
Roles("viewer", "admin", "librarian"); }
|
// Roles("viewer", "admin", "librarian");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(GetLoanRequest req, CancellationToken ct)
|
public override async Task HandleAsync(GetLoanRequest req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ public class PatchLoanEndpoint(LibraryDbContext database) : Endpoint<PatchLoanDt
|
|||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Patch("/loans/{@Id}/EffectiveReturningDate", x => new {x.Id});
|
Patch("/loans/{@Id}/EffectiveReturningDate", x => new {x.Id});
|
||||||
Roles("admin", "librarian");
|
// Roles("admin", "librarian");
|
||||||
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(PatchLoanDto req, CancellationToken ct)
|
public override async Task HandleAsync(PatchLoanDto req, CancellationToken ct)
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ public class UpdateLoanEndpoint(LibraryDbContext database) : Endpoint<UpdateLoan
|
|||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Put("/loans/{@Id}", x => new {x.Id});
|
Put("/loans/{@Id}", x => new {x.Id});
|
||||||
Roles("admin", "librarian");
|
// Roles("admin", "librarian");
|
||||||
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(UpdateLoanDto req, CancellationToken ct)
|
public override async Task HandleAsync(UpdateLoanDto req, CancellationToken ct)
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ public class DeleteLoginEndpoint(LibraryDbContext database) : Endpoint<DeleteLog
|
|||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Delete("/logins/{@Id}", x => new {x.Id});
|
Delete("/logins/{@Id}", x => new {x.Id});
|
||||||
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(DeleteLoginRequest req, CancellationToken ct)
|
public override async Task HandleAsync(DeleteLoginRequest req, CancellationToken ct)
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ public class GetAllLoginEndpoint(LibraryDbContext database) : EndpointWithoutReq
|
|||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get("/logins");
|
Get("/logins");
|
||||||
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(CancellationToken ct)
|
public override async Task HandleAsync(CancellationToken ct)
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ public class GetLoginEndpoint(LibraryDbContext database) : Endpoint<GetLoginRequ
|
|||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get("/logins/{@Id}", x => new {x.Id});
|
Get("/logins/{@Id}", x => new {x.Id});
|
||||||
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(GetLoginRequest req, CancellationToken ct)
|
public override async Task HandleAsync(GetLoginRequest req, CancellationToken ct)
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ public class UpdateLoginEndpoint(LibraryDbContext database) : Endpoint<UpdateLog
|
|||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Put("/logins/{@Id}", x => new {x.Id});
|
Put("/logins/{@Id}", x => new {x.Id});
|
||||||
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(UpdateLoginDto req, CancellationToken ct)
|
public override async Task HandleAsync(UpdateLoginDto req, CancellationToken ct)
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ public class CreateUserEndpoint(LibraryDbContext database) : Endpoint<CreateUser
|
|||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Post("/users");
|
Post("/users");
|
||||||
Roles("admin");
|
// Roles("admin");
|
||||||
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(CreateUserDto req, CancellationToken ct)
|
public override async Task HandleAsync(CreateUserDto req, CancellationToken ct)
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ public class DeleteUserEndpoint(LibraryDbContext database) : Endpoint<DeleteUser
|
|||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Delete("/users/{@Id}", x => new {x.Id});
|
Delete("/users/{@Id}", x => new {x.Id});
|
||||||
Roles("admin");
|
// Roles("admin");
|
||||||
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(DeleteUserRequest req, CancellationToken ct)
|
public override async Task HandleAsync(DeleteUserRequest req, CancellationToken ct)
|
||||||
|
|||||||
@@ -10,7 +10,9 @@ public class GetAllUsersEndpoint(LibraryDbContext database) : EndpointWithoutReq
|
|||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get("/users");
|
Get("/users");
|
||||||
Roles("viewer", "admin", "librarian"); }
|
// Roles("viewer", "admin", "librarian");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(CancellationToken ct)
|
public override async Task HandleAsync(CancellationToken ct)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,7 +16,9 @@ public class GetUserEndpoint(LibraryDbContext database) : Endpoint<GetUserReques
|
|||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get("/users/{@Id}", x => new {x.Id});
|
Get("/users/{@Id}", x => new {x.Id});
|
||||||
Roles("viewer", "admin", "librarian"); }
|
// Roles("viewer", "admin", "librarian");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(GetUserRequest req, CancellationToken ct)
|
public override async Task HandleAsync(GetUserRequest req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ public class UpdateUserEndpoint(LibraryDbContext database) : Endpoint<UpdateUser
|
|||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Put("/users/{@Id}", x => new {x.Id});
|
Put("/users/{@Id}", x => new {x.Id});
|
||||||
Roles("admin");
|
// Roles("admin");
|
||||||
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(UpdateUserDto req, CancellationToken ct)
|
public override async Task HandleAsync(UpdateUserDto req, CancellationToken ct)
|
||||||
|
|||||||
@@ -7,12 +7,22 @@ WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
|
|||||||
|
|
||||||
// On ajoute ici FastEndpoints, un framework REPR et Swagger aux services disponibles dans le projet
|
// On ajoute ici FastEndpoints, un framework REPR et Swagger aux services disponibles dans le projet
|
||||||
builder.Services
|
builder.Services
|
||||||
.AddAuthenticationJwtBearer(s => s.SigningKey = "ThisIsASuperSecretJwtKeyThatIsAtLeast32CharsLong")
|
//.AddAuthenticationJwtBearer(s => s.SigningKey = "ThisIsASuperSecretJwtKeyThatIsAtLeast32CharsLong")
|
||||||
.AddAuthorization()
|
//.AddAuthorization()
|
||||||
.AddFastEndpoints()
|
.AddFastEndpoints()
|
||||||
|
.AddCors(options =>
|
||||||
|
{
|
||||||
|
options.AddPolicy("AllowAll", policy =>
|
||||||
|
{
|
||||||
|
policy.AllowAnyOrigin()
|
||||||
|
.AllowAnyMethod()
|
||||||
|
.AllowAnyHeader();
|
||||||
|
});
|
||||||
|
})
|
||||||
.SwaggerDocument(options =>
|
.SwaggerDocument(options =>
|
||||||
{
|
{
|
||||||
options.ShortSchemaNames = true;
|
options.ShortSchemaNames = true;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// On ajoute ici la configuration de la base de données
|
// On ajoute ici la configuration de la base de données
|
||||||
@@ -20,8 +30,8 @@ builder.Services.AddDbContext<LibraryDbContext>();
|
|||||||
|
|
||||||
// On construit l'application en lui donnant vie
|
// On construit l'application en lui donnant vie
|
||||||
WebApplication app = builder.Build();
|
WebApplication app = builder.Build();
|
||||||
app.UseAuthentication()
|
app//.UseAuthentication()
|
||||||
.UseAuthorization()
|
//.UseAuthorization()
|
||||||
.UseFastEndpoints(options =>
|
.UseFastEndpoints(options =>
|
||||||
{
|
{
|
||||||
options.Endpoints.ShortNames = true;
|
options.Endpoints.ShortNames = true;
|
||||||
@@ -31,4 +41,6 @@ app.UseAuthentication()
|
|||||||
|
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
|
|
||||||
|
app.UseCors("AllowAll");
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
Reference in New Issue
Block a user