Skip to content

Commit

Permalink
feat: api of getting server public key for app
Browse files Browse the repository at this point in the history
  • Loading branch information
Mmx233 committed Apr 4, 2024
1 parent 89cf1d9 commit 759b71a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
20 changes: 20 additions & 0 deletions internal/api/controllers/app/keypair.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package controllers

import (
"github.com/gin-gonic/gin"
"github.com/ncuhome/GeniusAuthoritarian/internal/api/callback"
"github.com/ncuhome/GeniusAuthoritarian/internal/global"
"github.com/ncuhome/GeniusAuthoritarian/pkg/keypair"
)

func ServerPublicKeys(c *gin.Context) {
jwtPublic, err := keypair.PemMarshalPublic(global.JwtEd25519.PublicKey)
if err != nil {
callback.Error(c, callback.ErrUnexpected, err)
return
}

callback.Success(c, gin.H{
"jwt": jwtPublic,
})
}
14 changes: 14 additions & 0 deletions internal/api/router/app/init.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package app

import (
"github.com/gin-gonic/gin"
controllers "github.com/ncuhome/GeniusAuthoritarian/internal/api/controllers/app"
"github.com/ncuhome/GeniusAuthoritarian/internal/api/middlewares"
)

func Router(G *gin.RouterGroup) {
G.Use(middlewares.RequireAppSignature)

keypair := G.Group("keypair")
keypair.GET("server", controllers.ServerPublicKeys)
}
2 changes: 2 additions & 0 deletions internal/api/router/v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ package router

import (
"github.com/gin-gonic/gin"
"github.com/ncuhome/GeniusAuthoritarian/internal/api/router/app"
"github.com/ncuhome/GeniusAuthoritarian/internal/api/router/feishu"
"github.com/ncuhome/GeniusAuthoritarian/internal/api/router/public"
"github.com/ncuhome/GeniusAuthoritarian/internal/api/router/user"
)

func ApiV1(G *gin.RouterGroup) {
public.Router(G.Group("public"))
app.Router(G.Group("app"))
user.Router(G.Group("user"))
feishu.Router(G.Group("feishu"))
}

0 comments on commit 759b71a

Please sign in to comment.