feat(profile): implement yggdrasil profile signing
This commit is contained in:
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"gitea.mrixs.me/minecraft-platform/backend/internal/api"
|
||||
"gitea.mrixs.me/minecraft-platform/backend/internal/core"
|
||||
@@ -23,10 +24,23 @@ func main() {
|
||||
// Сервисы
|
||||
userService := &core.UserService{Repo: userRepo}
|
||||
authService := &core.AuthService{UserRepo: userRepo} // Новый сервис
|
||||
|
||||
// Инициализируем сервис профилей, читая путь к ключу и домен из переменных окружения
|
||||
keyPath := os.Getenv("RSA_PRIVATE_KEY_PATH")
|
||||
if keyPath == "" {
|
||||
log.Fatal("RSA_PRIVATE_KEY_PATH environment variable is not set")
|
||||
}
|
||||
domain := os.Getenv("APP_DOMAIN") // Нам нужен домен для генерации URL
|
||||
if domain == "" {
|
||||
log.Fatal("APP_DOMAIN environment variable is not set")
|
||||
}
|
||||
profileService, err := core.NewProfileService(userRepo, keyPath, domain)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to create profile service: %v", err)
|
||||
}
|
||||
// Хендлеры
|
||||
userHandler := &api.UserHandler{Service: userService}
|
||||
authHandler := &api.AuthHandler{Service: authService} // Новый хендлер
|
||||
authHandler := &api.AuthHandler{Service: authService} // Новый хендлер
|
||||
profileHandler := &api.ProfileHandler{Service: profileService} // Новый хендлер
|
||||
|
||||
// --- Настраиваем роутер ---
|
||||
r := chi.NewRouter()
|
||||
@@ -43,6 +57,11 @@ func main() {
|
||||
r.Post("/authenticate", authHandler.Authenticate)
|
||||
// Здесь будут другие эндпоинты: refresh, validate, signout, invalidate
|
||||
})
|
||||
// Группа маршрутов для Session Server API
|
||||
r.Route("/sessionserver/session/minecraft", func(r chi.Router) {
|
||||
r.Get("/profile/{uuid}", profileHandler.GetProfile)
|
||||
// Здесь будет эндпоинт /join
|
||||
})
|
||||
|
||||
// Маршрут для проверки, что сервер жив
|
||||
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Reference in New Issue
Block a user