作者:dshashko
项目:YiiTask
public function behaviors()
{
$behaviors = parent::behaviors();
$behaviors['contentNegotiator'] = ['class' => ContentNegotiator::className(), 'formats' => ['application\\json' => Response::FORMAT_JSON]];
$behaviors['authenticator'] = ['class' => QueryParamAuth::className()];
return $behaviors;
}
作者:navatec
项目:yii2-roxymc
/**
* {@inheritDoc}
*/
public function behaviors()
{
$behaviors = parent::behaviors();
$behaviors['contentNegotiator'] = ['class' => ContentNegotiator::className(), 'formats' => ['application/json' => Response::FORMAT_JSON]];
$behaviors['verbs'] = ['class' => VerbFilter::className(), 'actions' => ['*' => ['GET', 'AJAX'], 'file-upload' => ['POST', 'AJAX']]];
return $behaviors;
}
作者:pylype
项目:api-sid
/**
* @inheritdoc
*/
public function behaviors()
{
$behaviors = parent::behaviors();
$behaviors['rateLimiter'] = ['class' => RateLimiter::className(), 'enableRateLimitHeaders' => false];
$behaviors['contentNegotiator'] = ['class' => ContentNegotiator::className(), 'formats' => ['application/json' => Response::FORMAT_JSON]];
return $behaviors;
}
作者:engrashi
项目:librar
/**
* @inheritdoc
*/
public function behaviors()
{
$behaviors = parent::behaviors();
$behaviors['authenticator'] = ['class' => HttpBearerAuth::className(), 'only' => ['dashboard']];
$behaviors['contentNegotiator'] = ['class' => ContentNegotiator::className(), 'formats' => ['application/json' => Response::FORMAT_JSON]];
$behaviors['access'] = ['class' => AccessControl::className(), 'only' => ['dashboard'], 'rules' => [['actions' => ['dashboard'], 'allow' => true, 'roles' => ['@']]]];
return $behaviors;
}
作者:VictorGu
项目:yii2-swagge
public function behaviors()
{
// Options Request Behavior must going at first because swagger makes OPTIONS requests before POST
// and this behavior must run early than VerbsFilter
$behaviors = ['optionsRequestFilter' => OptionsRequestFilter::className()];
$behaviors = array_merge($behaviors, parent::behaviors(), ['contentNegotiator' => ['class' => ContentNegotiator::className(), 'formats' => ['application/json' => Response::FORMAT_JSON]], 'corsFilter' => Cors::className(), 'authenticator' => QueryParamAuthSwagger::className()]);
return $behaviors;
}
作者:netis-p
项目:yii2-cru
/**
* @inheritdoc
*/
public function behaviors()
{
// bootstrap the ContentNegotiatot behavior earlier to use detected format for authenticator
/** @var ContentNegotiator $contentNegotiator */
$contentNegotiator = Yii::createObject(['class' => ContentNegotiator::className(), 'formats' => ['text/html' => Response::FORMAT_HTML, 'application/json' => Response::FORMAT_JSON, 'application/xml' => Response::FORMAT_XML, 'text/csv' => Response::FORMAT_CSV, 'application/pdf' => Response::FORMAT_PDF, 'application/vnd.ms-excel' => Response::FORMAT_XLS]]);
$contentNegotiator->negotiate();
return array_merge(parent::behaviors(), ['contentNegotiator' => $contentNegotiator, 'authenticator' => ['class' => \yii\filters\auth\CompositeAuth::className(), 'authMethods' => !Yii::$app->user->getIsGuest() || Yii::$app->response->format === Response::FORMAT_HTML ? [] : [\yii\filters\auth\HttpBasicAuth::className(), \yii\filters\auth\QueryParamAuth::className()]], 'rateLimiter' => ['class' => \yii\filters\RateLimiter::className(), 'user' => Yii::$app->user->getIdentity()], 'access' => ['class' => AccessControl::className(), 'rules' => [['allow' => true, 'roles' => ['@']]]], 'menu' => ['class' => ActiveNavigation::className()]]);
}
作者:shi
项目:yii-ap
public function behaviors()
{
$behaviors = parent::behaviors();
$behaviors['authenticator'] = ['class' => HttpBasicAuth::className(), 'auth' => [$this, 'auth'], 'only' => ['create', 'update', 'delete']];
$behaviors['contentNegotiator'] = ['class' => ContentNegotiator::className(), 'formats' => ['application/json' => Response::FORMAT_JSON, 'application/xml' => Response::FORMAT_XML]];
$behaviors['access'] = ['class' => AccessControl::className(), 'ruleConfig' => ['class' => AccessRule::className()], 'only' => ['create', 'update', 'delete'], 'rules' => [['allow' => true, 'actions' => ['create', 'update'], 'roles' => [User::ROLE_ADMIN, User::ROLE_USER]], ['allow' => true, 'actions' => ['delete'], 'roles' => [User::ROLE_ADMIN]]]];
$behaviors['verbs'] = ['class' => VerbFilter::className(), 'actions' => ['search-airport' => ['post', 'get']]];
return $behaviors;
}
作者:rowas
项目:yii2oauthserve
public function behaviors()
{
$public_actions = isset(Yii::$app->params["public-actions"]) ? Yii::$app->params["public-actions"] : [];
$behaviors = parent::behaviors();
if (isset($public_actions[$this->className()])) {
$this->public_actions = array_merge($this->public_actions, $public_actions[$this->className()]);
}
$behaviors['OAuth'] = ['class' => OAuthBearerFilter::className(), 'except' => $this->public_actions];
return array_merge($behaviors, ['contentNegotiator' => ['class' => ContentNegotiator::className(), 'formats' => ['application/json' => Response::FORMAT_JSON]]]);
}
作者:adem-tea
项目:advance
public function behaviors()
{
return ArrayHelper::merge(parent::behaviors(), ['access' => ['class' => AccessControl::className(), 'rules' => [['actions' => ['login', 'error'], 'allow' => true], ['actions' => ['logout', 'index'], 'allow' => true, 'roles' => ['@']]]], 'verbs' => ['class' => VerbFilter::className(), 'actions' => ['delete' => ['post']]], 'bootstrap' => ['class' => ContentNegotiator::className(), 'formats' => ['application/json' => Response::FORMAT_JSON, 'charset' => 'UTF-8'], 'languages' => ['en', 'de']]]);
/*
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
];
*/
}
作者:rhosocia
项目:rho.socia
public function behaviors()
{
return ['contentNegotiator' => ['class' => ContentNegotiator::className(), 'formats' => ['text/html' => Response::FORMAT_JSON]], 'access' => ['class' => AccessControl::className(), 'rules' => [['allow' => true, 'actions' => ['get', 'widget-get'], 'matchCallback' => function ($rule, $action) {
$this->checkCsrfToken();
$this->checkIdentity();
$this->checkUserRelation(Yii::$app->request->post('id'));
return true;
}], ['allow' => true, 'actions' => ['list', 'widget-list', 'page-count'], 'matchCallback' => function ($rule, $action) {
$this->checkCsrfToken();
$this->checkIdentity();
return true;
}]], 'denyCallback' => function ($rule, $action) {
throw new ForbiddenHttpException('Access Denied.');
}], 'verbs' => ['class' => VerbFilter::className(), 'actions' => ['get' => ['post'], 'widget-get' => ['post'], 'list' => ['post'], 'widget-list' => ['post'], 'page-count' => ['post']]]];
}
作者:gitter-badge
项目:luy
public function behaviors()
{
// get the parent behaviors to overwrite
$behaviors = parent::behaviors();
if (!$this->getUserAuthClass()) {
unset($behaviors['authenticator']);
unset($behaviors['rateLimiter']);
} else {
// change to admin user auth class
$behaviors['authenticator'] = ['class' => \yii\filters\auth\CompositeAuth::className(), 'user' => $this->getUserAuthClass(), 'authMethods' => [\yii\filters\auth\QueryParamAuth::className(), \yii\filters\auth\HttpBearerAuth::className()]];
// change to admin rate limiter
$behaviors['rateLimiter'] = ['class' => \yii\filters\RateLimiter::className(), 'user' => $this->getUserAuthClass()];
}
$behaviors['contentNegotiator'] = ['class' => \yii\filters\ContentNegotiator::className(), 'formats' => ['application/json' => \yii\web\Response::FORMAT_JSON, 'application/xml' => \yii\web\Response::FORMAT_XML]];
return $behaviors;
}
作者:EuresTool
项目:eVote-we
public function behaviors()
{
$behaviors = parent::behaviors();
//set response header to application/json only
$behaviors['contentNegotiator'] = ['class' => ContentNegotiator::className(), 'formats' => ['application/json' => Response::FORMAT_JSON]];
$behaviors['ipFilter'] = ['class' => IPFilter::className()];
$behaviors['tokenFilter'] = ['class' => TokenFilter::className()];
$behaviors['openPollFilter'] = ['class' => OpenPollFilter::className()];
// $behaviors['verbs'] = [
// 'class' => VerbFilter::className(),
// 'actions' => [
// 'submit' => ['get'],
// 'get' => ['get'],
// ],
// ];
return $behaviors;
}
作者:luyade
项目:luya-cor
/**
* Remove not used behaviors from parent behaviors.
*
* @return array The list of behvaiors.
*/
public function behaviors()
{
// get the parent behaviors to overwrite
$behaviors = parent::behaviors();
if (!$this->getUserAuthClass()) {
unset($behaviors['authenticator']);
} else {
// change to admin user auth class
$behaviors['authenticator'] = ['class' => CompositeAuth::className(), 'user' => $this->getUserAuthClass(), 'authMethods' => [QueryParamAuth::className(), HttpBearerAuth::className()]];
}
$behaviors['contentNegotiator'] = ['class' => ContentNegotiator::className(), 'formats' => ['application/json' => Response::FORMAT_JSON, 'application/xml' => Response::FORMAT_XML]];
// by default rate limiter behavior is removed as its not implememented.
if (isset($behaviors['rateLimiter'])) {
unset($behaviors['rateLimiter']);
}
return $behaviors;
}
作者:cyhalothri
项目:yiiflo
/**
* @inheritdoc
*/
public function behaviors()
{
return ['verb' => ['class' => 'yii\\filters\\VerbFilter', 'actions' => ['delete' => ['post']]], 'access' => ['class' => 'yii\\filters\\AccessControl', 'only' => ['upload', 'delete'], 'rules' => [['allow' => true, 'roles' => ['@']]]], 'negotiator' => ['class' => ContentNegotiator::className(), 'only' => ['upload', 'delete'], 'formats' => ['application/json' => Response::FORMAT_JSON]]];
}
作者:C12
项目:ap
public function behaviors()
{
return ArrayHelper::merge(parent::behaviors(), ['authenticator' => ['class' => CompositeAuth::className(), 'authMethods' => [['class' => HttpBearerAuth::className()], ['class' => QueryParamAuth::className(), 'tokenParam' => 'access-token']]], 'bootstrap' => ['class' => ContentNegotiator::className(), 'formats' => ['application/json' => Response::FORMAT_JSON]]]);
}
作者:Nosthertu
项目:S
public function behaviors()
{
return [['class' => ContentNegotiator::className(), 'formats' => ['application/json' => Response::FORMAT_JSON]]];
}
作者:C12
项目:advancedap
public function behaviors()
{
return ArrayHelper::merge(parent::behaviors(), ['authenticator' => ['class' => CompositeAuth::className(), 'authMethods' => [['class' => HttpBearerAuth::className()], ['class' => QueryParamAuth::className()]]], 'bootstrap' => ['class' => ContentNegotiator::className(), 'formats' => ['application/json' => Response::FORMAT_JSON, 'charset' => 'UTF-8'], 'languages' => ['en', 'de']], 'corsFilter' => ['class' => \yii\filters\Cors::className(), 'cors' => ['Origin' => ['http://lukisongroup.com', 'http://lukisongroup.int'], 'Access-Control-Request-Method' => ['POST', 'PUT', 'GET'], 'Access-Control-Request-Headers' => ['X-Wsse'], 'Access-Control-Allow-Credentials' => true, 'Access-Control-Max-Age' => 3600, 'Access-Control-Expose-Headers' => ['X-Pagination-Current-Page']]]]);
}
作者:adem-tea
项目:advance
public function behaviors()
{
return ArrayHelper::merge(parent::behaviors(), ['bootstrap' => ['class' => ContentNegotiator::className(), 'formats' => ['application/json' => Response::FORMAT_JSON, 'charset' => 'UTF-8'], 'languages' => ['en', 'de']]]);
}
作者:nisnake
项目:yii2-templat
public function behaviors()
{
return ['access' => ['class' => 'yii\\filters\\AccessControl', 'rules' => [['allow' => true, 'roles' => ['@']], ['allow' => false, 'roles' => ['?']]]], 'contentNegotiator' => ['class' => ContentNegotiator::className(), 'formats' => ['text/html' => Response::FORMAT_HTML, 'application/xhtml+xml' => Response::FORMAT_HTML, 'application/json' => Response::FORMAT_JSON, 'application/xml' => Response::FORMAT_XML]]];
}
作者:hiqde
项目:hiam-cor
/**
* {@inheritdoc}
*/
public function behaviors()
{
return ArrayHelper::merge(parent::behaviors(), ['contentNegotiator' => ['class' => ContentNegotiator::className(), 'only' => ['resource'], 'formats' => ['application/json' => Response::FORMAT_JSON]]]);
}