-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate Tauri to v2.0 and implement socket security
- Loading branch information
Showing
25 changed files
with
6,418 additions
and
1,134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
backend/src/main/java/fr/zelytra/session/socket/security/SocketSecurityEndpoints.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package fr.zelytra.session.socket.security; | ||
|
||
import io.quarkus.security.Authenticated; | ||
import jakarta.transaction.Transactional; | ||
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; | ||
|
||
@Authenticated | ||
@Path("/socket") | ||
public class SocketSecurityEndpoints { | ||
|
||
@GET | ||
@Path("/register") | ||
@Transactional | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public Response registerClient() { | ||
SocketSecurityEntity socketSecurity = new SocketSecurityEntity(); | ||
return Response.ok(socketSecurity.getKey()).build(); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
backend/src/main/java/fr/zelytra/session/socket/security/SocketSecurityEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package fr.zelytra.session.socket.security; | ||
|
||
import java.util.Date; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
|
||
public class SocketSecurityEntity { | ||
|
||
|
||
public static Map<String, SocketSecurityEntity> websocketUser = new HashMap<>(); | ||
|
||
private String key; | ||
|
||
private long validity; | ||
|
||
public SocketSecurityEntity() { | ||
this.validity = new Date().toInstant().plusSeconds(30).toEpochMilli(); | ||
this.key = UUID.randomUUID().toString(); | ||
websocketUser.put(this.key, this); | ||
} | ||
|
||
public boolean isValid() { | ||
return this.validity >= new Date().toInstant().toEpochMilli(); | ||
} | ||
|
||
public String getKey() { | ||
return key; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
VITE_BACKEND_HOST="https://pre-prod.betterfleet.fr/api" | ||
VITE_SOCKET_HOST=wss://pre-prod.betterfleet.fr/api/sessions | ||
VITE_KEYCLOAK_HOST=https://pre-prod.betterfleet.fr/auth | ||
VITE_VERSION=$npm_package_version |
Oops, something went wrong.