Update
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
<?
|
||||
<?php
|
||||
|
||||
use Bitrix\Main\Security\Random;
|
||||
|
||||
IncludeModuleLangFile(__FILE__);
|
||||
|
||||
class CSocServVKontakte extends CSocServAuth
|
||||
@@ -13,7 +16,7 @@ class CSocServVKontakte extends CSocServAuth
|
||||
return array(
|
||||
array("vkontakte_appid", GetMessage("socserv_vk_id"), "", Array("text", 40)),
|
||||
array("vkontakte_appsecret", GetMessage("socserv_vk_key"), "", Array("text", 40)),
|
||||
array("note" => GetMessage("socserv_vk_sett_note2", array('#URL#'=>$this->getEntityOAuth()->GetRedirectURI()))),
|
||||
array("note" => GetMessage("socserv_vk_sett_note2_MSGVER_1", array('#URL#'=>$this->getEntityOAuth()->GetRedirectURI()))),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -248,7 +251,7 @@ window.close();
|
||||
foreach ($res['response'] as $key => $contact)
|
||||
{
|
||||
$res['response'][$key]['name'] = $contact["first_name"];
|
||||
$res['response'][$key]['url'] = "https://vk.com/id" . $contact["id"];
|
||||
$res['response'][$key]['url'] = "https://vk.ru/id" . $contact["id"];
|
||||
$res['response'][$key]['picture'] = $contact['photo_200_orig'];
|
||||
}
|
||||
|
||||
@@ -278,7 +281,7 @@ window.close();
|
||||
|
||||
public function getProfileUrl($uid)
|
||||
{
|
||||
return "http://vk.com/id" . $uid;
|
||||
return "http://vk.ru/id" . $uid;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,14 +290,15 @@ class CVKontakteOAuthInterface extends CSocServOAuthTransport
|
||||
const SERVICE_ID = "VKontakte";
|
||||
|
||||
// https://vk.com/dev/constant_version_updates
|
||||
const AUTH_URL = "https://oauth.vk.com/authorize";
|
||||
const TOKEN_URL = "https://oauth.vk.com/access_token";
|
||||
const CONTACTS_URL = "https://api.vk.com/method/users.get";
|
||||
const FRIENDS_URL = "https://api.vk.com/method/friends.get";
|
||||
const MESSAGE_URL = "https://api.vk.com/method/messages.send";
|
||||
const APP_URL = "https://api.vk.com/method/apps.get";
|
||||
// https://vk.com/dev/versions
|
||||
const API_VERSION = "5.107";
|
||||
const AUTH_URL = "https://id.vk.ru/authorize";
|
||||
const TOKEN_URL = "https://id.vk.ru/oauth2/auth";
|
||||
const CONTACTS_URL = "https://api.vk.ru/method/users.get";
|
||||
const FRIENDS_URL = "https://api.vk.ru/method/friends.get";
|
||||
const MESSAGE_URL = "https://api.vk.ru/method/messages.send";
|
||||
const APP_URL = "https://api.vk.ru/method/apps.get";
|
||||
|
||||
// https://dev.vk.com/ru/reference/versions
|
||||
const API_VERSION = "5.199";
|
||||
|
||||
protected $userID = false;
|
||||
protected $userEmail = false;
|
||||
@@ -320,6 +324,36 @@ class CVKontakteOAuthInterface extends CSocServOAuthTransport
|
||||
parent::__construct($appID, $appSecret, $code);
|
||||
}
|
||||
|
||||
private function generateCodeVerifier(): string
|
||||
{
|
||||
return Random::getString(40);
|
||||
}
|
||||
|
||||
private function getCodeVerifier(): string
|
||||
{
|
||||
if(!isset($_SESSION["CODE_VERIFIER"]))
|
||||
{
|
||||
$this->setCodeVerifier();
|
||||
}
|
||||
|
||||
return $_SESSION["CODE_VERIFIER"];
|
||||
}
|
||||
|
||||
private function setCodeVerifier(): void
|
||||
{
|
||||
$_SESSION["CODE_VERIFIER"] = $this->generateCodeVerifier();
|
||||
}
|
||||
|
||||
private function getCodeChallenge(): string
|
||||
{
|
||||
return str_replace(
|
||||
['+', '/', '='],
|
||||
['-', '_', ''],
|
||||
base64_encode(hash('sha256', $this->getCodeVerifier(), true))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function GetRedirectURI()
|
||||
{
|
||||
return \CHTTP::URN2URI("/bitrix/tools/oauth/vkontakte.php");
|
||||
@@ -337,6 +371,8 @@ class CVKontakteOAuthInterface extends CSocServOAuthTransport
|
||||
"&redirect_uri=" . urlencode($redirect_uri) .
|
||||
"&scope=" . $this->getScopeEncode() .
|
||||
"&response_type=code" .
|
||||
"&code_challenge_method=S256" .
|
||||
"&code_challenge=" . urlencode($this->getCodeChallenge()) .
|
||||
($state <> '' ? '&state=' . urlencode($state) : '');
|
||||
}
|
||||
|
||||
@@ -356,10 +392,13 @@ class CVKontakteOAuthInterface extends CSocServOAuthTransport
|
||||
}
|
||||
|
||||
$query = array(
|
||||
"client_id" => $this->appID,
|
||||
"client_secret" => $this->appSecret,
|
||||
"code" => $this->code,
|
||||
"redirect_uri" => $redirect_uri,
|
||||
'grant_type' => 'authorization_code',
|
||||
'code' => $this->code,
|
||||
'code_verifier' => $this->getCodeVerifier(),
|
||||
'client_id' => $this->appID,
|
||||
'device_id' => $_REQUEST["device_id"],
|
||||
'redirect_uri' => $redirect_uri,
|
||||
'state' => $_REQUEST["state"],
|
||||
);
|
||||
|
||||
$h = new \Bitrix\Main\Web\HttpClient(array(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
$arModuleVersion = [
|
||||
'VERSION' => '25.0.0',
|
||||
'VERSION_DATE' => '2025-05-29 13:00:00'
|
||||
];
|
||||
'VERSION' => '25.0.100',
|
||||
'VERSION_DATE' => '2025-09-23 09:04:50'
|
||||
];
|
||||
@@ -1,8 +1,8 @@
|
||||
<?
|
||||
$MESS['socserv_vk_id'] = "Application ID:";
|
||||
$MESS['socserv_vk_key'] = "Protected Key:";
|
||||
$MESS['socserv_vk_note'] = "Use your VKontakte profile to log in.";
|
||||
$MESS['socserv_vk_note_intranet'] = "Log in using VKontakte account";
|
||||
$MESS['socserv_vk_sett_note'] = "To get the ID and the key, <a href=\"http://vk.com/editapp?act=create\">register the Vkontakte application (\"website\" type)</a>.";
|
||||
$MESS['socserv_vk_sett_note1'] = "To get the code, please <a href=\"http://vk.com/editapp?act=create\">register the VK app</a> as website app.<br />Use the URL <a href=\"#URL#\">#URL#</a> as the \"Trusted redirect URI\".";
|
||||
?>
|
||||
<?php
|
||||
$MESS["socserv_vk_id"] = "Application ID:";
|
||||
$MESS["socserv_vk_key"] = "Protected Key:";
|
||||
$MESS["socserv_vk_note"] = "Use your VKontakte profile to log in.";
|
||||
$MESS["socserv_vk_note_intranet"] = "Log in using VKontakte account";
|
||||
$MESS["socserv_vk_sett_note"] = "To get the ID and the key, <a href=\"http://vk.com/editapp?act=create\">register the Vkontakte application (\"website\" type)</a>.";
|
||||
$MESS["socserv_vk_sett_note1"] = "To get the code, please <a href=\"http://vk.com/editapp?act=create\">register the VK app</a> as website app.<br />Use the URL <a href=\"#URL#\">#URL#</a> as the \"Trusted redirect URI\".";
|
||||
$MESS["socserv_vk_sett_note2_MSGVER_1"] = "To get the ID and the key, <a href=\"https://id.vk.ru/about/business/go\">Register VK app for Web</a>.<br />Use <a href=\"#URL#\">#URL#</a> in the field\"Trusted redirect URL\".";
|
||||
|
||||
@@ -5,3 +5,4 @@ $MESS["socserv_vk_note"] = "Сайтқа кіру үшін VKontakte есепт
|
||||
$MESS["socserv_vk_note_intranet"] = "VKontakte аккаунтын пайдаланып кіру";
|
||||
$MESS["socserv_vk_sett_note"] = "Кодтарды алу үшін ВКонтакте (түрі \"Веб-сайт\")<a href=\"http://vk.com/editapp?act=create\">қосымшасын тіркеу</a> қажет.";
|
||||
$MESS["socserv_vk_sett_note1"] = "Кодтарды алу үшін <a href=\"http://vk.com/editapp?act=create\"></a> ВКонтакте (түрі \"веб-сайт\") қосымшасын тіркеу қажет.<br/> \"Сенімді redirect URI\" өрісінде <a href=\"#URL#\">#URL#</a> мәнін көрсетуге болады.";
|
||||
$MESS["socserv_vk_sett_note2_MSGVER_1"] = "Кодтарды алу үшін ВКонтакте (Web платформасы үшін) <a href=\"https://id.vk.ru/about/business/go\">қосымшасын тіркеу</a> қажет.<br />\"Сенімді redirect URL\" өрісінде <a href=\"#URL#\">#URL#</a> мәнін көрсетуге болады.";
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
$MESS['socserv_vk_sett_note1'] = "Для получения кодов необходимо <a href=\"http://vk.com/editapp?act=create\">зарегистрировать приложение</a> ВКонтакте (тип \"Веб-сайт\").<br />В поле \"Доверенный redirect URI\" можно указать значение <a href=\"#URL#\">#URL#</a>";
|
||||
$MESS['socserv_vk_sett_note2'] = "Для получения кодов необходимо <a href=\"https://id.vk.com/about/business/go\">зарегистрировать приложение</a> ВКонтакте (для платформы Web).<br />В поле \"Доверенный redirect URL\" можно указать значение <a href=\"#URL#\">#URL#</a>";
|
||||
$MESS['socserv_vk_sett_note2_MSGVER_1'] = "Для получения кодов необходимо <a href=\"https://id.vk.ru/about/business/go\">зарегистрировать приложение</a> ВКонтакте (для платформы Web).<br />В поле \"Доверенный redirect URL\" можно указать значение <a href=\"#URL#\">#URL#</a>";
|
||||
$MESS['socserv_vk_id'] = "ID приложения:";
|
||||
$MESS['socserv_vk_key'] = "Защищенный ключ:";
|
||||
$MESS['socserv_vk_note'] = "Используйте вашу учетную запись VKontakte для входа на сайт.";
|
||||
|
||||
Reference in New Issue
Block a user