{"id":29111900,"url":"https://github.com/utopia-php/auth","last_synced_at":"2026-02-27T23:11:02.391Z","repository":{"id":281318576,"uuid":"944917245","full_name":"utopia-php/auth","owner":"utopia-php","description":"Lite \u0026 fast micro PHP auth library that is **easy to use**.","archived":false,"fork":false,"pushed_at":"2025-10-20T09:56:05.000Z","size":3215,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-22T14:21:33.377Z","etag":null,"topics":[],"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/utopia-php.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-03-08T08:23:23.000Z","updated_at":"2025-09-18T20:17:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"686b51e9-4bda-4446-a509-458ef9801c62","html_url":"https://github.com/utopia-php/auth","commit_stats":null,"previous_names":["utopia-php/auth"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/utopia-php/auth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utopia-php%2Fauth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utopia-php%2Fauth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utopia-php%2Fauth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utopia-php%2Fauth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/utopia-php","download_url":"https://codeload.github.com/utopia-php/auth/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utopia-php%2Fauth/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29918973,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-27T19:37:42.220Z","status":"ssl_error","status_checked_at":"2026-02-27T19:37:41.463Z","response_time":57,"last_error":"SSL_read: 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":[],"created_at":"2025-06-29T10:02:16.300Z","updated_at":"2026-02-27T23:11:02.362Z","avatar_url":"https://github.com/utopia-php.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Utopia Auth\n\n[![Build Status](https://travis-ci.org/utopia-php/auth.svg?branch=master)](https://travis-ci.org/utopia-php/auth)\n![Total Downloads](https://img.shields.io/packagist/dt/utopia-php/auth.svg)\n[![Discord](https://img.shields.io/discord/564160730845151244?label=discord)](https://appwrite.io/discord)\n\nUtopia Auth library is a simple and lite library for handling authentication and authorization in PHP applications. This library provides a collection of secure hashing algorithms and authentication proofs for building robust authentication systems. This library is maintained by the [Appwrite team](https://appwrite.io).\n\nAlthough this library is part of the [Utopia Framework](https://github.com/utopia-php/framework) project it is dependency free and can be used as standalone with any other PHP project or framework.\n\n## Getting Started\n\nInstall using composer:\n```bash\ncomposer require utopia-php/auth\n```\n\n## System Requirements\n\nUtopia Framework requires PHP 8.0 or later. We recommend using the latest PHP version whenever possible.\n\n## Features\n\n### Supported Hashing Hashes\n\n- **Argon2** - Modern, secure, and recommended password hashing algorithm\n- **Bcrypt** - Well-established and secure password hashing\n- **Scrypt** - Memory-hard password hashing algorithm\n- **ScryptModified** - Modified version of Scrypt with additional features\n- **SHA** - Various SHA hash implementations\n- **PHPass** - Portable password hashing framework\n- **MD5** (Not recommended for passwords, legacy support only)\n\n## Usage\n\n### Data Store\n\n```php\n\u003c?php\n\nuse Utopia\\Auth\\Store;\n\n// Create a new store\n$store = new Store();\n\n// Set various types of data\n$store-\u003eset('userId', '12345')\n      -\u003eset('name', 'John Doe')\n      -\u003eset('isActive', true)\n      -\u003eset('preferences', ['theme' =\u003e 'dark', 'notifications' =\u003e true]);\n\n// Get values with optional defaults\n$userId = $store-\u003eget('userId');\n$missing = $store-\u003eget('missing', 'default value');\n\n// Encode store data to a base64 string\n$encoded = $store-\u003eencode();\n\n// Later, decode the string back into a store\n$newStore = new Store();\n$newStore-\u003edecode($encoded);\n\n// Access the decoded data\necho $newStore-\u003eget('name'); // Outputs: John Doe\n```\n\n### Password Hashing\n\n```php\n\u003c?php\n\nrequire_once __DIR__ . '/vendor/autoload.php';\n\nuse Utopia\\Auth\\Proofs\\Password;\nuse Utopia\\Auth\\Hashes\\Argon2;\nuse Utopia\\Auth\\Hashes\\Bcrypt;\n\n// Initialize password authentication with default algorithms\n$password = new Password();\n\n// Hash a password (uses Argon2 by default)\n$hash = $password-\u003ehash('user-password');\n\n// Verify the password\n$isValid = $password-\u003everify('user-password', $hash);\n\n// Use a specific algorithm with custom parameters\n$bcrypt = new Bcrypt();\n$bcrypt-\u003esetCost(12); // Increase cost factor for better security\n\n$password-\u003esetHash($bcrypt);\n$hash = $password-\u003ehash('user-password');\n```\n\n### Authentication Tokens\n\n```php\n\u003c?php\n\nuse Utopia\\Auth\\Proofs\\Token;\n\n// Generate secure authentication tokens\n$token = new Token(32); // 32 characters length\n$authToken = $token-\u003egenerate(); // Random token\n$hashedToken = $token-\u003ehash($authToken); // Store this in database\n\n// Later, verify the token\n$isValid = $token-\u003everify($authToken, $hashedToken);\n```\n\n### One-Time Codes\n\n```php\n\u003c?php\n\nuse Utopia\\Auth\\Proofs\\Code;\n\n// Generate verification codes (e.g., for 2FA)\n$code = new Code(6); // 6-digit code\n$verificationCode = $code-\u003egenerate();\n$hashedCode = $code-\u003ehash($verificationCode);\n\n// Verify the code\n$isValid = $code-\u003everify($verificationCode, $hashedCode);\n```\n\n### Human-Readable Phrases\n\n```php\n\u003c?php\n\nuse Utopia\\Auth\\Proofs\\Phrase;\n\n// Generate memorable authentication phrases\n$phrase = new Phrase();\n$authPhrase = $phrase-\u003egenerate(); // e.g., \"Brave cat\"\n$hashedPhrase = $phrase-\u003ehash($authPhrase);\n\n// Verify the phrase\n$isValid = $phrase-\u003everify($authPhrase, $hashedPhrase);\n```\n\n### Advanced Hash Configuration\n\n```php\n\u003c?php\n\nuse Utopia\\Auth\\Hashes\\Scrypt;\nuse Utopia\\Auth\\Hashes\\Argon2;\n\n// Configure Scrypt parameters\n$scrypt = new Scrypt();\n$scrypt\n    -\u003esetCpuCost(16)      // CPU/Memory cost parameter\n    -\u003esetMemoryCost(14)   // Memory cost parameter\n    -\u003esetParallelCost(2)  // Parallelization parameter\n    -\u003esetLength(64)       // Output length in bytes\n    -\u003esetSalt('randomsalt123'); // Custom salt\n\n// Configure Argon2 parameters\n$argon2 = new Argon2();\n$argon2\n    -\u003esetMemoryCost(65536)  // Memory cost in KiB\n    -\u003esetTimeCost(4)        // Number of iterations\n    -\u003esetThreads(3);        // Number of threads\n```\n\n## Tests\n\nTo run all unit tests, use the following Docker command:\n\n```bash\ndocker compose exec tests vendor/bin/phpunit --configuration phpunit.xml tests\n```\n\nTo run static code analysis, use the following Psalm command:\n\n```bash\ndocker compose exec tests vendor/bin/psalm --show-info=true\n```\n\n## Security\n\nWe take security seriously. If you discover any security-related issues, please email security@appwrite.io instead of using the issue tracker.\n\n## Contributing\n\nAll code contributions - including those of people having commit access - must go through a pull request and be approved by a core developer before being merged. This is to ensure a proper review of all the code.\n\nWe truly ❤️ pull requests! If you wish to help, you can learn more about how you can contribute to this project in the [contribution guide](CONTRIBUTING.md).\n\n## Copyright and license\n\nThe MIT License (MIT) [http://www.opensource.org/licenses/mit-license.php](http://www.opensource.org/licenses/mit-license.php) ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Futopia-php%2Fauth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Futopia-php%2Fauth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Futopia-php%2Fauth/lists"}