Authentication vs. Authorization
What is the primary difference between authentication and authorization in the context of API security?
- Authentication verifies *what* a user can access, while authorization verifies *who* the user is.
- Authentication verifies *who* a user is, while authorization verifies *what* a user can access.
- Authentication encrypts data, while authorization decrypts it.
- Authentication is for front-end, authorization is for back-end.
- Authentication and authorization are the same thing.
JWT Structure
Which of the following correctly describes the typical structure of a JSON Web Token (JWT)?
- Header.Payload.Signature
- Signature.Payload.Header
- Payload.Header.Signature
- Header-Payload-Signature
- Header:Payload:Signature
OAuth 2.0 Grant Types
Which OAuth 2.0 grant type is best suited for native mobile applications where the client cannot securely store client secrets?
- Authorization Code Grant
- Implicit Grant
- Resource Owner Password Credentials Grant
- Client Credentials Grant
- Grant Type Extension
API Key Security
What is the most important security practice to follow when using API keys for authentication?
- Storing API keys in the client-side code.
- Using a very short API key to improve performance.
- Treating API keys as secrets and storing them securely on the server-side.
- Making API keys publicly available for easy integration.
- Rotating API keys annually.
Role-Based Access Control (RBAC)
In Role-Based Access Control (RBAC), what is the primary advantage of assigning permissions to roles instead of directly to users?
- It simplifies user management and reduces redundancy.
- It improves API performance.
- It increases the complexity of the system.
- It eliminates the need for authentication.
- It makes the system less secure.
Middleware for Authentication
What is the typical role of middleware in implementing authentication and authorization checks in an API endpoint?
- To handle database queries.
- To validate user input.
- To intercept incoming requests and verify user identity and permissions before routing to the API endpoint.
- To format API responses.
- To cache API responses.
Rate Limiting
Why is rate limiting an important aspect of API security, even if authentication and authorization are properly implemented?
- To improve API response times.
- To prevent brute-force attacks and resource exhaustion.
- To simplify API documentation.
- To make the API easier to use.
- To enforce user agreements.
CORS and API Security
How does Cross-Origin Resource Sharing (CORS) relate to API security?
- CORS is only relevant for front-end development.
- CORS helps prevent malicious websites from making unauthorized requests to your API from different origins.
- CORS encrypts data transmitted between the client and server.
- CORS handles user authentication.
- CORS is not related to API security.
Best Practice for Storing Passwords
Which of the following is the most secure method for storing user passwords in a database?
- Storing passwords in plain text.
- Hashing passwords with a weak hashing algorithm like MD5.
- Hashing passwords with a strong, salted hashing algorithm like bcrypt or Argon2.
- Encrypting passwords using a symmetric encryption key.
- Not storing passwords at all.
OWASP Top Ten API Security Risks
Which of the following is a common API security risk identified in the OWASP Top Ten?
- Excessive data validation
- Lack of resources and rate limiting
- Verbose error messaging
- Perfect Forward Secrecy
- Consistent use of HTTP headers