Authentication and security are crucial for developing secure web applications. Angular provides various built-in features like route guards, JWT authentication, and security mechanisms to prevent vulnerabilities such as XSS, CSRF, and clickjacking. These MCQs will help you prepare for interviews by testing your knowledge of securing Angular applications effectively.
1.) What is the best way to handle authentication in an Angular application?
A) Using local storage to store user credentials
B) Using JWT with an authentication service
C) Hardcoding usernames and passwords
D) Allowing users to bypass login if they refresh the page
2.) What is the best way to prevent brute-force attacks in Angular authentication?
A) Rate limiting login attempts
B) Allowing unlimited login attempts
C) Storing passwords in plaintext
D) Using a single static password
3.) What does JWT stand for?
A) JavaScript Web Token
B) Java Web Token
C) JSON Web Token
D) JAR Web Token
4.) Where should you store a JWT token in an Angular application for security reasons?
A) In local storage
B) In session storage
C) In HTTP cookies with HttpOnly and Secure flags
D) In a plain text file
5.) Which Angular feature is used to restrict access to certain routes?
A) Route Guards
B) Directives
C) Components
D) Services
6.) What does HTTPS encrypt?
A) Headers
B) Requests
C) Responses
D) Data
7.) What is the safest HTTP method for authentication?
A) GET
B) POST
C) PUT
D) DELETE
8.) What is Cross-Site Scripting (XSS) in Angular?
A) A method to enhance security
B) A debugging tool in Angular
C) A type of secure authentication
D) A vulnerability that allows injecting malicious scripts
9.) How does Angular prevent Cross-Site Scripting (XSS) attacks?
A) By using bypassSecurityTrustHtml()
B) By automatically sanitizing data in templates
C) By allowing all JavaScript code
D) By storing sensitive data in local storage
10.) What does the HttpInterceptor modify?
A) Routes
B) Styles
C) Requests
D) Components
Related