security: Add proper authentication, RBAC, and tenant isolation
- Add password hashing with bcrypt - Add AuthService with proper login - Add password strength validation - Add RBAC middleware (AdminOnly, ManagerOrAdmin) - Add tenant isolation middleware - Update CRM handler with tenant filtering - Add JWT fallback for development mode - Add user context helpers - Build successful
This commit is contained in:
@@ -38,6 +38,16 @@ func (c Claims) Valid() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// HasRole kontrollerar om användaren har en specifik roll
|
||||
func (c Claims) HasRole(role string) bool {
|
||||
for _, r := range c.Roles {
|
||||
if r == role {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// ── Context Key ────────────────────────────────────────────────────────────
|
||||
type contextKey int
|
||||
|
||||
|
||||
Reference in New Issue
Block a user