This commit is contained in:
2026-02-11 17:46:22 +03:00
commit eacfacb13b
266 changed files with 51337 additions and 0 deletions

47
svc/auth/claims.go Normal file
View File

@@ -0,0 +1,47 @@
package auth
import (
"strings"
"github.com/golang-jwt/jwt/v5"
)
type Claims struct {
// ==================================================
// 🔑 IDENTITY
// ==================================================
ID int64 `json:"id"`
Username string `json:"username"`
RoleID int64 `json:"role_id"`
RoleCode string `json:"role_code"`
DepartmentCodes []string `json:"department_codes"`
// ==================================================
// 🧾 NEBIM (frontend filtre & backend guard için)
// ==================================================
V3Username string `json:"v3_username"`
V3UserGroup string `json:"v3_usergroup"`
// ==================================================
// 🔐 SESSION
// ==================================================
SessionID string `json:"session_id"`
// ==================================================
// ⚠️ SECURITY
// ==================================================
ForcePasswordChange bool `json:"force_password_change"`
jwt.RegisteredClaims
}
func (c *Claims) IsAdmin() bool {
if c == nil {
return false
}
role := strings.ToLower(strings.TrimSpace(c.RoleCode))
return role == "admin"
}