Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

Ruby on Rails Module 6

Authentication and authorization interview questions

Interview questions on authentication and authorization: warm-ups, then what each harder question tests and how a good answer starts.

15 questions: 5 warm-ups and 10 with model answers · Levels: Fresher to senior

Warm-up questions

Short questions with short answers, each answered in full.

  1. Fresher

    What does User.authenticate_by(email_address:, password:) do that User.find_by(email_address:)&.authenticate(password) does not?

    Answered in the lesson The Rails 8 authentication generator

  2. Fresher to mid

    What is a passkey, in one sentence, and how is it different from a password?

    Answered in the lesson MFA, passkeys and social login

  3. Fresher to mid

    What is IDOR, and how does scoping queries prevent it?

    Answered in the lesson Authorization, roles and multi-tenancy

  4. Fresher to mid

    Why does attr_readonly :admin protect the admin flag better than relying only on strong parameters?

    Answered in the lesson Admin areas and audit trails

Questions with model answers

What each question tests, the first step of a good answer and the follow-ups to expect.

  1. Mid to senior

    The generated authentication keeps one Session row per browser and puts only its id in a signed cookie, instead of storing the whole session in the cookie. Why does a database-backed session suit sign-in, and when is a cookie-only session the wrong choice?

    What it tests
    Whether the candidate knows the trade-off between a cookie-only session and a server-side session record, and why revocation, a device list and 'log out everywhere' need the row.
    First step
    Contrast the two. A cookie-only session lives entirely in the browser and cannot be recalled once issued, while a row can be destroyed on the server. Sign-out, 'log out of all devices' and a device list all need something the server can delete, so name what each approach can and cannot do.
    Follow-ups

    From the lesson The Rails 8 authentication generator

    Model answer, Pro. Model answers open with any pass; prices are in the notice on this page.

    Opening the model answers with your pass…

    Model answers open with any MySmartCoPilot pass.

    • Pro pass · 1 week₹79$2.99
    • 30 days₹179$5.99
    • 1 year₹1,699$45

    One payment; a pass never renews. The price shown is the total you pay: no fees or charges are added at checkout.

    It also opens every other in-depth part in Learn and every Pro tool. Sales are final, except where the law gives you a right to withdraw, for example in the EU and the UK (refund policy).

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 4 minutes
  2. Mid to senior

    Your team is starting a Rails 8.1 app. Argue for using the built-in authentication generator rather than a gem such as Devise or Rodauth, and say where that choice stops being the right one.

    What it tests
    Whether the candidate can weigh owning readable generated code against a gem's breadth, and name the features that tip the decision toward a gem.
    First step
    List what the generator already gives, sign-in, sign-out, a password reset, a rate limit and a timing-safe login, and what it omits, sign-up, email confirmation, OAuth, multi-factor and account lockout. The decision is about how much of that omitted list you would otherwise build and maintain yourself.
    Follow-ups

    From the lesson The Rails 8 authentication generator

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 4 minutes
  3. Mid to senior

    A guardian asks for a copy of their data, then asks for the account to be deleted. The export reads nine tables and comes to about 40 MB; the deletion touches fee receipts the accounts team must keep for years. Design both as jobs, and say how you would show each one finished.

    What it tests
    Moving slow multi-table work out of the request, making a job safe to repeat and to resume, deciding what a deletion keeps, and evidencing both to the person who asked.
    First step
    Split each request into a mark and a job: the controller writes a requested_at column and enqueues, so the browser is answered at once. Then decide each job's unit of work, what it records as it goes, and what a second delivery of the same job must do.
    Follow-ups

    From the lesson Sign-up, email verification and settings

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 6 minutes
  4. Mid to senior

    We lose TOTP seeds in a backup. An attacker who reads the backup can now do what, and how do you stop it?

    What it tests
    Explain the seed is the private key, encryption at rest, recovery codes as a fallback
    First step
    Recognise that the TOTP seed lets anyone generate valid codes for that user
    Follow-ups

    From the lesson MFA, passkeys and social login

    Model answer, Pro.

    In the answer:

    • Model answer
    • How Rails encrypts the column
    • Recovery codes as a fallback
    • Follow-ups
    • Common mistakes
    • Rubric
    • Variants
    • about 5 minutes
  5. Mid to senior

    OmniAuth 2.x starts provider login with POST. Why, and what does omniauth-rails_csrf_protection add?

    What it tests
    Explain login CSRF, the switch from GET to POST, and the Rails authenticity token check
    First step
    Describe the login-CSRF attack that a GET link enables
    Follow-ups

    From the lesson MFA, passkeys and social login

    Model answer, Pro.

    In the answer:

    • Model answer
    • Why POST stops the forged start
    • What omniauth-rails_csrf_protection adds
    • Follow-ups
    • Common mistakes
    • Rubric
    • Variants
    • about 5 minutes
  6. Mid to senior

    After a deploy, a teacher at Centre A can see Centre B's students by changing the id in the URL. What went wrong, and how do you fix it without taking the site offline?

    What it tests
    Identify missing scope as root cause, explain immediate mitigation, fix the query, add IDOR test
    First step
    Recognise that the controller is using Student.find(params[:id]) instead of current_account.students.find(params[:id])
    Follow-ups

    From the lesson Authorization, roles and multi-tenancy

    Model answer, Pro.

    In the answer:

    • Model answer
    • Immediate mitigation
    • The proper fix
    • Finding other controllers with the same bug
    • The test that would have caught this
    • Should you notify Centre B?
    • Follow-ups
    • Common mistakes
    • Rubric
    • about 3 minutes
  7. Mid to senior

    Your SaaS has 50 coaching centres today and expects 500 next year. You need per-tenant backups and cross-tenant analytics. Which tenancy design fits, and why?

    What it tests
    Evaluate shared schema against database-per-tenant, consider the trade-offs, recommend with reasoning
    First step
    Recognise that cross-tenant analytics rules out database-per-tenant because you would need to open every database
    Follow-ups

    From the lesson Authorization, roles and multi-tenancy

    Model answer, Pro.

    In the answer:

    • Model answer
    • Why shared schema fits
    • The discipline problem
    • What if strict isolation becomes a requirement?
    • Follow-ups
    • Common mistakes
    • Rubric
    • about 4 minutes
  8. Mid to senior

    A coaching SaaS has eight admin resources. Six are plain lists and forms; fee waivers and refunds need multi-step screens drawn by the design team, with an audit row for every step. The licence policy is MIT-only. Would you build the whole admin by hand, use Administrate for all of it, or mix the two, and why?

    What it tests
    Whether the candidate splits the admin by kind of resource instead of picking one tool, keeps one role check across Administrate's controllers and hand-built ones, and records each step of a flow as its own audit row
    First step
    Sort the eight resources into plain lists and forms versus drawn flows, weigh what each option costs for each group, then ask where the role check and the audit rows live when both kinds of controller share /admin
    Follow-ups

    From the lesson Admin areas and audit trails

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-ups
    • Common mistakes
    • Rubric
    • Variants
    • about 4 minutes
  9. Mid to senior

    A compliance review asks the team to log every change to fee waivers with the actor, the before and after, and the request id. Would you add paper_trail, or grow an AuditEvent model as the lesson did, and how would you handle personal data in the diff?

    What it tests
    Compare paper_trail's versions table with a hand-written AuditEvent, name the schema and growth cost of each, show how to keep names and emails out of the diff
    First step
    Picture the two tables (paper_trail versions vs AuditEvent rows) and ask what the audit must answer, then decide which schema fits
    Follow-ups

    From the lesson Admin areas and audit trails

    Model answer, Pro.

    In the answer:

    • Model answer
    • Personal data in the diff
    • Follow-ups
    • Common mistakes
    • Rubric
    • Variants
    • about 6 minutes

All Ruby on Rails interview questions · The Ruby on Rails track

Quick answers and tool search

Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.