Add oauth2 like auth service
All checks were successful
Build Backend (NixCN CMS) TeamCity build finished
Build Frontend (NixCN CMS) TeamCity build finished

Signed-off-by: Asai Neko <sugar@sne.moe>
This commit is contained in:
2026-01-02 15:57:42 +08:00
parent 62da1e096e
commit a98ab26fa4
12 changed files with 292 additions and 83 deletions

View File

@@ -1,7 +1,7 @@
package middleware
import (
"nixcn-cms/internal/cryptography"
"nixcn-cms/pkgs/authtoken"
"github.com/gin-gonic/gin"
)
@@ -11,8 +11,8 @@ func JWTAuth(required bool) gin.HandlerFunc {
return func(c *gin.Context) {
auth := c.GetHeader("Authorization")
token := new(cryptography.Token)
uid, err := token.HeaderVerify(auth)
authtoken := new(authtoken.Token)
uid, err := authtoken.HeaderVerify(auth)
if err != nil {
c.JSON(401, gin.H{"status": err.Error()})
c.Abort()