Compare commits

..

23 Commits

Author SHA1 Message Date
36ce5a553b Profil, merge Master and corrections
All checks were successful
Build and test backend / Build-backend (pull_request) Successful in 2m0s
Build and test backend / Test-backend (pull_request) Successful in 1m59s
Build and test FrontEnd / Build-frontend (pull_request) Successful in 25s
2024-03-16 15:21:10 +01:00
53e478b05c Merge pull request 'added ApplicationController and Application enum' (#119) from Max/Backend/AppsController into master
All checks were successful
Build and test backend / Build-backend (push) Successful in 2m12s
Build and test backend / Test-backend (push) Successful in 1m19s
deploy to production / deploy-backend (push) Successful in 2m18s
Build and test FrontEnd / Build-frontend (push) Successful in 25s
deploy to production / deploy-frontend (push) Successful in 26s
Reviewed-on: #119
Reviewed-by: Debucquoy Anthony <d.tonitch@gmail.com>
Reviewed-by: Wal <karpinskiwal@gmail.com>
2024-03-16 14:51:56 +01:00
182be8ac7b
Merge branch 'master' into Max/Backend/AppsController
All checks were successful
Build and test backend / Build-backend (pull_request) Successful in 1m58s
Build and test backend / Test-backend (pull_request) Successful in 1m59s
Build and test FrontEnd / Build-frontend (pull_request) Successful in 25s
2024-03-16 14:48:03 +01:00
beba199f60 Merge pull request 'Login indication' (#127) from tonitch/front/loginIndication into master
All checks were successful
Build and test backend / Test-backend (push) Successful in 1m17s
deploy to production / deploy-frontend (push) Successful in 24s
Build and test FrontEnd / Build-frontend (push) Successful in 24s
deploy to production / deploy-backend (push) Successful in 2m21s
Build and test backend / Build-backend (push) Successful in 2m12s
Reviewed-on: #127
Reviewed-by: Wal <karpinskiwal@gmail.com>
Reviewed-by: Maxime <231026@umons.ac.be>
2024-03-16 14:45:02 +01:00
767a83d1d6 Merge pull request 'Max/Backend/BackendClean' (#121) from Max/Backend/BackendClean into master
Some checks failed
deploy to production / deploy-frontend (push) Successful in 26s
deploy to production / deploy-backend (push) Has been cancelled
Build and test FrontEnd / Build-frontend (push) Waiting to run
Build and test backend / Build-backend (push) Successful in 2m12s
Build and test backend / Test-backend (push) Successful in 1m20s
Reviewed-on: #121
Reviewed-by: Wal <karpinskiwal@gmail.com>
Reviewed-by: Debucquoy Anthony <d.tonitch@gmail.com>
2024-03-16 14:38:19 +01:00
da3f8c47f9
Fix merge because i'm bad
All checks were successful
Build and test backend / Build-backend (pull_request) Successful in 2m3s
Build and test backend / Test-backend (pull_request) Successful in 2m0s
Build and test FrontEnd / Build-frontend (pull_request) Successful in 22s
2024-03-16 14:34:11 +01:00
1546fc6d47
Merge branch 'master' into Max/Backend/BackendClean
Some checks failed
Build and test backend / Build-backend (pull_request) Failing after 1m34s
Build and test backend / Test-backend (pull_request) Failing after 1m31s
Build and test FrontEnd / Build-frontend (pull_request) Successful in 23s
2024-03-16 14:13:47 +01:00
04f64f505e
Indicated that you are logged by coloring the icon in orange and disconnect if clicked on it
All checks were successful
Build and test backend / Build-backend (pull_request) Successful in 2m2s
Build and test backend / Test-backend (pull_request) Successful in 1m57s
Build and test FrontEnd / Build-frontend (pull_request) Successful in 24s
2024-03-16 13:56:29 +01:00
c955fbf5f8 Merge pull request 'fix tokens characters' (#126) from tonitch/back/fixTokens into master
All checks were successful
Build and test backend / Test-backend (push) Successful in 1m19s
deploy to production / deploy-frontend (push) Successful in 25s
deploy to production / deploy-backend (push) Successful in 2m20s
Build and test FrontEnd / Build-frontend (push) Successful in 24s
Build and test backend / Build-backend (push) Successful in 2m11s
Reviewed-on: #126
Reviewed-by: Wal <karpinskiwal@gmail.com>
Reviewed-by: Maxime <231026@umons.ac.be>
2024-03-16 12:42:54 +01:00
847936b799
fix tokens characters
All checks were successful
Build and test backend / Build-backend (pull_request) Successful in 2m6s
Build and test backend / Test-backend (pull_request) Successful in 2m0s
Build and test FrontEnd / Build-frontend (pull_request) Successful in 23s
2024-03-16 12:36:17 +01:00
0b27d2e8d8
Merge branch 'master' into tonitch/front/pagesAPI
All checks were successful
Build and test backend / Build-backend (pull_request) Successful in 2m2s
Build and test backend / Test-backend (pull_request) Successful in 1m59s
Build and test FrontEnd / Build-frontend (pull_request) Successful in 23s
2024-03-16 12:35:15 +01:00
45fbef52ed
fix tokens characters
All checks were successful
Build and test backend / Build-backend (pull_request) Successful in 1m59s
Build and test backend / Test-backend (pull_request) Successful in 2m1s
Build and test FrontEnd / Build-frontend (pull_request) Successful in 24s
2024-03-16 12:29:51 +01:00
abff9aef3a Merge branch 'master' into Max/Backend/AppsController
All checks were successful
Build and test backend / Build-backend (pull_request) Successful in 1m59s
Build and test backend / Test-backend (pull_request) Successful in 1m56s
Build and test FrontEnd / Build-frontend (pull_request) Successful in 24s
2024-03-16 11:58:03 +01:00
8f2fb04112 I pressed tab by accident
All checks were successful
Build and test backend / Build-backend (pull_request) Successful in 2m2s
Build and test backend / Test-backend (pull_request) Successful in 2m0s
Build and test FrontEnd / Build-frontend (pull_request) Successful in 24s
2024-03-16 09:03:03 +01:00
c6198b7220 cleaned Services + added private final to all repos
Some checks failed
Build and test backend / Build-backend (pull_request) Failing after 1m35s
Build and test backend / Test-backend (pull_request) Failing after 1m30s
Build and test FrontEnd / Build-frontend (pull_request) Successful in 26s
2024-03-16 09:02:08 +01:00
13fd048cd2 added a inscriptionService mock user 2024-03-16 09:01:36 +01:00
b7b2eafb93 removed the GET /Apps/{id} frontend just iterates on the /apps list
All checks were successful
Build and test backend / Build-backend (pull_request) Successful in 2m3s
Build and test backend / Test-backend (pull_request) Successful in 2m2s
Build and test FrontEnd / Build-frontend (pull_request) Successful in 24s
2024-03-16 00:44:11 +01:00
0860567e1b fixed the GetAuthorizedApps method
All checks were successful
Build and test backend / Build-backend (pull_request) Successful in 2m4s
Build and test backend / Test-backend (pull_request) Successful in 1m59s
Build and test FrontEnd / Build-frontend (pull_request) Successful in 24s
2024-03-16 00:42:46 +01:00
25009ba149 Enum in CamelCase
All checks were successful
Build and test backend / Build-backend (pull_request) Successful in 1m58s
Build and test backend / Test-backend (pull_request) Successful in 1m56s
Build and test FrontEnd / Build-frontend (pull_request) Successful in 24s
2024-03-16 00:34:20 +01:00
208c6c63e8 moved the isSecretaryOrAdmin method 2024-03-16 00:31:03 +01:00
77a170be6d
Merge branch 'master' into tonitch/front/pagesAPI
All checks were successful
Build and test backend / Build-backend (pull_request) Successful in 2m1s
Build and test backend / Test-backend (pull_request) Successful in 1m58s
Build and test FrontEnd / Build-frontend (pull_request) Successful in 23s
2024-03-15 22:37:37 +01:00
1f14890d43 added ApplicationController and Application enum
All checks were successful
Build and test backend / Build-backend (pull_request) Successful in 2m3s
Build and test backend / Test-backend (pull_request) Successful in 2m0s
Build and test FrontEnd / Build-frontend (pull_request) Successful in 24s
2024-03-15 18:54:53 +01:00
160cfb0bbf Page api stub
All checks were successful
Build and test backend / Build-backend (pull_request) Successful in 2m1s
Build and test backend / Test-backend (pull_request) Successful in 1m55s
Build and test FrontEnd / Build-frontend (pull_request) Successful in 24s
2024-03-09 18:41:20 +01:00
18 changed files with 140 additions and 72 deletions

View File

@ -0,0 +1,62 @@
package ovh.herisson.Clyde.EndPoints;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;
import ovh.herisson.Clyde.Services.AuthenticatorService;
import ovh.herisson.Clyde.Tables.Applications;
import ovh.herisson.Clyde.Tables.Role;
import java.util.ArrayList;
@RestController
public class ApplicationsController {
AuthenticatorService authServ;
public ApplicationsController(AuthenticatorService authServ){
this.authServ = authServ;
}
/** return a list of authorized applications.
* depends on the token
*/
@GetMapping("/apps")
public ResponseEntity<Iterable<Applications>> getAuthorizedApps(@RequestHeader("Authorization") String token){
return new ResponseEntity<>(getAuthorizedApplications(token), HttpStatus.OK);
}
@GetMapping("/apps/{identifier}")
public ResponseEntity<Boolean> getAppAuthorization(@PathVariable Applications identifier, @RequestHeader("Authorization") String token){
if (getAuthorizedApplications(token).contains(identifier)){
return new ResponseEntity<>(true, HttpStatus.OK);
}
return new ResponseEntity<>(false, HttpStatus.OK);
}
public ArrayList<Applications> getAuthorizedApplications(String token){
Role posterRole = authServ.getUserFromToken(token).getRole();
ArrayList<Applications> authorizedApps = new ArrayList<>();
authorizedApps.add(Applications.Login);
authorizedApps.add(Applications.Profile);
if (posterRole == Role.Teacher || posterRole == Role.Student || posterRole == Role.Admin){
authorizedApps.add(Applications.Msg);
authorizedApps.add(Applications.Forum);
authorizedApps.add(Applications.Rdv);
}
if (posterRole == Role.Teacher || posterRole == Role.Secretary || posterRole == Role.Admin) authorizedApps.add(Applications.ManageCourses);
if (posterRole == Role.InscriptionService || posterRole == Role.Admin) authorizedApps.add(Applications.Inscription);
return authorizedApps;
}
}

View File

@ -43,28 +43,4 @@ public class CurriculumController {
public ResponseEntity<Iterable<CurriculumCourse>> findAll(){
return new ResponseEntity<>(curriculumCourseServ.findAll(),HttpStatus.OK);
}
/**@PostMapping("/curriculum")
public ResponseEntity<String> postCurriculum(@RequestHeader("Authorization") String token,@RequestBody Curriculum curriculum){
if (!isSecretaryOrAdmin(token)){
return new UnauthorizedResponse<>("you're not allowed to post a Curriculum");
}
CurriculumServ.save(Curriculum);
return new ResponseEntity<>("created !",HttpStatus.CREATED);
}**/
private boolean isSecretaryOrAdmin(String authorization){
if (authorization ==null)
return false;
User poster = authServ.getUserFromToken(authorization);
if (poster == null) return false;
return poster.getRole() == Role.Secretary && poster.getRole() == Role.Admin;
}
}

View File

@ -32,7 +32,7 @@ public class InscriptionController {
@GetMapping("/requests/register")
public ResponseEntity<Iterable<Map<String,Object>>> getAllRequests(@RequestHeader("Authorization") String token){
if (!isSecretaryOrAdmin(token)){return new UnauthorizedResponse<>(null);}
if (authServ.isNotSecretaryOrAdmin(token)){return new UnauthorizedResponse<>(null);}
Iterable<InscriptionRequest> inscriptionRequests = inscriptionServ.getAll();
ArrayList<Map<String,Object>> toReturn = new ArrayList<>();
@ -64,7 +64,7 @@ public class InscriptionController {
@RequestHeader("Authorize") String token,
@RequestBody RequestState requestState)
{
if (!isSecretaryOrAdmin(token)) return new UnauthorizedResponse<>(null);
if (authServ.isNotSecretaryOrAdmin(token)) return new UnauthorizedResponse<>(null);
inscriptionServ.modifyState(id, requestState);
return null;
}
@ -83,15 +83,4 @@ public class InscriptionController {
toReturn.put("state", inscriptionRequest.getState());
return toReturn;
}
private boolean isSecretaryOrAdmin(String authorization){
if (authorization ==null)
return false;
User poster = authServ.getUserFromToken(authorization);
if (poster == null) return false;
return poster.getRole() == Role.Secretary && poster.getRole() == Role.Admin;
}
}
}

View File

@ -49,4 +49,4 @@ public class LoginController {
authServ.register(inscriptionRequest);
return new ResponseEntity<>("Is OK", HttpStatus.OK);
}
}
}

View File

@ -51,6 +51,7 @@ public class MockController {
User joe = new User("Mama","Joe","student@student.com","roundabout","DaWarudo",new Date(0), null,Role.Student,passwordEncoder.encode("student"));
User meh = new User("Inspiration","lackOf","secretary@secretary.com","a Box","the street",new Date(0), null,Role.Secretary,passwordEncoder.encode("secretary"));
User joke = new User("CthemBalls","Lemme","teacher@teacher.com","lab","faculty",new Date(0), null,Role.Teacher,passwordEncoder.encode("teacher"));
User lena = new User("Louille","Lena","inscriptionService@InscriptionService.com","no","yes",new Date(0), null,Role.InscriptionService,passwordEncoder.encode("inscriptionService"));
mockUsers = new ArrayList<>(Arrays.asList(herobrine,joe,meh,joke));
userRepo.saveAll(mockUsers);

View File

@ -38,7 +38,7 @@ public class UserController {
@PostMapping("/user")
public ResponseEntity<String> postUser(@RequestBody User user,@RequestHeader("Authorization") String authorization){
if (!isSecretaryOrAdmin(authorization))
if (authServ.isNotSecretaryOrAdmin(authorization))
return new UnauthorizedResponse<>(null);
userService.save(user);
@ -48,7 +48,7 @@ public class UserController {
@GetMapping("/users")
public ResponseEntity<Iterable<HashMap<String,Object>>> getAllUsers(@RequestHeader("Authorization") String authorization){
if (!isSecretaryOrAdmin(authorization))
if (authServ.isNotSecretaryOrAdmin(authorization))
return new UnauthorizedResponse<>(null);
Iterable<User> users = userService.getAll();
@ -78,7 +78,6 @@ public class UserController {
*/
private HashMap<String,Object> userWithoutPassword(User user){
HashMap<String,Object> toReturn = new HashMap<>();
toReturn.put("regNo",user.getRegNo());
toReturn.put("firstName",user.getFirstName());
toReturn.put("lastName",user.getLastName());
@ -90,15 +89,5 @@ public class UserController {
return toReturn;
}
private boolean isSecretaryOrAdmin(String authorization){
if (authorization ==null)
return false;
User poster = authServ.getUserFromToken(authorization);
if (poster == null) return false;
return poster.getRole() == Role.Secretary && poster.getRole() == Role.Admin;
}
}

View File

@ -1,9 +1,8 @@
package ovh.herisson.Clyde.Services;
import org.springframework.stereotype.Service;
import ovh.herisson.Clyde.EndPoints.LoginController;
import ovh.herisson.Clyde.Repositories.InscriptionRepository;
import ovh.herisson.Clyde.Tables.InscriptionRequest;
import ovh.herisson.Clyde.Tables.Role;
import ovh.herisson.Clyde.Tables.Token;
import ovh.herisson.Clyde.Tables.User;
@ -39,4 +38,17 @@ public class AuthenticatorService {
public void register(InscriptionRequest inscriptionRequest) {
inscriptionService.save(inscriptionRequest);
}
public boolean isNotSecretaryOrAdmin(String authorization){
if (authorization ==null)
return true;
User poster = getUserFromToken(authorization);
if (poster == null) return true;
return poster.getRole() != Role.Secretary || poster.getRole() != Role.Admin;
}
}

View File

@ -31,4 +31,4 @@ public class InscriptionService {
inscriptionRequest.setState(requestState);
save(inscriptionRequest);
}
}
}

View File

@ -4,10 +4,8 @@ import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import ovh.herisson.Clyde.Repositories.FileRepository;
import ovh.herisson.Clyde.Tables.*;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

View File

@ -5,16 +5,15 @@ import org.springframework.stereotype.Service;
import ovh.herisson.Clyde.Repositories.TokenRepository;
import ovh.herisson.Clyde.Tables.Token;
import ovh.herisson.Clyde.Tables.User;
import java.io.UnsupportedEncodingException;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Base64;
import java.util.Calendar;
import java.util.Date;
@Service
public class TokenService {
TokenRepository tokenRepo;
private final TokenRepository tokenRepo;
public TokenService(TokenRepository tokenRepo){
this.tokenRepo = tokenRepo;
@ -30,13 +29,10 @@ public class TokenService {
new SecureRandom().nextBytes(bytes);
for (int i = 0; i < bytes.length; i++) {
bytes[i] = (byte) (((bytes[i]+256)%256 %95+ 32));
while ((char)bytes[i] == ';'){
bytes[i] = new SecureRandom().generateSeed(1)[0];
}
}
// will never end up in the catch because of the way that SecureRandom.nextBytes is implemented
try {
return new String(bytes,"ISO_8859_1");
return new String(Base64.getEncoder().encode(bytes),"ISO_8859_1");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}

View File

@ -0,0 +1,21 @@
package ovh.herisson.Clyde.Tables;
public enum Applications {
// without any token
Login,
// with any token
Profile,
// Students and higher authorization
Msg,
Forum,
Rdv,
// teachers and Secretary authorization
ManageCourses,
// InscriptionService authorization
Inscription
}

View File

@ -3,5 +3,5 @@ package ovh.herisson.Clyde.Tables;
public enum RequestState {
Accepted,
Refused,
Pending;
Pending
}

View File

@ -5,5 +5,5 @@ public enum Role {
Student,
Admin,
InscriptionService,
Secretary;
}
Secretary
}

View File

@ -2,6 +2,7 @@
import { toast } from 'vue3-toastify';
import { ref, computed } from 'vue'
import i18n, { setLang } from './i18n.js'
import { isLogged } from '@/rest/Users.js'
// Liste des apps
@ -23,6 +24,7 @@
const currentPath = ref(window.location.hash)
window.addEventListener('hashchange', () => {
Logged.value = isLogged();
currentPath.value = window.location.hash
})
@ -35,7 +37,9 @@
const settings=ref(i18n("app.settings"))
const login=ref(i18n("app.login"))
const active=ref(false)
const Logged = ref(isLogged());
</script>
<template>
@ -49,11 +53,11 @@
</a></li>
<li title=home>
<a class="icon" href="#home">
<div class=" fa-solid fa-house" style="margin-top: 7px; margin-bottom: 3px;"></div>
<div class=" fa-solid fa-house" style="margin-top: 7px; margin-bottom: 3px;"></div>
</a></li>
<li style="float: right;" title=login>
<a class="icon" href="#/login">
<div class="fa-solid fa-user" style="margin-top: 7px; margin-bottom: 3px;"></div>
<div class="fa-solid fa-user" :style="Logged ? 'color: orange' : 'haha'" style="margin-top: 7px; margin-bottom: 3px; "></div>
</a></li>
<li style="float: right;" title=notifications>
<a class="icon" href="#Notifications">

View File

@ -1,7 +1,7 @@
<script setup>
import { ref } from 'vue'
import i18n from '@/i18n.js'
import { login , register } from '@/rest/Users.js'
import { login , register , disconnect} from '@/rest/Users.js'
import { getAllCurriculums } from '@/rest/curriculum.js'
import { uploadProfilePicture } from '@/rest/uploads.js'
import {toast} from 'vue3-toastify'
@ -42,6 +42,8 @@
return toast('Password and Confirm Password are different',{type: "error",});
}
}
disconnect()
</script>

View File

@ -125,7 +125,7 @@ function getPP(){
<div>
</div>
<div v-if="(user.role=='teacher')">
<div v-if="(user.role==='Teacher')">
<div class="listTitle">
{{i18n("profile.course.list")}}
</div>

View File

@ -1,9 +1,18 @@
import { restGet, restPost } from './restConsumer.js'
import { getCookie, setCookie } from '@/utils.js'
export async function login(user, pass, exp){
return restPost("/login", {identifier: user, password: pass, expirationDate: exp});
}
export function isLogged(){
return getCookie("session_token") != ""
}
export function disconnect(){
setCookie("session_token", ";expires= Thu, 01 Jan 1970 00:00:01 GMT")
}
/**
* Register a user (tokenless)
*

View File

@ -0,0 +1,9 @@
import { restGet } from './restConsumer.js'
export async function appList(){
return restGet("/apps")
}
export async function checkPage(page){
return restGet("/apps/" + page)
}