# Bảo mật nâng cao (Symfony) > Custom authenticator, voter, security expression, bảo vệ CSRF, ngăn chặn XSS, rate limiting, gia cố môi trường production, cấu hình sai JWT/OAuth2 - 22 câu hỏi phỏng vấn - Senior - [Câu hỏi phỏng vấn: Symfony](https://sharpskill.dev/vi/technologies/symfony/cau-hoi-phong-van.md) ## 1. Trong Symfony 6+, một custom authenticator phải triển khai interface nào? **Câu trả lời** Trong Symfony 6+, các custom authenticator phải triển khai AuthenticatorInterface từ component Security HTTP. Interface này định nghĩa các phương thức supports(), authenticate(), onAuthenticationSuccess(), onAuthenticationFailure() và tùy chọn createToken(). Nó thay thế hệ thống Guard cũ được sử dụng trong Symfony 4/5. ## 2. Vai trò của phương thức supports() trong một custom authenticator là gì? **Câu trả lời** Phương thức supports() xác định xem authenticator có nên xử lý request hiện tại hay không. Nó nhận Request và trả về một giá trị boolean. Nếu là true, phương thức authenticate() sẽ được gọi, theo sau là onAuthenticationSuccess() hoặc onAuthenticationFailure(). Điều này cho phép có nhiều authenticator hoạt động trên cùng một firewall, mỗi cái xử lý một loại xác thực cụ thể. ## 3. Phương thức authenticate() của một custom authenticator nên trả về gì khi thành công? **Câu trả lời** Phương thức authenticate() phải trả về một đối tượng Passport chứa một UserBadge (định danh người dùng) và các credentials badge. Passport cũng có thể chứa các badge bổ sung như CsrfTokenBadge hoặc RememberMeBadge. Sau đó Symfony sử dụng Passport này để tạo token xác thực và tải người dùng thông qua UserProvider. ## Còn 19 câu hỏi nữa - Làm thế nào để định nghĩa một Voter tùy chỉnh nhằm kiểm soát quyền truy cập vào một tài nguyên cụ thể? - Chiến lược AccessDecisionManager nào được khuyến nghị cho các ứng dụng yêu cầu bảo mật nghiêm ngặt? Đăng ký miễn phí: https://sharpskill.dev/vi/login ## Các chủ đề phỏng vấn Symfony khác - [PHP Hiện Đại (8.1+)](https://sharpskill.dev/vi/technologies/symfony/cau-hoi-phong-van/php-modern-features.md): 20 câu hỏi, Junior - [Kiến thức cơ bản về Symfony](https://sharpskill.dev/vi/technologies/symfony/cau-hoi-phong-van/symfony-basics.md): 25 câu hỏi, Junior - [Routing & Controllers](https://sharpskill.dev/vi/technologies/symfony/cau-hoi-phong-van/routing-controllers.md): 20 câu hỏi, Junior - [Twig & Templates](https://sharpskill.dev/vi/technologies/symfony/cau-hoi-phong-van/twig-templates.md): 20 câu hỏi, Junior - [Kiến thức cơ bản về Doctrine ORM](https://sharpskill.dev/vi/technologies/symfony/cau-hoi-phong-van/doctrine-orm-basics.md): 25 câu hỏi, Junior - [Biểu mẫu Symfony](https://sharpskill.dev/vi/technologies/symfony/cau-hoi-phong-van/forms.md): 22 câu hỏi, Junior - [Xác thực dữ liệu](https://sharpskill.dev/vi/technologies/symfony/cau-hoi-phong-van/validation.md): 18 câu hỏi, Junior - [Dependency Injection & Services](https://sharpskill.dev/vi/technologies/symfony/cau-hoi-phong-van/dependency-injection.md): 24 câu hỏi, Mid-Level - [Security & Authentication](https://sharpskill.dev/vi/technologies/symfony/cau-hoi-phong-van/security-authentication.md): 26 câu hỏi, Mid-Level - [Doctrine Nâng cao](https://sharpskill.dev/vi/technologies/symfony/cau-hoi-phong-van/doctrine-advanced.md): 24 câu hỏi, Mid-Level - [API Platform](https://sharpskill.dev/vi/technologies/symfony/cau-hoi-phong-van/api-platform.md): 22 câu hỏi, Mid-Level - [Serializer Component](https://sharpskill.dev/vi/technologies/symfony/cau-hoi-phong-van/serializer.md): 20 câu hỏi, Mid-Level - [Events & Event Subscribers](https://sharpskill.dev/vi/technologies/symfony/cau-hoi-phong-van/events-subscribers.md): 20 câu hỏi, Mid-Level - [Console & Commands](https://sharpskill.dev/vi/technologies/symfony/cau-hoi-phong-van/console-commands.md): 18 câu hỏi, Mid-Level - [Messenger Component](https://sharpskill.dev/vi/technologies/symfony/cau-hoi-phong-van/messenger.md): 22 câu hỏi, Mid-Level - [HTTP Client](https://sharpskill.dev/vi/technologies/symfony/cau-hoi-phong-van/http-client.md): 18 câu hỏi, Mid-Level - [Cache & Hiệu năng](https://sharpskill.dev/vi/technologies/symfony/cau-hoi-phong-van/cache.md): 20 câu hỏi, Mid-Level - [Workflow Component](https://sharpskill.dev/vi/technologies/symfony/cau-hoi-phong-van/workflow.md): 18 câu hỏi, Mid-Level - [Testing Symfony](https://sharpskill.dev/vi/technologies/symfony/cau-hoi-phong-van/testing.md): 22 câu hỏi, Mid-Level - [Mailer Component](https://sharpskill.dev/vi/technologies/symfony/cau-hoi-phong-van/mailer.md): 16 câu hỏi, Mid-Level - [Bản dịch & i18n](https://sharpskill.dev/vi/technologies/symfony/cau-hoi-phong-van/translations.md): 16 câu hỏi, Mid-Level - [EasyAdmin Bundle](https://sharpskill.dev/vi/technologies/symfony/cau-hoi-phong-van/easyadmin.md): 18 câu hỏi, Mid-Level - [Kiến trúc Symfony](https://sharpskill.dev/vi/technologies/symfony/cau-hoi-phong-van/architecture-patterns.md): 24 câu hỏi, Senior - [Hiệu năng & Tối ưu hóa](https://sharpskill.dev/vi/technologies/symfony/cau-hoi-phong-van/performance-optimization.md): 22 câu hỏi, Senior - [Custom Bundle](https://sharpskill.dev/vi/technologies/symfony/cau-hoi-phong-van/custom-bundles.md): 20 câu hỏi, Senior - [Microservices với Symfony](https://sharpskill.dev/vi/technologies/symfony/cau-hoi-phong-van/microservices.md): 22 câu hỏi, Senior - [Real-time & WebSockets](https://sharpskill.dev/vi/technologies/symfony/cau-hoi-phong-van/real-time.md): 18 câu hỏi, Senior - [Deployment & DevOps](https://sharpskill.dev/vi/technologies/symfony/cau-hoi-phong-van/deployment-devops.md): 20 câu hỏi, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/vi/technologies/symfony/cau-hoi-phong-van/security-advanced