How to add SSO authentication to a YII 1 project?

Hello everyone.
I need to add SSO authentication to the project on YII 1. I have little experience in YII((
I would appreciate any advice on this topic? Thanks!
Screenshot_108

Use OAuth2 / OpenID Connect (Recommended)

Best modern solution.

Flow:

  • Redirect user to SSO provider (Google, Keycloak, Azure AD, etc.)
  • Get authorization code
  • Exchange it for token
  • Fetch user info
  • Login user in Yii

Yii 1 simple flow idea:

public function actionLogin(){    $code = $_GET['code'] ?? null;    if (!$code) {        header("Location: https://sso-server.com/auth");        exit;    }    $token = $this->getAccessToken($code);    $userInfo = $this->getUserInfo($token);    $user = User::model()->findByAttributes([        'email' => $userInfo['email']    ]);    if (!$user) {        $user = new User();        $user->email = $userInfo['email'];        $user->save();    }    Yii::app()->user->id = $user->id;    $this->redirect(['site/index']);}