Unit 4: Authentication and Database Integration - Practice Quiz

INT257 — Modern Web Application Development 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 What is the main purpose of authentication in a web application?

Authentication Concepts Easy
A. To improve network speed
B. To format a web page
C. To verify a user's identity
D. To compress database files

2 Which credential is commonly used with a username during authentication?

Authentication Concepts Easy
A. A password
B. A table name
C. A URL path
D. A stylesheet

3 What does a session commonly store after a user logs in?

Session Management Easy
A. The server's source code
B. The user's login state
C. The website's font files
D. The database schema

4 What usually happens to a user's session when they log out?

Session Management Easy
A. It is destroyed or invalidated
B. It installs a new browser
C. It changes the page layout
D. It becomes a database table

5 What is a protected route?

Protected Routes Easy
A. A route used only for images
B. A route with no server logic
C. A route that creates CSS files
D. A route limited to authorized users

6 Where is an unauthenticated user commonly sent when opening a protected route?

Protected Routes Easy
A. To the CSS editor
B. To the server terminal
C. To the login page
D. To the database console

7 What does authorization determine?

Authorization Easy
A. Whether a server is powered on
B. What an authenticated user may do
C. Which browser is installed
D. How a password is typed

8 Which check is an example of authorization?

Authorization Easy
A. Checking whether HTML is valid
B. Checking whether Wi-Fi is active
C. Checking whether a password matches
D. Checking permission to delete a post

9 In role-based access control, permissions are primarily assigned to what?

Role-based Access Control Easy
A. Roles
B. Queries
C. Images
D. Browsers

10 Which role would commonly have permission to manage all user accounts?

Role-based Access Control Easy
A. Administrator
B. Subscriber
C. Viewer
D. Guest

11 What does ORM stand for?

ORM Basics Easy
A. Object Request Method
B. Online Resource Management
C. Open Routing Model
D. Object-Relational Mapping

12 What does an ORM help developers do?

ORM Basics Easy
A. Design icons as vector images
B. Work with database data as objects
C. Compile styles into web pages
D. Configure physical network cables

13 What is required for an application to connect to a database?

Database Connectivity Easy
A. A database connection string
B. A screen resolution value
C. A page animation setting
D. A browser bookmark file

14 Which value is commonly included in database connection settings?

Database Connectivity Easy
A. Font family
B. Database host
C. Button color
D. Image width

15 What does the letter C represent in CRUD?

CRUD Operations Easy
A. Calculate
B. Create
C. Connect
D. Compile

16 Which CRUD operation changes an existing database record?

CRUD Operations Easy
A. Create
B. Read
C. Delete
D. Update

17 Which CRUD operation retrieves stored data?

CRUD Operations Easy
A. Read
B. Delete
C. Update
D. Create

18 Why is user input validated before it is stored?

Data Validation Easy
A. To increase the monitor brightness
B. To rename the application server
C. To ensure it meets expected rules
D. To change the browser theme

19 Which is a basic validation rule for a required email field?

Data Validation Easy
A. It must not be empty
B. It must create a session
C. It must delete a record
D. It must contain an image

20 Why are environment variables commonly used in web applications?

Environment Variables Easy
A. To arrange records in database rows
B. To store configuration outside source code
C. To define headings in a web page
D. To draw interface icons in HTML

21 A web application stores user passwords for login verification. Which approach provides the best protection if the database is exposed?

Authentication Concepts Medium
A. Store passwords using a shared application secret
B. Store passwords as salted cryptographic hashes
C. Store passwords as plain text with restricted access
D. Store passwords using reversible encryption

22 Why should a server regenerate a session identifier after a user successfully logs in?

Authentication Concepts Medium
A. To make database queries execute faster
B. To allow multiple passwords for one account
C. To prevent session fixation attacks
D. To reduce the size of the session cookie

23 A session cookie should not be accessible through client-side JavaScript because of which cookie attribute?

Session Management Medium
A. SameSite
B. Secure
C. Max-Age
D. HttpOnly

24 An application must ensure that a session cookie is sent only over HTTPS connections. Which cookie setting addresses this requirement?

Session Management Medium
A. HttpOnly
B. SameSite
C. Path
D. Secure

25 What is the primary purpose of an idle session timeout?

Session Management Medium
A. To increase the number of concurrent sessions
B. To encrypt data stored in the database
C. To invalidate inactive sessions after a period
D. To prevent users from changing passwords

26 A request to /dashboard is received without a valid authenticated session. What should protected-route middleware typically do?

Protected Routes Medium
A. Redirect or return an authentication error
B. Create a temporary administrator session
C. Render the dashboard with empty data
D. Ignore the request and continue processing

27 A frontend hides an administrator link, but the corresponding API endpoint has no server-side authentication check. What is the main security problem?

