misd/raven-bundle
Composer 安装命令:
composer require misd/raven-bundle
包简介
Adds Raven authentication to your Symfony2 application
README 文档
README
This bundle contains a Symfony2 authentication provider so that users can log in to a Symfony2 application through Raven, the University of Cambridge's central authentication service.
It also contains a user provider, which can allow any user authenticating through Raven access to your application.
Authors
- Chris Wilkinson chris.wilkinson@admin.cam.ac.uk
The bundle uses code based on the UcamWebauth PHP class.
Requirements
Installation
-
Add the bundle to your dependencies:
// composer.json { // ... "require": { // ... "misd/raven-bundle": "~1.0" } } -
Use Composer to download and install the bundle:
$ php composer.phar update misd/raven-bundle -
Register the bundle in your application:
// app/AppKernel.php class AppKernel extends Kernel { // ... public function registerBundles() { $bundles = array( // ... new Misd\RavenBundle\MisdRavenBundle(), // ... ); } // ... }
Configuration
Firewall
To enable Raven authentication, add raven: true to a firewall configuration:
// app/config/security.yml
security:
firewalls:
raven_secured:
pattern: ^/secure/.*
raven: true
User provision
Normal Symfony2 user providers can be used, as long as the username is the user's CRSid.
If you would like any user who has successfully authenticated with Raven to access your application, you can use the bundle's Raven user provider:
// app/config/security.yml
security:
providers:
raven:
id: raven.user_provider
The user provider returns an instance of Misd\RavenBundle\Security\User\RavenUser with the role ROLE_USER.
This can be chained with other providers to grant certain users extra roles. For example:
// app/config/security.yml
security:
providers:
chain_provider:
chain:
providers: [in_memory, raven]
in_memory:
memory:
users:
abc123: { roles: [ 'ROLE_ADMIN' ] }
raven:
id: raven.user_provider
Resource description
You can add the name of your application to the Raven log in page:
// app/config/config.yml
misd_raven:
description: "My application"
The text on the page will now include something like "This resource calls itself 'My application' and is ...".
Test Raven service
During development, especially when not on the University network, it is sometimes necessary to use the test Raven Service. You can use this instead of the live service:
// app/config/config_dev.yml
misd_raven:
use_test_service: true
The test Raven service must not be used in production: it might compromise your application. Keep it to config_dev.yml!
Exceptions
The bundle can throw various exceptions. To catch them, set up event listeners and implement your logic (display a message, redirect to another page etc).
Misd\RavenBundle\Exception\AuthenticationCancelledException
This is thrown if the user clicks 'cancel' on the Raven log in screen.
Symfony\Component\Security\Core\Exception\UsernameNotFoundException
This is thrown if the user is not provisioned. If you're using the Raven user provider, this will never been seen.
Misd\RavenBundle\Exception\RavenException
This is thrown if something has gone wrong with either the bundle or Raven itself. As this is an exceptional state, you probably won't need to catch it (and let the 500 Internal Server Error be returned). It has the following sub-types:
Misd\RavenBundle\Exception\LoginTimedOutException: If the Raven response is older than 30 seconds.
Misd\RavenBundle\Exception\OpenSslException
This is thrown if there is an OpenSSL problem.
Events
To listen for events that the bundle issues, create a normal event subscriber service:
<service id="%my_listener.id%" class="%my_listener.class%">
<tag name="kernel.event_listener" event="%raven_event%" method="%my_listener.method%"/>
</service>
The bundle issues the following events:
raven.redirect
The Misd\RavenBundle\Event\RedirectEvent object contains the parameters given to Raven when the user is redirected to the login page. You could, for example, add the msg parameter.
raven.login
The Symfony\Component\Security\Http\Event\InteractiveLoginEvent object contains the request and the authentication token following a successful Raven login.
misd/raven-bundle 适用场景与选型建议
misd/raven-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.61k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2012 年 10 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「Authentication」 「bundle」 「University of Cambridge」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 misd/raven-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 misd/raven-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 misd/raven-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Automatically logs-in users if they are already authenticated by a remote source. (e.g. environment variable REMOTE_USER)
2lenet/EasyAdminPlusBundle
GraphQL authentication for your headless Craft CMS applications.
Rinvex Universities is a simple and lightweight package for retrieving university details with flexibility. A whole bunch of data including name, country, state, email, website, telephone, address, and much more attributes for the 17k+ known universities worldwide at your fingertips.
The bundle for easy using json-rpc api on your project
Provide a way to secure accesses to all routes of an symfony application.
统计信息
- 总下载量: 2.61k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2012-10-08