refactor(api): separate Yggdrasil routes from v1 API group
Move Yggdrasil API endpoints from /api/v1/yggdrasil to /api/yggdrasil for better route organization and compatibility with standard Yggdrasil protocol. Also upgrade Go to 1.25, update dependencies, and migrate email package from jordan-wright/email to gopkg.in/mail.v2. Remove deprecated UUID design plan.
This commit is contained in:
@@ -177,7 +177,7 @@ func NewYggdrasilHandler(c *container.Container) *YggdrasilHandler {
|
||||
// @Param request body AuthenticateRequest true "认证请求"
|
||||
// @Success 200 {object} AuthenticateResponse
|
||||
// @Failure 403 {object} map[string]string "认证失败"
|
||||
// @Router /api/v1/yggdrasil/authserver/authenticate [post]
|
||||
// @Router /api/yggdrasil/authserver/authenticate [post]
|
||||
func (h *YggdrasilHandler) Authenticate(c *gin.Context) {
|
||||
rawData, err := io.ReadAll(c.Request.Body)
|
||||
if err != nil {
|
||||
@@ -279,7 +279,7 @@ func (h *YggdrasilHandler) Authenticate(c *gin.Context) {
|
||||
// @Param request body ValidTokenRequest true "验证请求"
|
||||
// @Success 204 "令牌有效"
|
||||
// @Failure 403 {object} errors.YggdrasilErrorResponse "令牌无效"
|
||||
// @Router /api/v1/yggdrasil/authserver/validate [post]
|
||||
// @Router /api/yggdrasil/authserver/validate [post]
|
||||
func (h *YggdrasilHandler) ValidToken(c *gin.Context) {
|
||||
var request ValidTokenRequest
|
||||
if err := c.ShouldBindJSON(&request); err != nil {
|
||||
@@ -310,7 +310,7 @@ func (h *YggdrasilHandler) ValidToken(c *gin.Context) {
|
||||
// @Param request body RefreshRequest true "刷新请求"
|
||||
// @Success 200 {object} RefreshResponse
|
||||
// @Failure 400 {object} map[string]string "刷新失败"
|
||||
// @Router /api/v1/yggdrasil/authserver/refresh [post]
|
||||
// @Router /api/yggdrasil/authserver/refresh [post]
|
||||
func (h *YggdrasilHandler) RefreshToken(c *gin.Context) {
|
||||
var request RefreshRequest
|
||||
if err := c.ShouldBindJSON(&request); err != nil {
|
||||
@@ -472,7 +472,7 @@ func (h *YggdrasilHandler) RefreshToken(c *gin.Context) {
|
||||
// @Produce json
|
||||
// @Param request body ValidTokenRequest true "失效请求"
|
||||
// @Success 204 "操作成功"
|
||||
// @Router /api/v1/yggdrasil/authserver/invalidate [post]
|
||||
// @Router /api/yggdrasil/authserver/invalidate [post]
|
||||
func (h *YggdrasilHandler) InvalidToken(c *gin.Context) {
|
||||
var request ValidTokenRequest
|
||||
if err := c.ShouldBindJSON(&request); err != nil {
|
||||
@@ -495,7 +495,7 @@ func (h *YggdrasilHandler) InvalidToken(c *gin.Context) {
|
||||
// @Param request body SignOutRequest true "登出请求"
|
||||
// @Success 204 "操作成功"
|
||||
// @Failure 400 {object} map[string]string "参数错误"
|
||||
// @Router /api/v1/yggdrasil/authserver/signout [post]
|
||||
// @Router /api/yggdrasil/authserver/signout [post]
|
||||
func (h *YggdrasilHandler) SignOut(c *gin.Context) {
|
||||
var request SignOutRequest
|
||||
if err := c.ShouldBindJSON(&request); err != nil {
|
||||
@@ -542,7 +542,7 @@ func (h *YggdrasilHandler) SignOut(c *gin.Context) {
|
||||
// @Param unsigned query string false "是否不返回签名(true/false,默认false)"
|
||||
// @Success 200 {object} map[string]interface{} "档案信息"
|
||||
// @Failure 404 {object} errors.YggdrasilErrorResponse "档案不存在"
|
||||
// @Router /api/v1/yggdrasil/sessionserver/session/minecraft/profile/{uuid} [get]
|
||||
// @Router /api/yggdrasil/sessionserver/session/minecraft/profile/{uuid} [get]
|
||||
func (h *YggdrasilHandler) GetProfileByUUID(c *gin.Context) {
|
||||
uuid := c.Param("uuid")
|
||||
h.logger.Info("获取配置文件请求", zap.String("uuid", uuid))
|
||||
@@ -580,7 +580,7 @@ func (h *YggdrasilHandler) GetProfileByUUID(c *gin.Context) {
|
||||
// @Success 204 "加入成功"
|
||||
// @Failure 400 {object} APIResponse "参数错误"
|
||||
// @Failure 500 {object} APIResponse "服务器错误"
|
||||
// @Router /api/v1/yggdrasil/sessionserver/session/minecraft/join [post]
|
||||
// @Router /api/yggdrasil/sessionserver/session/minecraft/join [post]
|
||||
func (h *YggdrasilHandler) JoinServer(c *gin.Context) {
|
||||
var request JoinServerRequest
|
||||
clientIP := c.ClientIP()
|
||||
@@ -635,7 +635,7 @@ func (h *YggdrasilHandler) JoinServer(c *gin.Context) {
|
||||
// @Param ip query string false "客户端IP"
|
||||
// @Success 200 {object} map[string]interface{} "验证成功,返回档案"
|
||||
// @Failure 204 "验证失败"
|
||||
// @Router /api/v1/yggdrasil/sessionserver/session/minecraft/hasJoined [get]
|
||||
// @Router /api/yggdrasil/sessionserver/session/minecraft/hasJoined [get]
|
||||
func (h *YggdrasilHandler) HasJoinedServer(c *gin.Context) {
|
||||
clientIP, _ := c.GetQuery("ip")
|
||||
|
||||
@@ -694,7 +694,7 @@ func (h *YggdrasilHandler) HasJoinedServer(c *gin.Context) {
|
||||
// @Param request body []string true "用户名列表"
|
||||
// @Success 200 {array} model.Profile "档案列表"
|
||||
// @Failure 400 {object} APIResponse "参数错误"
|
||||
// @Router /api/v1/yggdrasil/api/profiles/minecraft [post]
|
||||
// @Router /api/yggdrasil/api/profiles/minecraft [post]
|
||||
func (h *YggdrasilHandler) GetProfilesByName(c *gin.Context) {
|
||||
var names []string
|
||||
|
||||
@@ -723,7 +723,7 @@ func (h *YggdrasilHandler) GetProfilesByName(c *gin.Context) {
|
||||
// @Produce json
|
||||
// @Success 200 {object} map[string]interface{} "元数据"
|
||||
// @Failure 500 {object} APIResponse "服务器错误"
|
||||
// @Router /api/v1/yggdrasil [get]
|
||||
// @Router /api/yggdrasil [get]
|
||||
func (h *YggdrasilHandler) GetMetaData(c *gin.Context) {
|
||||
meta := gin.H{
|
||||
"implementationName": "CellAuth",
|
||||
@@ -768,7 +768,7 @@ func (h *YggdrasilHandler) GetMetaData(c *gin.Context) {
|
||||
// @Failure 401 {object} errors.YggdrasilErrorResponse "未授权"
|
||||
// @Failure 403 {object} errors.YggdrasilErrorResponse "令牌无效"
|
||||
// @Failure 500 {object} errors.YggdrasilErrorResponse "服务器错误"
|
||||
// @Router /api/v1/yggdrasil/minecraftservices/player/certificates [post]
|
||||
// @Router /api/yggdrasil/minecraftservices/player/certificates [post]
|
||||
func (h *YggdrasilHandler) GetPlayerCertificates(c *gin.Context) {
|
||||
authHeader := c.GetHeader("Authorization")
|
||||
if authHeader == "" {
|
||||
|
||||
Reference in New Issue
Block a user