Protected Routes Medium
A. The database schema becomes inconsistent
B. The API can still be called directly
C. The page may load more slowly
D. The browser cannot cache the link

28 A logged-in user requests another user's private profile by changing the user ID in the URL. Which authorization check is needed?

Authorization Medium
A. Check whether the requester owns the resource
B. Check whether the browser supports cookies
C. Check whether the request uses HTTPS
D. Check whether the URL contains a numeric ID

29 Which response status is most appropriate when a user is authenticated but lacks permission to delete a resource?

Authorization Medium
A. 403 Forbidden
B. 500 Internal Server Error
C. 302 Found
D. 200 OK

30 In a role-based access control system, a user has the role editor, which permits updating articles but not deleting them. What should happen when the user sends a delete request?

Role-based Access Control Medium
A. The request should be authorized automatically
B. The request should be denied by a permission check
C. The request should be converted into a read request
D. The request should create a new editor role

31 What is a key advantage of assigning permissions to roles instead of configuring permissions separately for every user?

Role-based Access Control Medium
A. It allows users to bypass server checks
B. It simplifies consistent permission management
C. It guarantees that roles cannot be changed
D. It removes the need for authentication

32 In an ORM, a User class is mapped to a database table. What does an instance of the class usually represent?

ORM Basics Medium
A. A row in the mapped table
B. A database server process
C. A database connection pool
D. A collection of unrelated schemas

33 What is the main purpose of an ORM migration?

ORM Basics Medium
A. To disable database transactions
B. To replace all application routes
C. To hash every user password again
D. To change the database schema in a tracked way

34 An application is deployed to production and fails because it cannot connect to the database. Which configuration should be checked first?

Database Connectivity Medium
A. The CSS framework version
B. The database connection string and credentials
C. The browser's font settings
D. The HTML document title

35 Why should a web application use a connection pool for frequent database access?

Database Connectivity Medium
A. It converts relational tables into JSON files
B. It guarantees that every query is valid
C. It reuses connections and reduces setup overhead
D. It removes the need for database indexes

36 Which operation best represents updating a user's email address in a database?

CRUD Operations Medium
A. Updating an existing record
B. Creating a new table
C. Reading a database schema
D. Deleting the user record

37 A user submits a form to create a new blog post. Which practice best reduces SQL injection risk when inserting the data?

CRUD Operations Medium
A. Remove spaces from the submitted text
B. Concatenate form values into SQL text
C. Use parameterized queries or ORM binding
D. Convert all values to uppercase

38 A registration endpoint receives an email field that contains an empty string. What is the best validation behavior?

Data Validation Medium
A. Reject it with a clear validation error
B. Store it as a random generated value
C. Convert it to an administrator address
D. Accept it and let the database decide

39 Why should validation be performed on the server even when the frontend already validates the form?

Data Validation Medium
A. Servers cannot process structured data
B. Clients can bypass or modify frontend checks
C. Frontend validation automatically encrypts requests
D. Database constraints are never useful

40 Which value is most appropriate to store in an environment variable rather than directly in source code?

Environment Variables Medium
A. A static application logo path
B. A database password
C. A public page heading
D. A fixed CSS class name

41 A web application stores passwords using a fast hash function with a unique salt per user. An attacker obtains the password table and can evaluate billions of hashes per second. Which change most directly improves resistance to offline cracking?

Authentication Concepts Hard
A. Replace the hash with a keyed HMAC
B. Use a memory-hard password hashing function
C. Encrypt the password table with the application key
D. Use a longer session expiration period

42 A login endpoint returns the same HTTP status, response body structure, and approximate timing for an unknown email and an incorrect password. What security property is this design primarily intended to provide?

Authentication Concepts Hard
A. Forward secrecy for credentials
B. Protection against session fixation
C. Resistance to account enumeration
D. Prevention of CSRF token reuse

43 A user logs in successfully, but the server keeps the anonymous session identifier and merely adds an authenticated flag. Which remediation is most important?

Session Management Hard
A. Increase the session cookie's maximum age
B. Store the session identifier in localStorage
C. Allow the identifier on cross-site requests
D. Rotate the session identifier after authentication

44 A server-side session store uses a sliding idle timeout. Two requests from the same session arrive concurrently: one is valid at time , while the other was sent before the session expired but reaches the server afterward. Which design best prevents stale-request resurrection?

Session Management Hard
A. Extend expiration whenever the session ID is syntactically valid
B. Use atomic compare-and-update expiration checks
C. Trust the timestamp embedded in the browser cookie
D. Refresh the expiry timestamp in every request handler

45 A single-page application hides an admin link for non-admin users, but its API endpoint only checks whether a request has a valid login session. What is the primary flaw?

Protected Routes Hard
A. The login page should be rendered server-side
B. The browser should hash the user's role
C. The interface should use shorter access tokens
D. The API trusts presentation logic for authorization

