AuthN vs AuthZ: Understanding Sessions, Tokens, and OAuth2 Quiz

Test your knowledge of authentication (AuthN) and authorization (AuthZ) concepts, including the roles of sessions, tokens, and basics of OAuth2. This quiz helps reinforce key identity and access control terms and scenarios essential for secure applications.

  1. Authentication Purpose

    What is the main purpose of authentication (AuthN) in a web application?

    1. To balance traffic across servers
    2. To encrypt all user data
    3. To verify the identity of a user
    4. To give users permission to access resources

    Explanation: Authentication is the process of verifying who a user is, usually through credentials like a password. Authorization, in contrast, deals with what the user is allowed to do, making the second option incorrect. Encrypting user data relates to security techniques, but not directly to authentication. Load balancing traffic is unrelated to either authentication or authorization.

  2. Authorization Scenario

    If a user is logged in but cannot access an admin page, what is most likely the issue?

    1. The session has expired
    2. The user lacks necessary authorization
    3. The page is temporarily unavailable
    4. The user failed authentication

    Explanation: A user who is already logged in has passed authentication. If the user cannot access a specific page, it usually means they do not have the required authorization. Failing authentication would prevent the user from logging in. An expired session would log the user out, and a temporarily unavailable page would affect all users, not just one.

  3. Sessions Meaning

    What does a 'session' represent in the context of web authentication?

    1. A period during which a user is authenticated
    2. A file storing encrypted user data
    3. A backup of application data
    4. A list of authorized resources

    Explanation: A session typically represents a time period when a user remains authenticated after logging in. It is not a file for encrypted data or a backup; those are separate concepts. A session also doesn't mean a list of authorized resources, which falls under authorization.

  4. Tokens Definition

    In authentication and authorization systems, what is most commonly the role of a token?

    1. To represent a user's authentication or access rights
    2. To store a website’s style information
    3. To schedule background tasks
    4. To generate application logs

    Explanation: Tokens are used to digitally represent a user's authentication state or permissions, such as allowing access to protected resources. Tokens do not store style information, which is the job of stylesheets. Scheduling tasks and generating logs are unrelated concepts.

  5. AuthN vs AuthZ Distinction

    Which statement best summarizes the difference between authentication (AuthN) and authorization (AuthZ)?

    1. Authentication checks what you can do; authorization checks who you are.
    2. Authentication is required after authorization.
    3. Both authentication and authorization mean the same thing.
    4. Authentication checks who you are; authorization checks what you can do.

    Explanation: Authentication is about establishing identity, while authorization is about assigning permissions after identity is known. The reverse statement mixes up the definitions. The two terms are related but not identical, making the third option false. Usually, authentication is required before authorization, not after.

  6. OAuth2 Purpose

    What is the primary purpose of the OAuth2 protocol in modern applications?

    1. To encrypt messages during transmission
    2. To allow users to grant limited access to their resources to third-party applications
    3. To measure app performance
    4. To store passwords in plain text

    Explanation: OAuth2 enables users to grant specific permissions to external applications without sharing their passwords. Encryption is a different security aspect, not OAuth2’s main role. Storing passwords in plain text is highly insecure. Measuring app performance is unrelated to OAuth2.

  7. Access Tokens Function

    What does an 'access token' typically allow in an OAuth2 workflow?

    1. It encrypts all traffic between user and server
    2. It grants access to specific protected resources on behalf of a user
    3. It resets a user's password
    4. It creates a new user account

    Explanation: An access token is issued after authorization and is used to access protected resources as permitted by the user's grants. Creating accounts and password resets are separate processes and not related to access tokens. While security is a consideration, access tokens do not directly encrypt traffic.

  8. Refresh Token Usage

    In OAuth2, what is the primary purpose of a refresh token?

    1. To validate a user's email address
    2. To change a user's permissions
    3. To terminate all active sessions
    4. To obtain a new access token after the original expires

    Explanation: A refresh token is specifically used to get a new access token without requiring the user to authenticate again. Email validation and terminating sessions are not functions of refresh tokens. Permissions changes are handled elsewhere in the system.

  9. Login Forms and AuthN

    When a website asks for a username and password on a login form, which process is being performed?

    1. Token revocation
    2. Session destruction
    3. Authorization
    4. Authentication

    Explanation: Requesting username and password serves to confirm a user’s identity, which is authentication. Authorization comes after, once the identity is verified. Ending a session or revoking tokens is not part of simply logging in.

  10. Authorization Example

    If one user can edit a document while another user can only view it, what security principle is being applied?

    1. Authentication
    2. Replication
    3. Authorization
    4. Session expiration

    Explanation: Giving different permissions to users is the essence of authorization. Authentication only identifies users, not what they’re allowed to do. Replication and session expiration are unrelated to access permissions.

  11. Which Happens First?

    In a typical security flow, which process usually occurs before the other: authentication or authorization?

    1. Both always happen at the same time
    2. Neither is required for resource access
    3. Authorization comes before authentication
    4. Authentication comes before authorization

    Explanation: Users are first authenticated to confirm identity, then authorized to access resources. Authorization before authentication would not make sense, as the system doesn’t yet know who is accessing it. The two processes may be closely linked but are not simultaneous. Access typically requires at least one or both.

  12. Session Expiry Outcome

    What happens if a user's session expires while accessing an application?

    1. The entire application resets
    2. The user is automatically authorized for all resources
    3. The user must re-authenticate to continue
    4. The user’s password changes automatically

    Explanation: Session expiration commonly logs the user out or removes authentication, requiring them to log in again. Automatic authorization is incorrect, as session expiry removes access. Passwords are not changed automatically. Application resets are unrelated to individual sessions.

  13. Token Storage Risk

    Why is it risky to store authentication tokens in unsecured locations such as plain-text files?

    1. Because attackers could steal the token and impersonate the user
    2. Because it slows down server performance
    3. Because tokens do not expire
    4. Because it increases data replication

    Explanation: If tokens are easily accessible, malicious parties can use them to gain unauthorized access. Performance and data replication are not directly affected by storage location. While tokens do have expiration times, this is unrelated to why plain-text storage is unsafe.

  14. OAuth2 Consent Screen

    During OAuth2 authorization, what is the purpose of the user consent screen?

    1. To select a different username
    2. To ask for their password again
    3. To let the user approve access to specific data or actions
    4. To update their authentication session

    Explanation: A consent screen shows which permissions the user is granting to an application. It does not request a password (that’s usually handled by authentication). Updating a session or choosing usernames is not the role of the consent screen in OAuth2.

  15. Least Privilege Principle

    Granting users only the access rights they need—no more, no less—is known as what?

    1. Full trust
    2. Tokenization
    3. Session mirroring
    4. Least privilege

    Explanation: The principle of least privilege restricts users to the minimal permissions necessary for their work. Tokenization refers to the use of tokens, not permission control. Full trust is the opposite, granting all privileges. Session mirroring refers to duplicating sessions, unrelated to security rights.

  16. Broken AuthZ Consequence

    What is a possible risk if an application has broken authorization mechanisms?

    1. Users cannot log in at all
    2. Users may access resources they should not be allowed to
    3. All network traffic will be encrypted
    4. Usernames will be displayed in error logs

    Explanation: Flaws in authorization can grant users undue access to protected data or actions. It doesn't typically prevent all logins unless authentication is also affected. Network traffic encryption is a separate feature, and displaying usernames in logs does not directly relate to authorization.