BasicHttpAuthStatic ​
- Type
- Class
- Namespace
- craft\filters
- Inherits
- craft\filters\BasicHttpAuthStatic » yii\filters\auth\HttpBasicAuth » yii\filters\auth\AuthMethod » yii\base\ActionFilter » yii\base\Behavior » yii\base\BaseObject
- Implements
- yii\base\Configurable, yii\filters\auth\AuthInterface
- Uses traits
- craft\filters\BasicHttpAuthTrait, craft\filters\SiteFilterTrait
- Since
- 5.5.0
Filter for adding basic HTTP authentication with static credentials to site requests.
See also https://www.yiiframework.com/doc/api/2.0/yii-filters-auth-httpbasicauth
Public Properties ​
Property | Description |
---|---|
auth | callable, null – A PHP callable that will authenticate the user with the HTTP basic auth information. |
except | array – List of action IDs that this filter should not apply to. |
only | array – List of action IDs that this filter should apply to. |
optional | array – List of action IDs that this filter will be applied to, but auth failure will not lead to error. |
owner | yii\base\Component, null – The owner of this behavior |
password | |
realm | string – The HTTP authentication realm |
request | yii\web\Request, null – The current request. |
response | yii\web\Response, null – The response to be sent. |
site | integer, string, craft\models\Site, `(int |
user | yii\web\User, null – The user object representing the user authentication status. |
username |
password
​
- Default value
null
realm
​
- Type
- string
- Default value
null
The HTTP authentication realm
username
​
- Default value
null
Public Methods ​
Method | Description |
---|---|
__call() | Calls the named method which is not a class method. |
__construct() | Constructor. |
__get() | Returns the value of an object property. |
__isset() | Checks if a property is set, i.e. defined and not null. |
__set() | Sets value of an object property. |
__unset() | Sets an object property to null. |
afterAction() | This method is invoked right after an action is executed. |
afterFilter() | |
attach() | Attaches the behavior object to the component. |
authenticate() | Authenticates the current user. |
beforeAction() | This method is invoked right before an action is to be executed (after all possible filters.) You may override this method to do last-minute preparation for the action. |
beforeFilter() | |
canGetProperty() | Returns a value indicating whether a property can be read. |
canSetProperty() | Returns a value indicating whether a property can be set. |
challenge() | Generates challenges upon authentication failure. |
className() | Returns the fully qualified name of this class. |
detach() | Detaches the behavior object from the component. |
events() | Declares event handlers for the owner's events. |
handleFailure() | Handles authentication failure. |
hasMethod() | Returns a value indicating whether a method is defined. |
hasProperty() | Returns a value indicating whether a property is defined. |
init() | Initializes the object. |
__construct()
​
Constructor.
The default implementation does two things:
- Initializes the object with the given configuration
$config
. - Call init().
If this method is overridden in a child class, it is recommended that
- the last parameter of the constructor is a configuration array, like
$config
here. - call the parent implementation at the end of the constructor.
Arguments ​
$config
(array) – Name-value pairs that will be used to initialize the object properties
beforeAction()
​
This method is invoked right before an action is to be executed (after all possible filters.) You may override this method to do last-minute preparation for the action.
Arguments ​
$action
(yii\base\Action) – The action to be executed.
Returns ​
boolean – Whether the action should continue to be executed.
Protected Methods ​
Method | Description |
---|---|
getActionId() | Returns an action ID by converting yii\base\Action::$uniqueId into an ID relative to the module. |
isActive() | Returns a value indicating whether the filter is active for the given action. |
isOptional() | Checks, whether authentication is optional for the given action. |
setSite() |