更改
跳到导航
跳到搜索
←上一编辑
Yii2
(查看源代码)
2019年8月23日 (五) 11:36的版本
添加895字节
、
2019年8月23日 (五) 11:36
无编辑摘要
第1行:
第1行:
+
== 认证方式配置 ==
+
参考教程: https://www.yiichina.com/tutorial/812
−
yii2自定义异常页面
+
<nowiki>
+
public function behaviors()
+
{
+
$behaviors = parent::behaviors();
+
$behaviors['authenticator'] = [
+
//auth method 1
+
//'class' => HttpBasicAuth::className(),
+
//auth method 2
+
'class' => HttpBearerAuth::className(),
+
//auth method 3
+
//'class' => QueryParamAuth::className(),
+
//auth method 4 复合认证
+
'class' => CompositeAuth::className(),
+
'authMethods' => [
+
HttpBasicAuth::className(),
+
HttpBearerAuth::className(),
+
QueryParamAuth::className(),
+
],
+
'optional'=>['login'],// 不用认证的action, 配置的是action id。
+
];
+
return $behaviors;
+
}
+
</nowiki>
+
+
identityClass继承IdentityInterface,实现findIdentityByAccessToken等方法
+
+
==
yii2自定义异常页面
==
框架中异常是由yii\web\ErrorHandler类处理,所以继承他并重写(renderException)就好了。
框架中异常是由yii\web\ErrorHandler类处理,所以继承他并重写(renderException)就好了。
Yaosong
行政员
、
界面管理员
、
管理员
133
个编辑
导航菜单
个人工具
登录
名字空间
页面
讨论
变种
视图
阅读
查看源代码
查看历史
更多
搜索
导航
首页
最近更改
随机页面
MediaWiki帮助
工具
特殊页面
可打印版本