| 第1行: |
第1行: |
| | + | == 认证方式配置 == |
| | | | |
| | + | 参考教程: https://www.yiichina.com/tutorial/812 |
| | + | |
| | + | <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> |
| | | | |
| | == yii2自定义异常页面 == | | == yii2自定义异常页面 == |