You are developing an Express application that requires user authentication. How do you ensure that user credentials are secured, and sessions are managed effectively across different routes?
- Use a secure authentication library like Passport.js, store user credentials securely by hashing and salting passwords, and implement session management with the express-session middleware.
- Store user credentials in plain text for simplicity, use client-side storage for session management, and avoid encrypting sensitive data to reduce overhead.
- Implement a custom authentication mechanism using base64 encoding for user credentials, and manage sessions by storing them in a global JavaScript object.
- Use HTTP Basic Authentication for user login and manage sessions by storing user information in cookies without encryption.
To ensure secure user authentication and session management in an Express application, it's crucial to use a secure authentication library like Passport.js, securely store user credentials, and utilize a trusted session management middleware like express-session. Options 2, 3, and 4 are insecure and not recommended practices.
Loading...
Related Quiz
- Cache ______ is a situation where multiple requests are made to a resource that is expensive to produce, causing a surge in load.
- Which of the following is the correct syntax for destructuring an array in JavaScript?
- In Node.js, what is the purpose of the process.on('uncaughtException', handler) method?
- When are CORS preflight requests sent by the browser?
- How can you optimize the rendering performance of template engines like EJS and Pug?