feat(auth): implement yggdrasil authenticate endpoint

This commit is contained in:
2025-06-14 21:51:36 +03:00
parent 54ce479a6e
commit 4d42cfff2d
5 changed files with 209 additions and 8 deletions

36
internal/models/auth.go Normal file
View File

@@ -0,0 +1,36 @@
package models
// Agent представляет информацию о лаунчере, который делает запрос
type Agent struct {
Name string `json:"name"` // "Minecraft"
Version int `json:"version"` // 1
}
// AuthenticateRequest - это тело запроса на /authserver/authenticate
type AuthenticateRequest struct {
Agent Agent `json:"agent"`
Username string `json:"username"`
Password string `json:"password"`
ClientToken string `json:"clientToken"`
}
// ProfileInfo содержит краткую информацию о профиле игрока
type ProfileInfo struct {
ID string `json:"id"` // UUID пользователя без дефисов
Name string `json:"name"` // Никнейм пользователя
}
// AuthenticateResponse - это тело успешного ответа
type AuthenticateResponse struct {
AccessToken string `json:"accessToken"`
ClientToken string `json:"clientToken"`
AvailableProfiles []ProfileInfo `json:"availableProfiles"`
SelectedProfile ProfileInfo `json:"selectedProfile"`
User *UserProperty `json:"user,omitempty"` // Необязательное поле с доп. свойствами
}
// UserProperty - часть ответа, может содержать доп. свойства пользователя
type UserProperty struct {
ID string `json:"id"` // UUID пользователя
Properties []any `json:"properties"` // Обычно пустой массив
}