test login
This commit is contained in:
45
src/main/java/fr/titionfire/ffsaf/rest/AuthEndpoints.java
Normal file
45
src/main/java/fr/titionfire/ffsaf/rest/AuthEndpoints.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package fr.titionfire.ffsaf.rest;
|
||||
|
||||
import io.quarkus.security.Authenticated;
|
||||
import io.quarkus.security.identity.SecurityIdentity;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import org.eclipse.microprofile.config.inject.ConfigProperty;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
@Path("/auth")
|
||||
public class AuthEndpoints {
|
||||
|
||||
@ConfigProperty(name = "login_redirect")
|
||||
String redirect;
|
||||
|
||||
@Inject
|
||||
SecurityIdentity securityIdentity;
|
||||
|
||||
@GET
|
||||
@Produces(MediaType.TEXT_PLAIN)
|
||||
public Boolean auth() {
|
||||
return !securityIdentity.isAnonymous();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/userinfo")
|
||||
@Produces(MediaType.TEXT_PLAIN)
|
||||
public String userinfo() {
|
||||
return securityIdentity.getPrincipal().getName();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/login")
|
||||
@Authenticated
|
||||
@Produces(MediaType.TEXT_PLAIN)
|
||||
public Response login() throws URISyntaxException {
|
||||
return Response.temporaryRedirect(new URI(redirect)).build();
|
||||
}
|
||||
}
|
||||
@@ -87,6 +87,7 @@ public class CombEndpoints {
|
||||
|
||||
@GET
|
||||
@Path("{id}/photo")
|
||||
@RolesAllowed("federation_admin")
|
||||
public Uni<Response> getPhoto(@PathParam("id") long id) throws URISyntaxException {
|
||||
Future<Pair<File, byte[]>> future = CompletableFuture.supplyAsync(() -> {
|
||||
FilenameFilter filter = (directory, filename) -> filename.startsWith(String.valueOf(id));
|
||||
|
||||
Reference in New Issue
Block a user