Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

login-control

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

login-control

  • 0.0.21
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Description

The Attempt here is to give more flexibility on multiple signup barriers, like captacha or 2fa. Based on the requests it gives you a decisive criteria of the barriers a user have to take for sign in. It stores a permanent cookie and a table for tracking requests for specific routes you track within a controller method.

its built for systems on higher security requirements, for users which have sign-in multiple times on same login.

Features

The RequestControlViewHelper.captcha_tag? delivers true if captcha is necessary and showed on a login form.

This decision is based on the status of failed login attempts, which is stored in rails-session-cookie.

For a user that had never a successfully login, captcha_tag? is always true. After first successful login, captcha_tag? is true if attempts are less than configured (default: 10) and last_attempt is older than config.x.login_control.retry_after_seconds

On localhost captcha is never required.

Installation

gem 'login-control'

run

$ bundle
$ rails g model login_control session_id:string login_name:string scope:string sign_in_success:integer attempts:integer last_attempt:datetime validate_captcha:boolean
$ rails db:migrate

initializer

require 'login_control_module'
require 'login_control_view_helper'

ApplicationHelper

include LoginControlViewHelper

Login Form

  - if captcha_tag?
    = hcaptcha xxx

Controller example for subclassed devise controller

class SessionsController < Devise::SessionsController

  include LoginControlModule

  def create
    notice_login_attempt
    if (captcha_validation? ? verify_hcaptcha(secret_key: ...) : true) && credentials-matched
      super
      notice_successful_login
    else
      redirect_to login_path, alert: 'captcha failed' 
    end
  end
end

Configs

config.x.login_control.attempts_allowed integer, default: 10

config.x.login_control.retry_after_seconds integer, default: 30 (seconds) # => if, after a failed login, within status :known, within attempts_allowed, within retry_after_seconds RequestControlViewHelper.captcha_tag? returns true

config.x.login_control.debug boolean, default: false only for production

FAQs

Package last updated on 16 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc