<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/authenticate-by-prevent-timing-based-enumeration-of-users--a4a1u7zjq" -->

---
title: authenticate_by: Prevent timing-based enumeration of users.
description: The code in the post has a security problem related to response times, which can be exploited by an enumeration attack. Rails 7.1 introduced the...
canonical: https://daily.dev/posts/authenticate-by-prevent-timing-based-enumeration-of-users--a4a1u7zjq
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: authenticate_by: Prevent timing-based enumeration of users. | daily.dev
og:description: The code in the post has a security problem related to response times, which can be exploited by an enumeration attack. Rails 7.1 introduced the...
og:url: https://daily.dev/posts/authenticate-by-prevent-timing-based-enumeration-of-users--a4a1u7zjq
og:image: https://api.daily.dev/og/posts/a4A1u7zJq.png
og:image:alt: authenticate_by: Prevent timing-based enumeration of users.
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# authenticate_by: Prevent timing-based enumeration of users.

**[Ruby Flow](https://daily.dev/sources/rubyflow)** · 3 min read · 1 upvotes · 0 comments

## Summary

The code in the post has a security problem related to response times, which can be exploited by an enumeration attack. Rails 7.1 introduced the 'authenticate_by' method to prevent this type of attack. The method ensures consistent response times for both existing and non-existing user emails, improving web application security.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://a-chacon.com/en/ruby/rails/security/2024/04/18/authenticate-by-for-prevent-timing-based-enumeration-in-rails.html>

---

Tags: [#authentication](https://daily.dev/tags/authentication), [#rails](https://daily.dev/tags/rails), [#web-security](https://daily.dev/tags/web-security)

[View this post on daily.dev](https://daily.dev/posts/authenticate-by-prevent-timing-based-enumeration-of-users--a4a1u7zjq)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"authenticate_by: Prevent timing-based enumeration of users.","url":"https://daily.dev/posts/authenticate-by-prevent-timing-based-enumeration-of-users--a4a1u7zjq","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/authenticate-by-prevent-timing-based-enumeration-of-users--a4a1u7zjq"},"datePublished":"2024-04-19T07:12:56.177Z","dateModified":"2024-05-09T09:06:09.090Z","description":"The code in the post has a security problem related to response times, which can be exploited by an enumeration attack. Rails 7.1 introduced the...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/d11b1199a82c96954d6e40f871c5a21b?_a=AQAEufR","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/d11b1199a82c96954d6e40f871c5a21b?_a=AQAEufR","isAccessibleForFree":true,"articleSection":"Ruby Flow","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Ruby Flow","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/a21aaa8bcbbf448193a016895c90a0e1","url":"https://daily.dev/sources/rubyflow"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/authenticate-by-prevent-timing-based-enumeration-of-users--a4a1u7zjq","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"authentication,rails,web-security","timeRequired":"PT3M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Ruby Flow","item":"https://daily.dev/sources/rubyflow"},{"@type":"ListItem","position":3,"name":"authenticate_by: Prevent timing-based enumeration of users."}]}
```

