mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 10:25:52 +02:00
feat: encrypt login and install request #852
This commit is contained in:
parent
8e523258b5
commit
20531971cf
16 changed files with 265 additions and 108 deletions
22
api/crypto/crypto.go
Normal file
22
api/crypto/crypto.go
Normal file
|
@ -0,0 +1,22 @@
|
|||
package crypto
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/0xJacky/Nginx-UI/api"
|
||||
"github.com/0xJacky/Nginx-UI/internal/sign"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// GetPublicKey generates a new ED25519 key pair and registers it in the cache
|
||||
func GetPublicKey(c *gin.Context) {
|
||||
sign, err := sign.GetCryptoParams()
|
||||
if err != nil {
|
||||
api.ErrHandler(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"public_key": sign.PublicKey,
|
||||
})
|
||||
}
|
10
api/crypto/router.go
Normal file
10
api/crypto/router.go
Normal file
|
@ -0,0 +1,10 @@
|
|||
package crypto
|
||||
|
||||
import "github.com/gin-gonic/gin"
|
||||
|
||||
func InitPublicRouter(r *gin.RouterGroup) {
|
||||
g := r.Group("/crypto")
|
||||
{
|
||||
g.GET("public_key", GetPublicKey)
|
||||
}
|
||||
}
|
|
@ -1,12 +1,13 @@
|
|||
package system
|
||||
|
||||
import (
|
||||
"github.com/0xJacky/Nginx-UI/internal/middleware"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func InitPublicRouter(r *gin.RouterGroup) {
|
||||
r.GET("install", InstallLockCheck)
|
||||
r.POST("install", InstallNginxUI)
|
||||
r.POST("install", middleware.EncryptedParams(), InstallNginxUI)
|
||||
r.GET("translation/:code", GetTranslation)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package user
|
||||
|
||||
import (
|
||||
"github.com/0xJacky/Nginx-UI/internal/middleware"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func InitAuthRouter(r *gin.RouterGroup) {
|
||||
r.POST("/login", Login)
|
||||
r.POST("/login", middleware.EncryptedParams(), Login)
|
||||
r.DELETE("/logout", Logout)
|
||||
|
||||
r.GET("/begin_passkey_login", BeginPasskeyLogin)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue