mirror of
https://github.com/elyby/accounts.git
synced 2025-01-16 00:32:52 +05:30
Интегрирован сбор метрик в oauth2 процесс
This commit is contained in:
parent
63db3adca9
commit
6ee40f3fcc
@ -87,6 +87,7 @@ class OauthProcess {
|
|||||||
*/
|
*/
|
||||||
public function complete(): array {
|
public function complete(): array {
|
||||||
try {
|
try {
|
||||||
|
Yii::$app->statsd->inc('oauth.complete.attempt');
|
||||||
$grant = $this->getAuthorizationCodeGrant();
|
$grant = $this->getAuthorizationCodeGrant();
|
||||||
$authParams = $grant->checkAuthorizeParams();
|
$authParams = $grant->checkAuthorizeParams();
|
||||||
$account = Yii::$app->user->identity->getAccount();
|
$account = Yii::$app->user->identity->getAccount();
|
||||||
@ -94,6 +95,7 @@ class OauthProcess {
|
|||||||
$clientModel = OauthClient::findOne($authParams->getClient()->getId());
|
$clientModel = OauthClient::findOne($authParams->getClient()->getId());
|
||||||
|
|
||||||
if (!$this->canAutoApprove($account, $clientModel, $authParams)) {
|
if (!$this->canAutoApprove($account, $clientModel, $authParams)) {
|
||||||
|
Yii::$app->statsd->inc('oauth.complete.approve_required');
|
||||||
$isAccept = Yii::$app->request->post('accept');
|
$isAccept = Yii::$app->request->post('accept');
|
||||||
if ($isAccept === null) {
|
if ($isAccept === null) {
|
||||||
throw new AcceptRequiredException();
|
throw new AcceptRequiredException();
|
||||||
@ -109,7 +111,12 @@ class OauthProcess {
|
|||||||
'success' => true,
|
'success' => true,
|
||||||
'redirectUri' => $redirectUri,
|
'redirectUri' => $redirectUri,
|
||||||
];
|
];
|
||||||
|
Yii::$app->statsd->inc('oauth.complete.success');
|
||||||
} catch (OAuthException $e) {
|
} catch (OAuthException $e) {
|
||||||
|
if (!$e instanceof AcceptRequiredException) {
|
||||||
|
Yii::$app->statsd->inc('oauth.complete.fail');
|
||||||
|
}
|
||||||
|
|
||||||
$response = $this->buildErrorResponse($e);
|
$response = $this->buildErrorResponse($e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,8 +146,11 @@ class OauthProcess {
|
|||||||
*/
|
*/
|
||||||
public function getToken(): array {
|
public function getToken(): array {
|
||||||
try {
|
try {
|
||||||
|
Yii::$app->statsd->inc('oauth.issueToken.attempt');
|
||||||
$response = $this->server->issueAccessToken();
|
$response = $this->server->issueAccessToken();
|
||||||
|
Yii::$app->statsd->inc('oauth.issueToken.success');
|
||||||
} catch (OAuthException $e) {
|
} catch (OAuthException $e) {
|
||||||
|
Yii::$app->statsd->inc('oauth.issueToken.fail');
|
||||||
Yii::$app->response->statusCode = $e->httpStatusCode;
|
Yii::$app->response->statusCode = $e->httpStatusCode;
|
||||||
$response = [
|
$response = [
|
||||||
'error' => $e->errorType,
|
'error' => $e->errorType,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user