Configure Maven repository for unionflow-server-api dependency
This commit is contained in:
@@ -0,0 +1,136 @@
|
||||
package de.lions.unionflow.server.auth;
|
||||
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
/**
|
||||
* Resource temporaire pour gérer les callbacks d'authentification OAuth2/OIDC depuis l'application
|
||||
* mobile.
|
||||
*/
|
||||
@Path("/auth")
|
||||
public class AuthCallbackResource {
|
||||
|
||||
private static final Logger log = Logger.getLogger(AuthCallbackResource.class);
|
||||
|
||||
/**
|
||||
* Endpoint de callback pour l'authentification OAuth2/OIDC. Redirige vers l'application mobile
|
||||
* avec les paramètres reçus.
|
||||
*/
|
||||
@GET
|
||||
@Path("/callback")
|
||||
public Response handleCallback(
|
||||
@QueryParam("code") String code,
|
||||
@QueryParam("state") String state,
|
||||
@QueryParam("session_state") String sessionState,
|
||||
@QueryParam("error") String error,
|
||||
@QueryParam("error_description") String errorDescription) {
|
||||
|
||||
try {
|
||||
// Log des paramètres reçus pour debug
|
||||
log.infof("=== CALLBACK DEBUG === Code: %s, State: %s, Session State: %s, Error: %s, Error Description: %s",
|
||||
code, state, sessionState, error, errorDescription);
|
||||
|
||||
// URL de redirection simple vers l'application mobile
|
||||
String redirectUrl = "dev.lions.unionflow-mobile://callback";
|
||||
|
||||
// Si nous avons un code d'autorisation, c'est un succès
|
||||
if (code != null && !code.isEmpty()) {
|
||||
redirectUrl += "?code=" + code;
|
||||
if (state != null && !state.isEmpty()) {
|
||||
redirectUrl += "&state=" + state;
|
||||
}
|
||||
} else if (error != null) {
|
||||
redirectUrl += "?error=" + error;
|
||||
if (errorDescription != null) {
|
||||
redirectUrl += "&error_description=" + errorDescription;
|
||||
}
|
||||
}
|
||||
|
||||
// Page HTML simple qui redirige automatiquement vers l'app mobile
|
||||
String html =
|
||||
"""
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Redirection vers UnionFlow</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
text-align: center;
|
||||
padding: 50px;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: white;
|
||||
}
|
||||
.container {
|
||||
max-width: 400px;
|
||||
margin: 0 auto;
|
||||
background: rgba(255,255,255,0.1);
|
||||
padding: 30px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
.spinner {
|
||||
border: 4px solid rgba(255,255,255,0.3);
|
||||
border-top: 4px solid white;
|
||||
border-radius: 50%;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
animation: spin 1s linear infinite;
|
||||
margin: 20px auto;
|
||||
}
|
||||
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
|
||||
a { color: #ffeb3b; text-decoration: none; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h2>🔐 Authentification réussie</h2>
|
||||
<div class="spinner"></div>
|
||||
<p>Redirection vers l'application UnionFlow...</p>
|
||||
<p><small>Si la redirection ne fonctionne pas automatiquement,
|
||||
<a href="%s">cliquez ici</a></small></p>
|
||||
</div>
|
||||
<script>
|
||||
// Tentative de redirection automatique
|
||||
setTimeout(function() {
|
||||
window.location.href = '%s';
|
||||
}, 2000);
|
||||
|
||||
// Fallback: ouvrir l'app mobile si possible
|
||||
setTimeout(function() {
|
||||
try {
|
||||
window.open('%s', '_self');
|
||||
} catch(e) {
|
||||
console.log('Redirection manuelle nécessaire');
|
||||
}
|
||||
}, 3000);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
.formatted(redirectUrl, redirectUrl, redirectUrl);
|
||||
|
||||
return Response.ok(html).type("text/html").build();
|
||||
|
||||
} catch (Exception e) {
|
||||
// En cas d'erreur, retourner une page d'erreur simple
|
||||
String errorHtml =
|
||||
"""
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head><title>Erreur d'authentification</title></head>
|
||||
<body style="font-family: Arial; text-align: center; padding: 50px;">
|
||||
<h2>❌ Erreur d'authentification</h2>
|
||||
<p>Une erreur s'est produite lors de la redirection.</p>
|
||||
<p>Veuillez fermer cette page et réessayer.</p>
|
||||
</body>
|
||||
</html>
|
||||
""";
|
||||
return Response.status(500).entity(errorHtml).type("text/html").build();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user