aescarcha/oauth
Composer 安装命令:
composer require aescarcha/oauth
包简介
A bundle to wrap FOSOauthServerBundle and provide oauth to APIs
README 文档
README
Step 1: Download the Bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require aescarcha/oauth "~1"
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Step 2: Install Requirements
composer require friendsofsymfony/rest-bundle
composer require jms/serializer-bundle
composer require nelmio/api-doc-bundle
composer require friendsofsymfony/user-bundle
composer require aescarcha/user-bundle dev-master
composer require friendsofsymfony/oauth-server-bundle
Step 3: Enable the Bundle
Then, enable the bundle by adding it to the list of registered bundles
in the app/AppKernel.php file of your project:
<?php // app/AppKernel.php // ... class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new FOS\RestBundle\FOSRestBundle(), new JMS\SerializerBundle\JMSSerializerBundle(), new Nelmio\ApiDocBundle\NelmioApiDocBundle(), new FOS\UserBundle\FOSUserBundle(), new Aescarcha\UserBundle\AescarchaUserBundle(), new Aescarcha\OauthServerBundle\AescarchaOauthServerBundle(), ); // ... } // ... }
Step 4: Configure the Bundle
Enable the routes in app/config/routing.yml
NelmioApiDocBundle:
resource: "@NelmioApiDocBundle/Resources/config/routing.yml"
prefix: /api/doc
aescarcha_oauth_server:
resource: "@AescarchaOauthServerBundle/Resources/config/routing.yml"
prefix: /
Configure the bundles in app/config/config.yml
# app/config/config.yml
nelmio_api_doc: ~
fos_rest:
routing_loader:
default_format: json # All responses should be JSON formated
include_format: false # We do not include format in request, so that all responses
# will eventually be JSON formated
body_listener: # Decode full json bodies
decoders:
son: fos_rest.decoder.json
fos_user:
db_driver: orm
firewall_name: oauth_token # Seems to be used when registering user/reseting password,
# but since there is no "login", as so it seems to be useless in
# our particular context, but still required by "FOSUserBundle"
user_class: Aescarcha\UserBundle\Entity\User
fos_oauth_server:
db_driver: orm
client_class: Aescarcha\OauthServerBundle\Entity\Client
access_token_class: Aescarcha\OauthServerBundle\Entity\AccessToken
refresh_token_class: Aescarcha\OauthServerBundle\Entity\RefreshToken
auth_code_class: Aescarcha\OauthServerBundle\Entity\AuthCode
service:
user_provider: fos_user.user_manager # This property will be used when valid credentials are given to load the user upon access token creation
Add this to app/config/security.yml
security:
encoders:
FOS\UserBundle\Model\UserInterface: sha512
providers:
fos_userbundle:
id: fos_user.user_provider.username # fos_user.user_provider.username_email does not seem to work (OAuth-spec related ("username + password") ?)
firewalls:
oauth_token: # Everyone can access the access token URL.
pattern: ^/oauth/v2/token
security: false
Testing
To test this bundle, you need to download and enable the following bundles
"doctrine/doctrine-fixtures-bundle": "^2.3",
"liip/functional-test-bundle": "^1.6"
$bundles[] = new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle();
$bundles[] = new Liip\FunctionalTestBundle\LiipFunctionalTestBundle();
And I recommend using this config in config_test.yml to use sqlite
doctrine:
dbal:
default_connection: default
connections:
default:
driver: pdo_sqlite
path: %kernel.cache_dir%/test.db
liip_functional_test:
cache_sqlite_db: true
aescarcha/oauth 适用场景与选型建议
aescarcha/oauth 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 42 次下载、GitHub Stars 达 1, 最近一次更新时间为 2016 年 10 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「oauth」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 aescarcha/oauth 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 aescarcha/oauth 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 aescarcha/oauth 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
WeChat OAuth SDK
Ory-Hydra OAuth 2.0 Client Provider for The PHP League OAuth2-Client
Library for ORCID web services
The bundle for easy using json-rpc api on your project
A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.
Bundle Symfony DaplosBundle
统计信息
- 总下载量: 42
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-10-30