treehouselabs / swift-bundle
OpenStack Swift 协议的实现。可用于对象存储。
v1.0.0
2015-04-28 08:15 UTC
Requires
- php: >=5.5
- symfony/symfony: ~2.6
- treehouselabs/keystone-bundle: ~1.0
Requires (Dev)
- phpunit/phpunit: ~4.1
This package is auto-updated.
Last update: 2024-09-12 22:59:41 UTC
README
OpenStack Swift 协议的实现。可用于对象存储。
安装
添加依赖
composer require treehouselabs/swift-bundle:~1.0
启用包(KeystoneBundle 是此包的依赖项)
$bundles[] = new TreeHouse\KeystoneBundle\TreeHouseKeystoneBundle(); $bundles[] = new TreeHouse\SwiftBundle\TreeHouseSwiftBundle();
配置
如果您尚未这样做,请配置 KeystoneBundle。有关更多信息,请参阅该包的文档。然后向 Swift 配置中添加对象存储。
# app/config/config.yml tree_house_keystone: user_class: Acme\DemoBundle\Entity\User services: cdn: type: object-store endpoint: http://cdn.acme.org/ tree_house_swift: stores: cdn: tree_house.keystone.service.cdn
启用路由
# app/config/routing.yml cdn: resource: @TreeHouseSwiftBundle/Resources/config/routing.yml host: cdn.acme.org
默认情况下,所有路由都使用 ROLE_USER
表达式进行保护,但 head_object
和 get_object
路由除外。如果您想为每个单独的路由覆盖此表达式,或者您可以在配置中设置默认表达式。
# app/config/config.yml tree_house_swift: expression: ROLE_CDN_USER
如果您想使用基于令牌的认证,请为对象存储配置防火墙。包不会自动执行此操作,您必须自己配置。幸运的是,这很容易完成。
# app/config/security.yml security: firewalls: cdn: pattern: ^/ host: cdn.acme.org anonymous: true stateless: true simple_preauth: authenticator: tree_house.keystone.token_authenticator
就这样,现在所有对象存储请求都将尝试使用令牌进行认证。通过将防火墙设置为允许匿名用户,我们确保您不需要认证即可请求对象(这有点像是对象存储的目的)。