qr vcard
This commit is contained in:
@@ -261,12 +261,27 @@ func AuthAdmin(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
func AuthApi() func(*fiber.Ctx) error {
|
||||
return Authenticate(AuthConfig{
|
||||
SigningKey: []byte(app.Http.Token.ApiJwtSecret),
|
||||
TokenLookup: "header:Verify-Rest-Token",
|
||||
ErrorHandler: func(ctx *fiber.Ctx, err error) error {
|
||||
auth.Logout(ctx)
|
||||
return ctx.Status(401).JSON("Invalid Attempt")
|
||||
},
|
||||
})
|
||||
return func(c *fiber.Ctx) error {
|
||||
// Excluir rutas públicas
|
||||
if c.Path() == "/api/v1/oauth/token" {
|
||||
return c.Next()
|
||||
}
|
||||
|
||||
// Obtener el token de la cookie "Verify-Rest-Token"
|
||||
token := c.Cookies("Verify-Rest-Token")
|
||||
if token == "" {
|
||||
// Si no hay token, regresar un error
|
||||
return c.Status(401).JSON("Token not found")
|
||||
}
|
||||
|
||||
// Continuar con la verificación JWT para otras rutas
|
||||
return Authenticate(AuthConfig{
|
||||
SigningKey: []byte(app.Http.Token.ApiJwtSecret),
|
||||
TokenLookup: "cookie:Verify-Rest-Token", // Ahora se busca en la cookie
|
||||
ErrorHandler: func(ctx *fiber.Ctx, err error) error {
|
||||
auth.Logout(ctx)
|
||||
return ctx.Status(401).JSON("Invalid Attempt")
|
||||
},
|
||||
})(c)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user