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 verify a user's identity
B. To format a web page
C. To compress database files
D. To improve network speed

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

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

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

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

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

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

5 What is a protected route?

Protected Routes Easy
A. A route that creates CSS files
B. A route with no server logic
C. A route used only for images
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 login page
B. To the database console
C. To the CSS editor
D. To the server terminal

7 What does authorization determine?

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

8 Which check is an example of authorization?

Authorization Easy
A. Checking whether a password matches
B. Checking whether Wi-Fi is active
C. Checking whether HTML is valid
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. Images
C. Browsers
D. Queries

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

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

11 What does ORM stand for?

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

12 What does an ORM help developers do?

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

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. Button color
B. Font family
C. Database host
D. Image width

15 What does the letter C represent in CRUD?

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

16 Which CRUD operation changes an existing database record?

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

17 Which CRUD operation retrieves stored data?

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

18 Why is user input validated before it is stored?

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

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

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

20 Why are environment variables commonly used in web applications?

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

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 as salted cryptographic hashes
B. Store passwords using a shared application secret
C. Store passwords using reversible encryption
D. Store passwords as plain text with restricted access

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

Authentication Concepts Medium
A. To prevent session fixation attacks
B. To make database queries execute faster
C. To allow multiple passwords for one account
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. Max-Age
B. Secure
C. SameSite
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. SameSite
B. Secure
C. Path
D. HttpOnly

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

Session Management Medium
A. To invalidate inactive sessions after a period
B. To encrypt data stored in the database
C. To increase the number of concurrent sessions
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. Render the dashboard with empty data
B. Create a temporary administrator session
C. Redirect or return an authentication error
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 page may load more slowly
B. The API can still be called directly
C. The browser cannot cache the link
D. The database schema becomes inconsistent

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 request uses HTTPS
B. Check whether the browser supports cookies
C. Check whether the URL contains a numeric ID
D. Check whether the requester owns the resource

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

Authorization Medium
A. 500 Internal Server Error
B. 403 Forbidden
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 create a new editor role
D. The request should be converted into a read request

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 guarantees that roles cannot be changed
C. It simplifies consistent permission management
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 database server process
B. A row in the mapped table
C. A collection of unrelated schemas
D. A database connection pool

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 browser's font settings
B. The HTML document title
C. The database connection string and credentials
D. The CSS framework version

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

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

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

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

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. Convert all values to uppercase
C. Use parameterized queries or ORM binding
D. Concatenate form values into SQL text

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

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

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

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

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. Use a longer session expiration period
B. Encrypt the password table with the application key
C. Replace the hash with a keyed HMAC
D. Use a memory-hard password hashing function

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. Prevention of CSRF token reuse
B. Protection against session fixation
C. Resistance to account enumeration
D. Forward secrecy for credentials

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. Allow the identifier on cross-site requests
B. Increase the session cookie's maximum age
C. Store the session identifier in localStorage
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. Trust the timestamp embedded in the browser cookie
B. Refresh the expiry timestamp in every request handler
C. Extend expiration whenever the session ID is syntactically valid
D. Use atomic compare-and-update expiration checks

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 browser should hash the user's role
B. The interface should use shorter access tokens
C. The API trusts presentation logic for authorization
D. The login page should be rendered server-side

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. Permit any HTTPS destination after login
B. Encrypt the destination with a public key
C. Store the destination in a query string
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. Broken object-level authorization
C. Session fixation
D. Credential stuffing

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. Check authorization only after the update commits
C. Perform authorization and mutation in one transaction
D. Cache the authorization result for five minutes

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. Ignore roles and use the user's creation date
B. Deny if the role list contains a wildcard
C. Grant only when every role permits
D. Grant if at least one applicable 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. Hide administrative controls after rendering
B. Validate revocation or privilege version server-side
C. Increase the token lifetime for usability
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. Disable all database indexes
C. Increase the connection pool indefinitely
D. Use eager loading or a batched relation query

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. Apply an allowlist for mass-assigned fields
B. Use lazy loading for all relationships
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. Share one connection globally across all requests
B. Use a bounded connection pool with release handling
C. Create one unmanaged connection per query
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. Consistency
B. Isolation
C. Durability
D. Atomicity

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. Treat every omitted field as an authorization failure
B. Document the endpoint as partial update semantics
C. Replace the database with a document store
D. Use PUT only for deleting the resource

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. Update only where the ID and version both match
C. Add a random delay before every update
D. Read the product again after committing

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. Rely only on a client-side uniqueness check
B. Remove the constraint after validating the format
C. Check uniqueness once during application startup
D. Keep the unique constraint and handle conflicts

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. Validate only after writing the value
B. Accept all strings and normalize them in the UI
C. Convert every numeric value to floating point
D. Use strict schemas with bounded numeric constraints

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. Expose the secret through a client-side configuration file
B. Base64-encode every value without decoding it
C. Quote values according to the deployment environment
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. Generate a new key on every incoming request
B. Log the missing key and continue normally
C. Use a predictable default key for availability
D. Fail startup when required secrets are absent