fix: RegisterPublicRoute pour pages HTML modules + masquer installés dans store
- RouteEntry.Public bool : routes sans auth (pages HTML navigables par Swup) - RegisterPublicRoute() ajouté à Registry interface + coreRegistry - main.go : switch public/auth/admin pour les routes modules - modules.html : masque les modules déjà installés dans le store Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
3c8a1a6b58
commit
365165c13b
4 changed files with 16 additions and 5 deletions
|
|
@ -201,9 +201,12 @@ func main() {
|
||||||
// Routes enregistrées par les modules actifs
|
// Routes enregistrées par les modules actifs
|
||||||
for _, route := range loader.Registry().GetRoutes() {
|
for _, route := range loader.Registry().GetRoutes() {
|
||||||
routeCopy := route // Capturer la variable pour la closure
|
routeCopy := route // Capturer la variable pour la closure
|
||||||
if routeCopy.RequireAdmin {
|
switch {
|
||||||
|
case routeCopy.Public:
|
||||||
|
r.MethodFunc(routeCopy.Method, routeCopy.Path, routeCopy.Handler)
|
||||||
|
case routeCopy.RequireAdmin:
|
||||||
r.With(api.RequireAuth(jwtManager), api.RequireAdmin).MethodFunc(routeCopy.Method, routeCopy.Path, routeCopy.Handler)
|
r.With(api.RequireAuth(jwtManager), api.RequireAdmin).MethodFunc(routeCopy.Method, routeCopy.Path, routeCopy.Handler)
|
||||||
} else {
|
default:
|
||||||
r.With(api.RequireAuth(jwtManager)).MethodFunc(routeCopy.Method, routeCopy.Path, routeCopy.Handler)
|
r.With(api.RequireAuth(jwtManager)).MethodFunc(routeCopy.Method, routeCopy.Path, routeCopy.Handler)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,7 @@ type RouteEntry struct {
|
||||||
Path string
|
Path string
|
||||||
Handler http.HandlerFunc
|
Handler http.HandlerFunc
|
||||||
RequireAdmin bool
|
RequireAdmin bool
|
||||||
|
Public bool // true = pas d'authentification requise (ex: pages HTML)
|
||||||
}
|
}
|
||||||
|
|
||||||
type migrationEntry struct {
|
type migrationEntry struct {
|
||||||
|
|
@ -118,7 +119,12 @@ func newCoreRegistry(sqlDB *sql.DB, pool *sshpool.Pool, enc *crypto.Encryptor) *
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *coreRegistry) RegisterRoute(method, path string, handler http.HandlerFunc, requireAdmin bool) {
|
func (r *coreRegistry) RegisterRoute(method, path string, handler http.HandlerFunc, requireAdmin bool) {
|
||||||
r.routes = append(r.routes, RouteEntry{method, path, handler, requireAdmin})
|
r.routes = append(r.routes, RouteEntry{Method: method, Path: path, Handler: handler, RequireAdmin: requireAdmin})
|
||||||
|
}
|
||||||
|
|
||||||
|
// RegisterPublicRoute enregistre une route sans authentification (ex: page HTML d'un module).
|
||||||
|
func (r *coreRegistry) RegisterPublicRoute(method, path string, handler http.HandlerFunc) {
|
||||||
|
r.routes = append(r.routes, RouteEntry{Method: method, Path: path, Handler: handler, Public: true})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *coreRegistry) RegisterWSChannel(channel string, handler WSHandler) {
|
func (r *coreRegistry) RegisterWSChannel(channel string, handler WSHandler) {
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,10 @@ type NavItemDef struct {
|
||||||
// Registry est l'interface exposée aux modules pour s'enregistrer dans le CORE.
|
// Registry est l'interface exposée aux modules pour s'enregistrer dans le CORE.
|
||||||
// Seuls des types de la bibliothèque standard sont exposés — aucun type internal.
|
// Seuls des types de la bibliothèque standard sont exposés — aucun type internal.
|
||||||
type Registry interface {
|
type Registry interface {
|
||||||
// Enregistrement de routes HTTP
|
// Enregistrement de routes HTTP (avec authentification)
|
||||||
RegisterRoute(method, path string, handler http.HandlerFunc, requireAdmin bool)
|
RegisterRoute(method, path string, handler http.HandlerFunc, requireAdmin bool)
|
||||||
|
// Enregistrement d'une route publique (sans auth — pour les pages HTML)
|
||||||
|
RegisterPublicRoute(method, path string, handler http.HandlerFunc)
|
||||||
|
|
||||||
// Enregistrement du canal WebSocket
|
// Enregistrement du canal WebSocket
|
||||||
RegisterWSChannel(channel string, handler WSHandler)
|
RegisterWSChannel(channel string, handler WSHandler)
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@
|
||||||
|
|
||||||
<div class="modules-grid" x-show="!storeLoading">
|
<div class="modules-grid" x-show="!storeLoading">
|
||||||
<template x-for="mod in storeModules" :key="mod.id">
|
<template x-for="mod in storeModules" :key="mod.id">
|
||||||
<div class="neu-card module-card">
|
<div class="neu-card module-card" x-show="!mod.installed">
|
||||||
<div class="module-header">
|
<div class="module-header">
|
||||||
<div class="module-icon"><i class="lnid-puzzle"></i></div>
|
<div class="module-icon"><i class="lnid-puzzle"></i></div>
|
||||||
<div class="module-info">
|
<div class="module-info">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue