[ 'only' => ['complete'], ], 'access' => [ 'class' => AccessControl::class, 'only' => ['complete'], 'rules' => [ [ 'allow' => true, 'actions' => ['complete'], 'roles' => [P::COMPLETE_OAUTH_FLOW], 'roleParams' => fn(): array => [ 'accountId' => Yii::$app->user->identity->getAccount()->id, ], ], ], ], ]); } public function verbs(): array { return [ 'validate' => ['GET'], 'complete' => ['POST'], 'device' => ['POST'], 'token' => ['POST'], ]; } public function actionValidate(): array { return $this->oauthProcess->validate($this->getServerRequest()); } public function actionComplete(): array { return $this->oauthProcess->complete($this->getServerRequest()); } public function actionDevice(): array { return $this->oauthProcess->deviceCode($this->getServerRequest()); } public function actionToken(): array { return $this->oauthProcess->getToken($this->getServerRequest()); } private function getServerRequest(): ServerRequestInterface { $request = Yii::$app->request; return (new ServerRequest( $request->getMethod(), $request->getAbsoluteUrl() . '?' . $request->getQueryString(), $request->getHeaders()->toArray(), )) ->withParsedBody($request->getBodyParams()) ->withQueryParams($request->getQueryParams()); } }