mirror of
https://github.com/JustKato/drive-health.git
synced 2026-04-30 01:42:29 +03:00
Implemented Authentication
+ Basic Authentication
This commit is contained in:
11
lib/web/auth_middleware.go
Normal file
11
lib/web/auth_middleware.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package web
|
||||
|
||||
import "github.com/gin-gonic/gin"
|
||||
|
||||
func BasicAuthMiddleware(username, password string) gin.HandlerFunc {
|
||||
authorized := gin.Accounts{
|
||||
username: password,
|
||||
}
|
||||
|
||||
return gin.BasicAuth(authorized)
|
||||
}
|
||||
@@ -2,12 +2,16 @@ package web
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"tea.chunkbyte.com/kato/drive-health/lib/config"
|
||||
)
|
||||
|
||||
func SetupRouter() *gin.Engine {
|
||||
// Initialize the Gin engine
|
||||
cfg := config.GetConfiguration()
|
||||
r := gin.Default()
|
||||
|
||||
r.Use(BasicAuthMiddleware(cfg.IdentityUsername, cfg.IdentityPassword))
|
||||
|
||||
// Setup Health Pings
|
||||
setupHealth(r)
|
||||
// Setup Api
|
||||
|
||||
Reference in New Issue
Block a user