certmanager updates

This commit is contained in:
Олег Бородин
2024-08-10 10:19:56 +02:00
parent a21b4e2db9
commit 1cdbd2b034
29 changed files with 2341 additions and 1088 deletions

View File

@@ -1,32 +0,0 @@
package handler
import (
"errors"
"fmt"
"certmanager/pkg/auxhttp"
"github.com/gin-gonic/gin"
)
func (hand *Handler) BasicAuth(gctx *gin.Context) {
var err error
authHeader := gctx.Request.Header.Get("Authorization")
if authHeader == "" {
err = errors.New("Cannot found autentification data")
auxhttp.SendError(gctx, err)
return
}
username, password, err := auxhttp.ParseAuthBasicHeader(authHeader)
if err != nil {
err = fmt.Errorf("Authorization error: %s", err)
auxhttp.SendError(gctx, err)
return
}
if !hand.lg.ValidateUser(username, password) {
err = errors.New("Incorrect autentification data")
auxhttp.SendError(gctx, err)
return
}
gctx.Next()
}