1. Go to this page and download the library: Download denits/yii-apiauth library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
denits / yii-apiauth example snippets
return array(
#...
'import' => array(
#...
'ext.apiAuth.components.*',
#...
),
#...
'components' => array(
#...
'apiAuth' => array(
'class' => 'ext.apiAuth.ApiAuth',
// Below are the Extensions configurable attributes, specified with their default values.
// The optional values can be left out of the configuration file (will get default values specified here)
//'realm' => 'Restricted Area', //optional
//'protocol' => 'digest', //optional: 'basic' or 'digest' (recommended)
//'hash' => null, //optional: empty or 'md5' (recommended. See comment on apiAuthPasswordAttribute)
// The name of your (api) user model (i.e.: this can be your front-end User model, or a custom Api User model)
'userClass' => 'User', //ssword verification.
// It's property MUST be availble in the user model. It can be left empty or unspecified
// in which case it will be set to the same value as 'passwordAttribute' when the extension is
// initialized.
//
// Please note that there are specific owing setting on it's default value.
// If you do override it, make sure you change it to a derived class of AUserIdentity.
//'userIdentityClass' => 'AUserIdentity', //optional
),
#...
),
#...
);
class YourController extends AController {
class Controller extends AController { //this would create an infinate extends loop.
class YourController extends AController { //note: AController extends Controller, so this should not break your existing configuration.
public function filters()
{
//Specify the ApiAuth filter to med before authentication ;)
//
//For example, to use Yii's access control as authorization scheme, change this to:
//
// return array('ApiAuth', 'accessControl');
return array('ApiAuth');
}
// Uncomment this method to specify Auth Rules on specific actions, verbs or IP's.
// When no rules are supplied or when this method is not specified, authentication will
// be );
}
*/
}
ANonce::cleanExpiredNonces();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.