Skip to content

Commit b4ba21c

Browse files
committed
Docs
1 parent 28ab36f commit b4ba21c

File tree

1 file changed

+39
-3
lines changed

1 file changed

+39
-3
lines changed

README.md

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,42 @@ This template support 3 most used authentication. (Actually it's not me who make
6767
2. Query parameter: the access token is sent as a query parameter in the API URL, e.g., https://example.com/users?access-token=xxxxxxxx. Because most Web servers will keep query parameters in server logs, this approach should be mainly used to serve JSONP requests which cannot use HTTP headers to send access tokens.
6868
3. OAuth 2: the access token is obtained by the consumer from an authorization server and sent to the API server via HTTP Bearer Tokens, according to the OAuth2 protocol.
6969

70+
## Global Configuration of AuthMethods and RateLimiter
71+
This template provide global configuration to set your application supported authMethods. You can find global configuration from `app\config\params.php`. Set your supported authMethods and RateLimiter from this file.
72+
73+
```php
74+
return [
75+
'useHttpBasicAuth' => true,
76+
'useHttpBearerAuth' => true,
77+
'useQueryParamAuth' => true,
78+
'useRateLimiter' => false,
79+
];
80+
```
81+
82+
Example use in behaviors looks like this
83+
84+
```php
85+
use app\helpers\BehaviorsFromParamsHelper;
86+
use yii\rest\ActiveController;
87+
88+
class PostController extends ActiveController
89+
{
90+
public $modelClass = 'app\models\Post';
91+
92+
public function behaviors()
93+
{
94+
$behaviors = parent::behaviors();
95+
$behaviors = BehaviorsFromParamsHelper::behaviors($behaviors);
96+
// if you need other behaviors method use like this
97+
// $behaviors['otherMethods'] = $value;
98+
return $behaviors;
99+
}
100+
}
101+
```
102+
103+
### Ratelimiter
104+
To enable your ratelimiter configuration, please follow official guide from [Yii documentation](https://www.yiiframework.com/doc/guide/2.0/en/rest-rate-limiting).
105+
70106
## Auth Scenario
71107
This template already have basic endpoint that you can use to start your REST-API. Such as:
72108

@@ -92,9 +128,9 @@ Feel free to contribute if you have any idea.
92128
- [x] Rest API Template
93129
- [x] Login and signup in SiteController
94130
- [x] Example of versioning and Blog Scenario
95-
- [ ] Authentication Type from params
96-
- [ ] Rate Limiter from params
97-
- [ ] Change auth_key for every login
131+
- [x] Authentication Type from params
132+
- [x] Rate Limit from params
133+
- [x] Change auth_key for every login
98134
- [ ] Auth_key have expiration
99135
- [ ] each auth_key have application token
100136

0 commit comments

Comments
 (0)