{"id":15287374,"url":"https://github.com/chrisyue/dark-portal-bundle","last_synced_at":"2025-07-25T22:42:24.756Z","repository":{"id":33720851,"uuid":"37374809","full_name":"chrisyue/dark-portal-bundle","owner":"chrisyue","description":"如果OAuth2.0用户账号提供商无法设置多redirect_uri host，比如微信，此bundle适合你","archived":false,"fork":false,"pushed_at":"2016-10-25T11:00:59.000Z","size":15,"stargazers_count":9,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-13T05:08:47.164Z","etag":null,"topics":["bundle","php","symfony","symfony-bundle"],"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/chrisyue.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":"Security/Core/Authentication/Provider/OAuthCodeProvider.php","support":null}},"created_at":"2015-06-13T14:39:31.000Z","updated_at":"2021-01-04T09:54:32.000Z","dependencies_parsed_at":"2022-08-28T17:20:30.513Z","dependency_job_id":null,"html_url":"https://github.com/chrisyue/dark-portal-bundle","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisyue%2Fdark-portal-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisyue%2Fdark-portal-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisyue%2Fdark-portal-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisyue%2Fdark-portal-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chrisyue","download_url":"https://codeload.github.com/chrisyue/dark-portal-bundle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248665747,"owners_count":21142123,"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":["bundle","php","symfony","symfony-bundle"],"created_at":"2024-09-30T15:27:58.541Z","updated_at":"2025-04-13T05:08:59.531Z","avatar_url":"https://github.com/chrisyue.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"OAuth 2.0 登录助手\n==================\n\n某些OAuth2.0用户提供商，可能要求只能设置一个redirect_uri host，但是你却想使用多个redirect_uri host，如果是这种情况，此库适合你。\n\n原理\n----\n\n在用户登录时，分为获取code和获取access token两个步骤。\n\n只有在获取code步骤，公众号设置的redirect_uri才用作用（限制使用公众号的域名的作用）\n\n而获取access token 阶段完全没有此限制，直接使用code获取就行了\n\n使用方式\n--------\n\n```\n$ composer require chrisyue/dark-portal-bundle:dev-master\n```\n\n然后在`AppKernel`里开启此Bundle你懂的\n\n设置security.yml文件：\n\n```\nproviders:\n    oauth:\n        id: chrisyue_dark_portal.security.user.provider\n\nfirewalls:\n    secured_area:\n        pattern: ^/\n        oauth_code:\n            appid: %your_appid%\n            secret: %your_secret%\n            scope: %your_scope%\n            code_endpoint: %your_code_endpoint% # 不着急，此字段意义见后面\n        provider: oauth\n```\n\n比如wechat.xxx.com和weixin.xxx.com都需要使用同一个微信公众账号登录，公众账号只能设置一个redirect_uri的域名。\n\n将一台服务器设置为专门的获取code的服务器，比如：oauth-code.xxx.com\n\n将get-code.php代码部署到服务器，部署前可设置能使用此服务的域名：\n\n```php\n$hosts = [\n    'wechat.xxx.com',\n    'weixin.xxx.com',\n];\n```\n\n假如部署后此脚本路径为`http://oauth-code.xxx.com/get-code.php`，那么`your_code_endpoint`参数的值就是它。\n\nTODO\n----\n\n* 单元测试\n* 不仅限于微信使用\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrisyue%2Fdark-portal-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchrisyue%2Fdark-portal-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrisyue%2Fdark-portal-bundle/lists"}