{"id":19039614,"url":"https://github.com/windwalker-io/windwalker-authenticate","last_synced_at":"2026-03-14T01:43:17.044Z","repository":{"id":21620599,"uuid":"24941055","full_name":"windwalker-io/windwalker-authenticate","owner":"windwalker-io","description":"[READ ONLY] Subtree split of Windwalker Framework","archived":false,"fork":false,"pushed_at":"2015-07-27T10:13:20.000Z","size":184,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-02T06:44:52.863Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/ventoviro/windwalker","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/windwalker-io.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-10-08T13:08:30.000Z","updated_at":"2024-12-16T07:27:21.000Z","dependencies_parsed_at":"2022-08-24T14:09:31.112Z","dependency_job_id":null,"html_url":"https://github.com/windwalker-io/windwalker-authenticate","commit_stats":null,"previous_names":["ventoviro/windwalker-authenticate"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windwalker-io%2Fwindwalker-authenticate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windwalker-io%2Fwindwalker-authenticate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windwalker-io%2Fwindwalker-authenticate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windwalker-io%2Fwindwalker-authenticate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/windwalker-io","download_url":"https://codeload.github.com/windwalker-io/windwalker-authenticate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240100117,"owners_count":19747632,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2024-11-08T22:17:54.907Z","updated_at":"2025-12-18T09:04:47.417Z","avatar_url":"https://github.com/windwalker-io.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Windwalker Authenticate\n\n## Installation via Composer\n\nAdd this to the require block in your `composer.json`.\n\n``` json\n{\n    \"require\": {\n        \"windwalker/authenticate\": \"~2.0\"\n    }\n}\n```\n\n## Getting Started\n\nThis is a simple login auth process.\n\n``` php\npublic function login($username, $password)\n{\n    $auth = new Authenticate;\n\n    // Attach methods\n    $auth-\u003eaddMethod(new LocalMethod);\n    $auth-\u003eaddMethod(new MyMethod);\n\n    $credential = new Credential;\n\n    $credential-\u003eusername = $username;\n    $credential-\u003epassword = $password;\n\n    // Do authenticate\n    $result = $auth-\u003eauthenticate($credential);\n\n    // False means login fail\n    if (!$result)\n    {\n        // Print results to know what happened\n        print_r($auth-\u003egetResults());\n\n        throw new Exception('Username or password not matched');\n    }\n\n    $user = $auth-\u003egetCredential();\n\n    return $user;\n}\n```\n\n## Create Custom Methods\n\n``` php\nuse Windwalker\\Authenticate\\Method\\AbstractMethod;\n\nclass MyMethod extends AbstractMethod\n{\n    public function authenticate(Credential $credential)\n    {\n        $username = $credential-\u003eusername;\n        $password = $credential-\u003epassword;\n\n        if (!$username || !$password)\n        {\n            $this-\u003estatus = Authenticate::EMPTY_CREDENTIAL;\n\n            return false;\n        }\n\n        $user = Database::loadOne(array('username' =\u003e $username));\n\n        if (!$user)\n        {\n            $this-\u003estatus = Authenticate::USER_NOT_FOUND;\n\n            return false;\n        }\n\n        if (!password_verify($password, $user-\u003epassword))\n        {\n            $this-\u003estatus = Authenticate::INVALID_CREDENTIAL;\n\n            return false;\n        }\n\n        // Success\n        $this-\u003estatus = Authenticate::SUCCESS;\n\n        // Set some data to Credential\n        $credential-\u003ebind($user);\n\n        unset($credential-\u003epassword);\n\n        return true;\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwindwalker-io%2Fwindwalker-authenticate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwindwalker-io%2Fwindwalker-authenticate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwindwalker-io%2Fwindwalker-authenticate/lists"}