fix: applied formatter (on all import as well :)
This commit is contained in:
@ -1,6 +1,9 @@
|
||||
package enseirb.myinpulse.config;
|
||||
|
||||
import static org.springframework.security.authorization.AuthorityAuthorizationManager.hasRole;
|
||||
|
||||
import enseirb.myinpulse.security.KeycloakJwtRolesConverter;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@ -13,9 +16,6 @@ import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.springframework.security.authorization.AuthorityAuthorizationManager.hasRole;
|
||||
|
||||
|
||||
@Configuration
|
||||
public class WebSecurityCustomConfiguration {
|
||||
// CORS configuration
|
||||
@ -24,8 +24,8 @@ public class WebSecurityCustomConfiguration {
|
||||
private String frontendUrl;
|
||||
|
||||
/**
|
||||
* Configure the CORS (Cross Origin Ressource Sharing -- a security feature) configuration.
|
||||
* The only allowed website is the frontend, defined in the .env file.
|
||||
* Configure the CORS (Cross Origin Ressource Sharing -- a security feature) configuration. The
|
||||
* only allowed website is the frontend, defined in the .env file.
|
||||
*
|
||||
* @return the CORS configuration used by the backend
|
||||
*/
|
||||
@ -35,10 +35,7 @@ public class WebSecurityCustomConfiguration {
|
||||
configuration.setAllowedOrigins(List.of(frontendUrl));
|
||||
configuration.setAllowedMethods(Arrays.asList("GET", "OPTIONS"));
|
||||
configuration.setAllowedHeaders(
|
||||
Arrays.asList(
|
||||
"authorization",
|
||||
"content-type",
|
||||
"x-auth-token"));
|
||||
Arrays.asList("authorization", "content-type", "x-auth-token"));
|
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||
source.registerCorsConfiguration("/**", configuration);
|
||||
|
||||
@ -47,8 +44,10 @@ public class WebSecurityCustomConfiguration {
|
||||
|
||||
/**
|
||||
* Configure the authorisation required for each path.
|
||||
* admin endpoints are under /admin/* and entrepreneur are under /entrepreneur/*
|
||||
* If endpoints dont require authentication, they are under /unauth/
|
||||
*
|
||||
* <p>admin endpoints are under /admin/* and entrepreneur are under /entrepreneur/*
|
||||
*
|
||||
* <p>If endpoints dont require authentication, they are under /unauth/
|
||||
*
|
||||
* @param http automatically filled in by spring.
|
||||
* @return a securityfilterchain, automatically used by spring.
|
||||
|
@ -2,12 +2,14 @@ package enseirb.myinpulse.postgres_db.controller;
|
||||
|
||||
import enseirb.myinpulse.postgres_db.model.Administrateurs;
|
||||
import enseirb.myinpulse.postgres_db.repository.AdministrateursRepository;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
public class AdministrateursController {
|
||||
|
||||
|
@ -2,12 +2,14 @@ package enseirb.myinpulse.postgres_db.controller;
|
||||
|
||||
import enseirb.myinpulse.postgres_db.model.ComptesRendus;
|
||||
import enseirb.myinpulse.postgres_db.repository.ComptesRendusRepository;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
public class ComptesRendusController {
|
||||
|
||||
|
@ -2,12 +2,14 @@ package enseirb.myinpulse.postgres_db.controller;
|
||||
|
||||
import enseirb.myinpulse.postgres_db.model.Entrepreneurs;
|
||||
import enseirb.myinpulse.postgres_db.repository.EntrepreneursRepository;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
public class EntrepreneursController {
|
||||
|
||||
|
@ -2,13 +2,15 @@ package enseirb.myinpulse.postgres_db.controller;
|
||||
|
||||
import enseirb.myinpulse.postgres_db.model.Projets;
|
||||
import enseirb.myinpulse.postgres_db.repository.ProjetsRepository;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
public class ProjetsController {
|
||||
|
||||
|
@ -2,14 +2,16 @@ package enseirb.myinpulse.postgres_db.controller;
|
||||
|
||||
import enseirb.myinpulse.postgres_db.model.RendezVous;
|
||||
import enseirb.myinpulse.postgres_db.repository.RendezVousRepository;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
public class RendezVousController {
|
||||
|
||||
|
@ -2,13 +2,15 @@ package enseirb.myinpulse.postgres_db.controller;
|
||||
|
||||
import enseirb.myinpulse.postgres_db.model.Sections;
|
||||
import enseirb.myinpulse.postgres_db.repository.SectionsRepository;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
public class SectionsController {
|
||||
|
||||
|
@ -2,12 +2,14 @@ package enseirb.myinpulse.postgres_db.controller;
|
||||
|
||||
import enseirb.myinpulse.postgres_db.model.Utilisateurs;
|
||||
import enseirb.myinpulse.postgres_db.repository.UtilisateursRepository;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
public class UtilisateursController {
|
||||
|
||||
|
@ -3,6 +3,7 @@ package enseirb.myinpulse.postgres_db.model;
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.persistence.PrimaryKeyJoinColumn;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -2,6 +2,7 @@ package enseirb.myinpulse.postgres_db.model;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -12,31 +12,6 @@ import java.util.List;
|
||||
@Table(name = "rendez_vous")
|
||||
public class RendezVous {
|
||||
|
||||
@Id
|
||||
@NotNull
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id_rdv;
|
||||
|
||||
private LocalDate date_rdv;
|
||||
|
||||
private LocalDateTime heure_rdv;
|
||||
|
||||
private LocalDateTime duree_rdv;
|
||||
|
||||
@Column(length = 255)
|
||||
private String lieu_rdv;
|
||||
|
||||
private String sujet_rdv;
|
||||
|
||||
@OneToMany(mappedBy = "rendezVousEntrepreneurs", fetch = FetchType.LAZY, orphanRemoval = true)
|
||||
private List<Entrepreneurs> ListEntrepreneurs = new ArrayList<>();
|
||||
|
||||
@OneToMany(mappedBy = "rendezVousAdministrateurs", fetch = FetchType.LAZY, orphanRemoval = true)
|
||||
private List<Administrateurs> ListAdministrateurs = new ArrayList<>();
|
||||
|
||||
@OneToMany(mappedBy = "rendezVousComptesRendus", fetch = FetchType.LAZY, orphanRemoval = true)
|
||||
private List<ComptesRendus> ListComptesRendus = new ArrayList<>();
|
||||
|
||||
@ManyToMany(
|
||||
fetch = FetchType.LAZY,
|
||||
cascade = {CascadeType.ALL})
|
||||
@ -45,6 +20,22 @@ public class RendezVous {
|
||||
joinColumns = @JoinColumn(name = "id_rdv"),
|
||||
inverseJoinColumns = @JoinColumn(name = "id_section"))
|
||||
List<Sections> ListSections = new ArrayList<>();
|
||||
@Id
|
||||
@NotNull
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id_rdv;
|
||||
private LocalDate date_rdv;
|
||||
private LocalDateTime heure_rdv;
|
||||
private LocalDateTime duree_rdv;
|
||||
@Column(length = 255)
|
||||
private String lieu_rdv;
|
||||
private String sujet_rdv;
|
||||
@OneToMany(mappedBy = "rendezVousEntrepreneurs", fetch = FetchType.LAZY, orphanRemoval = true)
|
||||
private List<Entrepreneurs> ListEntrepreneurs = new ArrayList<>();
|
||||
@OneToMany(mappedBy = "rendezVousAdministrateurs", fetch = FetchType.LAZY, orphanRemoval = true)
|
||||
private List<Administrateurs> ListAdministrateurs = new ArrayList<>();
|
||||
@OneToMany(mappedBy = "rendezVousComptesRendus", fetch = FetchType.LAZY, orphanRemoval = true)
|
||||
private List<ComptesRendus> ListComptesRendus = new ArrayList<>();
|
||||
|
||||
public RendezVous() {}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package enseirb.myinpulse.postgres_db.repository;
|
||||
|
||||
import enseirb.myinpulse.postgres_db.model.Administrateurs;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package enseirb.myinpulse.postgres_db.repository;
|
||||
|
||||
import enseirb.myinpulse.postgres_db.model.ComptesRendus;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package enseirb.myinpulse.postgres_db.repository;
|
||||
|
||||
import enseirb.myinpulse.postgres_db.model.Entrepreneurs;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package enseirb.myinpulse.postgres_db.repository;
|
||||
|
||||
import enseirb.myinpulse.postgres_db.model.Projets;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package enseirb.myinpulse.postgres_db.repository;
|
||||
|
||||
import enseirb.myinpulse.postgres_db.model.RendezVous;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package enseirb.myinpulse.postgres_db.repository;
|
||||
|
||||
import enseirb.myinpulse.postgres_db.model.Sections;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package enseirb.myinpulse.postgres_db.repository;
|
||||
|
||||
import enseirb.myinpulse.postgres_db.model.Utilisateurs;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
package enseirb.myinpulse.security;
|
||||
|
||||
import static java.util.stream.Collectors.toSet;
|
||||
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.security.authentication.AbstractAuthenticationToken;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
@ -14,8 +16,6 @@ import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.stream.Collectors.toSet;
|
||||
|
||||
public class KeycloakJwtRolesConverter implements Converter<Jwt, AbstractAuthenticationToken> {
|
||||
/** Prefix used for realm level roles. */
|
||||
public static final String PREFIX_REALM_ROLE = "ROLE_REALM_";
|
||||
|
Reference in New Issue
Block a user