add_hook($host::HOOK_AUTH_USER, $this); Config::add(self::AUTH_OIDC_POST_LOGOUT_URL, "", Config::T_STRING); if (Config::get(self::AUTH_OIDC_POST_LOGOUT_URL) != "") { $host->add_hook($host::HOOK_POST_LOGOUT, $this); } $this->host = $host; } function is_public_method($method) { return $method == "callback"; } function callback() { print "IN_CALLBACK"; die; } function authenticate($login, $password, $service = '') { $oidc = new OpenIDConnectClient('https://auth.fakecake.org', 'dev-debian-ttrss', 'Bu3vuCi0wBeQteJ7di4H6SKgqvYnpSludEP68SHu9wLekxXl'); if (!($_SESSION['uid'] ?? false)) { $oidc->setRedirectURL(Config::get_self_url()); try { $oidc->addScope(['openid', 'profile', 'email']); $oidc->authenticate(); $login = $oidc->requestUserInfo("preferred_username"); $user_id = $this->auto_create_user($login, $password); if ($user_id) { $name = $oidc->requestUserInfo("name"); if ($name) { $sth = $this->pdo->prepare("UPDATE ttrss_users SET full_name = ? WHERE id = ?"); $sth->execute([$name, $user_id]); } $email = $oidc->requestUserInfo("email"); if ($email) { $sth = $this->pdo->prepare("UPDATE ttrss_users SET email = ? WHERE id = ?"); $sth->execute([$email, $user_id]); } } return $user_id; } catch (Exception $e) { var_dump($e); die; } } return false; } function hook_post_logout($login, $user_id) { return [ Config::get(self::AUTH_OIDC_POST_LOGOUT_URL) ]; } function api_version() { return 2; } }