{"id":30178418,"url":"https://github.com/webman-tech/auth","last_synced_at":"2025-08-12T05:20:53.450Z","repository":{"id":44903884,"uuid":"495451866","full_name":"webman-tech/auth","owner":"webman-tech","description":"webman auth plugin","archived":false,"fork":false,"pushed_at":"2025-07-15T02:30:39.000Z","size":73,"stargazers_count":13,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-15T07:02:03.589Z","etag":null,"topics":["auth","authentication","webman"],"latest_commit_sha":null,"homepage":"","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/webman-tech.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-05-23T14:44:43.000Z","updated_at":"2025-06-13T06:21:32.000Z","dependencies_parsed_at":"2025-06-05T04:27:41.092Z","dependency_job_id":"57cb3fe1-7f54-4f29-a684-72476ab769ca","html_url":"https://github.com/webman-tech/auth","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/webman-tech/auth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webman-tech%2Fauth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webman-tech%2Fauth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webman-tech%2Fauth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webman-tech%2Fauth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webman-tech","download_url":"https://codeload.github.com/webman-tech/auth/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webman-tech%2Fauth/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270005591,"owners_count":24510939,"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","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["auth","authentication","webman"],"created_at":"2025-08-12T05:20:50.885Z","updated_at":"2025-08-12T05:20:53.402Z","avatar_url":"https://github.com/webman-tech.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# webman-tech/auth\n\n本项目是从 [webman-tech/components-monorepo](https://github.com/orgs/webman-tech/components-monorepo) 自动 split 出来的，请勿直接修改\n\n\u003e 简介\n\nAuth plugin for webman\n\n提供高可扩展的认证授权插件，包含以下功能：\n\n- [x] 多用户认证: AuthManager 管理多 guard 实例\n- [x] 多认证方式\n  - [x] SessionMethod: session 认证\n  - [x] RequestMethod: 请求参数认证，token 放在 query 或 post 中\n  - [x] HttpHeaderMethod: 请求 Header 认证，token 放在 header 中\n  - [x] HttpAuthorizationMethod: 请求 Header 中的 Authorization 认证\n  - [x] HttpBasicMethod: 请求 Basic 认证\n  - [x] HttpBearerMethod: 请求 Bearer 认证\n  - [x] TinywanJwtMethod: 使用 [tinywan/jwt](https://github.com/Tinywan/webman-jwt) 进行 jwt 认证\n  - [x] CompositeMethod: 组合以上多种认证方式\n- [x] 多认证失败处理器\n  - [x] RedirectHandler: 重定向处理器\n  - [x] ResponseHandler: 响应 401 http status\n  - [x] ThrowExceptionHandler: 抛出 UnauthorizedException 异常\n    \n## 安装\n\n```bash\ncomposer require webman-tech/auth\n```\n\n## 配置\n\n详见： [auth.php](copy/config/plugin/auth.php)\n\n## 使用\n\n### 认证授权方法\n\n```php\nuse WebmanTech\\Auth\\Auth;\n\n$guard = Auth::guard(); // 获取默认的 guard\n$guard = Auth::guard('admin'); // 获取指定名称的 guard\n\n$guard-\u003elogin($user); // 用户登录\n$guard-\u003elogout(); // 用户退出登录\n$guard-\u003egetId(); // 获取当前登录用户的 id\n$guard-\u003egetUser(); // 获取当前登录用户的实例\n$guard-\u003eisGuest(); // 判断当前用户是否为游客\n```\n\n其他方法详见: [`GuardInterface`](src/Interfaces/GuardInterface.php)\n\n### 中间件\n\n- 全局切换 Guard: `WebmanTech\\Auth\\Middleware\\SetAuthGuard`\n- 认证授权: `WebmanTech\\Auth\\Middleware\\Authentication`\n\n## 扩展\n\n支持扩展以下接口：\n\n- 认证方式接口：[`AuthenticationMethodInterface`](src/Interfaces/AuthenticationMethodInterface.php)\n- 认证失败处理方式接口：[`AuthenticationFailureHandlerInterface`](src/Interfaces/AuthenticationFailureHandlerInterface.php)\n- Guard 接口：[`GuardInterface`](src/Interfaces/GuardInterface.php)\n\n## 例子\n\n多种用户体系（前端用户api接口，后端用户session）\n\n详见 [examples/multi-user](examples/multi-user)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebman-tech%2Fauth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebman-tech%2Fauth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebman-tech%2Fauth/lists"}