46 A protected route checks authentication in middleware, then redirects unauthenticated users to a login page. An attacker supplies a URL containing an external destination as the return parameter. Which control is required?

Protected Routes Hard
A. Store the destination in a query string
B. Permit any HTTPS destination after login
C. Encrypt the destination with a public key
D. Permit only relative internal return paths

47 An endpoint permits a user to fetch /orders/4821 after checking that the user is logged in, but it does not compare the order's owner ID with the requester. What vulnerability remains?

Authorization Hard
A. Cross-site request forgery
B. Session fixation
C. Credential stuffing
D. Broken object-level authorization

48 A document update service first verifies that a user may edit a document and then performs the update using only the document ID. The document can be moved between tenants by another process between these operations. Which solution best addresses the issue?

Authorization Hard
A. Expose the tenant ID as a client-editable field
B. Cache the authorization result for five minutes
C. Perform authorization and mutation in one transaction
D. Check authorization only after the update commits

49 A user has both viewer and editor roles. The application denies access if any assigned role lacks permission, even when another role grants it. Which RBAC evaluation model is usually intended instead?

Role-based Access Control Hard
A. Deny if the role list contains a wildcard
B. Grant if at least one applicable role permits
C. Ignore roles and use the user's creation date
D. Grant only when every role permits

50 An administrator changes a user's role from admin to support, but existing access tokens contain the old role claim and remain valid for one hour. Which mitigation most directly limits stale privilege?

Role-based Access Control Hard
A. Validate revocation or privilege version server-side
B. Increase the token lifetime for usability
C. Hide administrative controls after rendering
D. Move the role claim into a browser cookie

51 An ORM loads 1,000 posts and lazily fetches each author's record while rendering them. The database receives one query for posts and 1,000 author queries. What is the most appropriate correction when all authors are needed?

ORM Basics Hard
A. Serialize each author into the post table
B. Increase the connection pool indefinitely
C. Use eager loading or a batched relation query
D. Disable all database indexes

52 An ORM model accepts a request body containing email, displayName, and isAdmin, and uses a generic update method. A client changes isAdmin despite lacking permission. Which ORM-level control is most relevant?

ORM Basics Hard
A. Use lazy loading for all relationships
B. Apply an allowlist for mass-assigned fields
C. Enable automatic schema migration
D. Convert every column to a string

53 A production service opens a new database connection for every request and occasionally exhausts the database connection limit under load. Which architecture is most appropriate?

Database Connectivity Hard
A. Create one unmanaged connection per query
B. Share one connection globally across all requests
C. Use a bounded connection pool with release handling
D. Retry indefinitely without limiting concurrency

54 A database transaction updates an inventory row, but a second transaction can read the intermediate value before the first transaction commits. Which database property is missing or inadequately configured?

Database Connectivity Hard
A. Durability
B. Consistency
C. Atomicity
D. Isolation

55 An API implements PUT /users/7 by updating only fields present in the request and leaving all other fields unchanged. A client omits a field expecting it to be cleared. Which design correction is most accurate?

CRUD Operations Hard
A. Use PUT only for deleting the resource
B. Replace the database with a document store
C. Treat every omitted field as an authorization failure
D. Document the endpoint as partial update semantics

56 Two clients read a product with version 12. Both submit updates, and the second update silently overwrites the first. Which implementation provides optimistic concurrency control?

CRUD Operations Hard
A. Permit updates only from administrators
B. Add a random delay before every update
C. Read the product again after committing
D. Update only where the ID and version both match

57 A registration validator checks that an email has a valid format, but the database later rejects it because the email column is unique. Which validation strategy is correct?

Data Validation Hard
A. Remove the constraint after validating the format
B. Rely only on a client-side uniqueness check
C. Keep the unique constraint and handle conflicts
D. Check uniqueness once during application startup

58 A server validates a request's JSON structure but accepts a string such as "999999999999999999999" for an integer amount, allowing inconsistent coercion across services. What is the strongest fix?

Data Validation Hard
A. Convert every numeric value to floating point
B. Use strict schemas with bounded numeric constraints
C. Accept all strings and normalize them in the UI
D. Validate only after writing the value

59 A deployment reads DATABASE_URL successfully, but a secret containing a dollar sign and spaces is truncated or altered by the shell. Which practice best prevents this configuration error?

Environment Variables Hard
A. Base64-encode every value without decoding it
B. Quote values according to the deployment environment
C. Expose the secret through a client-side configuration file
D. Embed the secret directly in source code

60 An application falls back to a development signing key when AUTH_SECRET is missing. In production, a deployment typo therefore starts successfully but issues forgeable tokens. Which design is safest?

Environment Variables Hard
A. Fail startup when required secrets are absent
B. Use a predictable default key for availability
C. Log the missing key and continue normally
D. Generate a new key on every incoming request