{"id":37014526,"url":"https://github.com/machaven/track-attempts","last_synced_at":"2026-01-14T01:26:58.663Z","repository":{"id":62521336,"uuid":"96040809","full_name":"machaven/track-attempts","owner":"machaven","description":"Track and limit any auth, OTP, or any other type of action","archived":false,"fork":false,"pushed_at":"2022-12-12T11:21:05.000Z","size":22,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-12-08T06:39:54.682Z","etag":null,"topics":["bruteforce","counter","increment","laravel","otp","php","protection","redis","tracking"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/machaven.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-02T18:11:13.000Z","updated_at":"2022-12-14T22:43:16.000Z","dependencies_parsed_at":"2023-01-27T18:31:18.900Z","dependency_job_id":null,"html_url":"https://github.com/machaven/track-attempts","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/machaven/track-attempts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/machaven%2Ftrack-attempts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/machaven%2Ftrack-attempts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/machaven%2Ftrack-attempts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/machaven%2Ftrack-attempts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/machaven","download_url":"https://codeload.github.com/machaven/track-attempts/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/machaven%2Ftrack-attempts/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28407738,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T00:40:43.272Z","status":"ssl_error","status_checked_at":"2026-01-14T00:40:42.636Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bruteforce","counter","increment","laravel","otp","php","protection","redis","tracking"],"created_at":"2026-01-14T01:26:58.159Z","updated_at":"2026-01-14T01:26:58.663Z","avatar_url":"https://github.com/machaven.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Track Attempts Library\n=========================\n\nA handy library to track any type of action and limit the amount of attempts made in a period of time frame.\n\nUseful things to track and limit:\n\n* Login attempts.\n* One Time Pin (OTP) attempts.\n* Any thing else you want to limit or monitor.\n\nFeatures\n--------\n\n* Track on any metric you want, like email, username, etc.\n* Configurable limits.\n* Multiple backend drivers:\n    - Redis (Predis Client)\n    - Laravel (Cache Facade)\n\nInstall\n--------\nIf using with the Laravel Drivers:\n\nUse tags for version 1.x when used with Laravel version less than 5.8\n\n```composer require machaven/track-attempts:^1.0```\n\nUse tags for version 2.x when used with Laravel version 5.8+\n\n```composer require machaven/track-attempts:^2.0```\n\nIf used with predis driver:\n\n```composer require machaven/track-attempts:^2.0```\n\n\nClass Configuration\n--------\nMinimum Configuration\n```\n$config = ['driver' =\u003e 'predis', userIdentifier' =\u003e $username];\n$attempts = (new \\Machaven\\TrackAttempts\\TrackAttempts($config))-\u003egetDriver();\n\n```\nFull Configuration\n```\n$config = [\n    'driver' =\u003e 'predis', // Driver to use ('predis' or 'laravel')\n    'userIdentifier' =\u003e $username, // A variable with a unique identifier for the session/user\n    'maxAttempts' =\u003e 3, // Max attempts limit\n    'systemName' =\u003e 'my-website', // System Identifier used in cache key prefix.\n    'ttlInMinutes' =\u003e 5, // Keep track of attempts in a five minute period.\n    'actionName' =\u003e 'login', // The name of the action you are tracking.\n    ];\n$attempts = (new \\Machaven\\TrackAttempts\\TrackAttempts($config))-\u003egetDriver();\n```\n\nThe configuration above will create a key named: my-website:login:$username.\n\nPredis Driver Configuration\n--------\nThe predis driver requires redis settings to be configured in a .env file in your project root folder.\n\nExample .env:\n```\nREDIS_SCHEME=tcp\nREDIS_HOST=localhost\nREDIS_PASSWORD=\nREDIS_PORT=6379\nREDIS_DB=0\nREDIS_PROFILE=3.2\n``` \n\nUsage\n--------\n\nKeeping count\n```\n\u003e\u003e\u003e $attempts-\u003eincrement();\n=\u003e true\n```\n\nGetting the count\n```\n\u003e\u003e\u003e $attempts-\u003egetCount();\n=\u003e 1\n```\n\nChecking if the limit is reached\n```\n\u003e\u003e\u003e $attempts-\u003eisLimitReached();\n=\u003e false\n```\n\nClearing all attempts\n```\n\u003e\u003e\u003e $attempts-\u003eclear();\n=\u003e true\n```\n\nChecking the time left before the count expires (in seconds)\n```\n\u003e\u003e\u003e $attempts-\u003egetTimeUntilExpired();\n=\u003e 188\n```\n\nIncrementing attempts\n```\n\u003e\u003e\u003e $attempts-\u003eincrement();\n```\n\nUsing increment to track and check (example of max limit of 3 attempts)\n```\n\u003e\u003e\u003e $attempts-\u003eincrementAndCheckLimit();\n=\u003e true\n\u003e\u003e\u003e $attempts-\u003eincrementAndCheckLimit();\n=\u003e true\n\u003e\u003e\u003e $attempts-\u003eincrementAndCheckLimit();\n=\u003e true\n\u003e\u003e\u003e $attempts-\u003eincrementAndCheckLimit();\n=\u003e false\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmachaven%2Ftrack-attempts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmachaven%2Ftrack-attempts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmachaven%2Ftrack-attempts/lists"}