fixed a token encoding issue #70

Merged
tonitch merged 3 commits from Max/backend/loginFix into master 2024-03-09 09:57:54 +01:00
Owner
No description provided.
Maxime added the
Done
Waiting for review
labels 2024-03-08 18:55:22 +01:00
Maxime added 1 commit 2024-03-08 18:55:23 +01:00
fixed a token encoding issue
All checks were successful
Build and test backend / Build-backend (pull_request) Successful in 2m33s
Build and test backend / Test-backend (pull_request) Successful in 1m59s
Build and test FrontEnd / Build-frontend (pull_request) Successful in 23s
fba30cff9e
tonitch approved these changes 2024-03-08 20:54:21 +01:00
Dismissed
tonitch left a comment
Owner

image

![image](/attachments/63e75cbb-6751-4c6e-9c17-a25e7b2fdac4)
150 KiB
@ -25,3 +23,1 @@
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.set("Set-Cookie",String.format("session_token=%s",sessionToken));
return ResponseEntity.ok().headers(responseHeaders).build();
return ResponseEntity.ok().header("Set-Cookie", String.format("session_token=%s", sessionToken)).build();
Owner

resembler pour mieux brainfuck ^^

resembler pour mieux brainfuck ^^
Author
Owner

osef

osef
Maxime marked this conversation as resolved
@ -22,9 +24,12 @@ public class TokenService {
public String generateNewToken(){
byte[] bytes = new byte[64];
new SecureRandom().nextBytes(bytes);
Owner

je suis un peu curieux de la différence avec Random()

je suis un peu curieux de la différence avec Random()
Author
Owner

random est moins random et plus prévisible donc plus de conflits (on m'a juste conseillé SecureRandom donc sur un site donc voila
)

random est moins random et plus prévisible donc plus de conflits (on m'a juste conseillé SecureRandom donc sur un site donc voila )
Maxime marked this conversation as resolved
Maxime added 1 commit 2024-03-08 20:55:26 +01:00
put the params in the body and fixed token issue
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 2m0s
Build and test FrontEnd / Build-frontend (pull_request) Successful in 20s
82a3b152f2
Maxime dismissed tonitch’s review 2024-03-08 20:55:26 +01:00
Reason:

New commits pushed, approval review dismissed automatically according to repository settings

Author
Owner

Exemple de Json pour le body du POST /login
{
"identifier": "1",
"password": "admin",
"expirationDate": "2024-03-08T22:34:33"
}

Exemple de Json pour le body du POST /login { "identifier": "1", "password": "admin", "expirationDate": "2024-03-08T22:34:33" }
tonitch reviewed 2024-03-08 21:00:56 +01:00
@ -28,0 +30,4 @@
new SecureRandom().nextBytes(temp);
bytes[i] = temp[0];
}
}
Owner

tu viens pas de dupliquer le new SecureRandom().nextBytes(bytes); ?

tu viens pas de dupliquer le `new SecureRandom().nextBytes(bytes);` ?
Owner
https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/security/SecureRandom.html
tonitch marked this conversation as resolved
tonitch reviewed 2024-03-08 21:14:51 +01:00
@ -26,2 +27,2 @@
System.out.println(token);
return token;
for (int i = 0; i < bytes.length; i++) {
while (bytes[i] == 0){
Owner

tu peux aussi ( x / 4 (division entière) + 64) et ainsi tu est dans une range affichable (lazy)

tu peux aussi ( x / 4 (division entière) + 64) et ainsi tu est dans une range affichable (lazy)
Author
Owner

smart je vais try

smart je vais try
Maxime added 1 commit 2024-03-09 00:47:18 +01:00
token is now an writable char thanks to the modulos !
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 1m57s
Build and test FrontEnd / Build-frontend (pull_request) Successful in 22s
521c98fdc2
Maxime reviewed 2024-03-09 09:38:32 +01:00
@ -26,2 +27,2 @@
System.out.println(token);
return token;
for (int i = 0; i < bytes.length; i++) {
bytes[i] = (byte) (((bytes[i]+256)%256 %95+ 32));
Author
Owner

Permet d'avoir des caractères affichable

Permet d'avoir des caractères affichable
Wal approved these changes 2024-03-09 09:38:42 +01:00
tonitch approved these changes 2024-03-09 09:39:38 +01:00
tonitch left a comment
Owner

image

![image](/attachments/8159faf3-28bf-4184-8578-ef7606f9c8c5)
299 KiB
LeoMoulin approved these changes 2024-03-09 09:57:25 +01:00
tonitch merged commit b88d820c12 into master 2024-03-09 09:57:54 +01:00
tonitch deleted branch Max/backend/loginFix 2024-03-09 09:57:54 +01:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: PGL/Clyde#70
No description provided.