Git Komut Rehberi & Terminal Asistanı
Sıfırdan Yeni Bir Depo Başlatın:
Mevcut Bir Git Deposu veya Klasörü Gönderin:
Hataları Geri Alma, İptal & Temizlik:
Son commit'i geri al (yapılan değişiklikleri korur):
git reset --soft HEAD~1
Yapılan yerel değişiklikleri iptal et (çalışma ağacını temizler):
git restore .
Takip edilmeyen gereksiz dosyaları sil:
git clean -fd
Değişiklikleri geçici sakla ve geri getir (stash):
git stash git stash pop
Dal (Branch) ve Sürüm Etiketleri:
Yeni dal aç ve geçiş yap:
git checkout -b yeni-ozellik git push -u origin yeni-ozellik
Sürüm etiketi (tag) oluştur ve gönder:
git tag -a v1.0.0 -m "Sürüm 1.0.0" git push origin --tags
release: SnapCAD Studio 1.0.10 (desktop menuler, macOS kisayollari, YakNet SSO)
Build and Push Docker Images / build (push) Canceled after 0s
Desktop Release / Build linux desktop (push) Canceled after 0s
Desktop Release / Build windows desktop (push) Canceled after 0s
Desktop Release / Attach packages to release (push) Canceled after 0s
Desktop Release / Build macos desktop (push) Canceled after 0s
CI / Typecheck and unit tests (push) Canceled after 0s
Build and Push Docker Images / build (push) Canceled after 0s
Desktop Release / Build linux desktop (push) Canceled after 0s
Desktop Release / Build windows desktop (push) Canceled after 0s
Desktop Release / Attach packages to release (push) Canceled after 0s
Desktop Release / Build macos desktop (push) Canceled after 0s
CI / Typecheck and unit tests (push) Canceled after 0s
This commit is contained in:
+51
-16
@@ -7,18 +7,46 @@ require_once __DIR__ . '/snap-config.php';
|
||||
|
||||
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
|
||||
|
||||
$desktopCtx = $_SESSION['oauth2_desktop'] ?? null;
|
||||
unset($_SESSION['oauth2_desktop']);
|
||||
|
||||
$desktopPort = 0;
|
||||
$desktopNonce = '';
|
||||
$desktopDevice = 'SnapCAD Masaüstü';
|
||||
if (
|
||||
is_array($desktopCtx)
|
||||
&& !empty($desktopCtx['port'])
|
||||
&& !empty($desktopCtx['nonce'])
|
||||
&& ((int)($desktopCtx['issued_at'] ?? 0) <= 0 || (time() - (int)$desktopCtx['issued_at']) <= 900)
|
||||
) {
|
||||
$candidatePort = (int)$desktopCtx['port'];
|
||||
$candidateNonce = strtolower(trim((string)$desktopCtx['nonce']));
|
||||
if ($candidatePort >= 1024 && $candidatePort <= 65535 && preg_match('/^[a-f0-9]{32,128}$/', $candidateNonce)) {
|
||||
$desktopPort = $candidatePort;
|
||||
$desktopNonce = $candidateNonce;
|
||||
$desktopDevice = (string)($desktopCtx['device'] ?? 'SnapCAD Masaüstü');
|
||||
}
|
||||
}
|
||||
|
||||
$redirectCallbackError = static function (string $message) use ($desktopPort, $desktopNonce): void {
|
||||
if ($desktopPort > 0 && $desktopNonce !== '') {
|
||||
header('Location: http://127.0.0.1:' . $desktopPort . '/oauth-callback?error=' . urlencode($message) . '&nonce=' . urlencode($desktopNonce));
|
||||
exit;
|
||||
}
|
||||
header('Location: /?oauth_error=' . urlencode($message));
|
||||
exit;
|
||||
};
|
||||
|
||||
if (isset($_GET['error'])) {
|
||||
$err = (string)($_GET['error_description'] ?? $_GET['error']);
|
||||
header('Location: /?oauth_error=' . urlencode($err));
|
||||
exit;
|
||||
$redirectCallbackError($err);
|
||||
}
|
||||
|
||||
$code = isset($_GET['code']) ? (string)$_GET['code'] : '';
|
||||
$state = isset($_GET['state']) ? (string)$_GET['state'] : '';
|
||||
|
||||
if ($code === '') {
|
||||
header('Location: /?oauth_error=' . urlencode('Yetkilendirme kodu (code) alınamadı.'));
|
||||
exit;
|
||||
$redirectCallbackError('Yetkilendirme kodu (code) alınamadı.');
|
||||
}
|
||||
|
||||
// State her zaman zorunludur; eksik veya eski state kabul edilmez.
|
||||
@@ -27,13 +55,11 @@ $issuedAt = (int)($_SESSION['oauth2state_issued_at'] ?? 0);
|
||||
unset($_SESSION['oauth2state'], $_SESSION['oauth2state_issued_at']);
|
||||
|
||||
if ($expectedState === '' || $state === '' || !hash_equals($expectedState, $state)) {
|
||||
header('Location: /?oauth_error=' . urlencode('Geçersiz OAuth state anahtarı. Lütfen tekrar deneyin.'));
|
||||
exit;
|
||||
$redirectCallbackError('Geçersiz OAuth state anahtarı. Lütfen tekrar deneyin.');
|
||||
}
|
||||
|
||||
if ($issuedAt > 0 && (time() - $issuedAt) > 600) {
|
||||
header('Location: /?oauth_error=' . urlencode('Giriş isteğinin süresi doldu. Lütfen tekrar deneyin.'));
|
||||
exit;
|
||||
$redirectCallbackError('Giriş isteğinin süresi doldu. Lütfen tekrar deneyin.');
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -54,8 +80,7 @@ try {
|
||||
$userAvatar = $raw['avatar'] ?? $raw['picture'] ?? null;
|
||||
|
||||
if ($userId <= 0) {
|
||||
header('Location: /?oauth_error=' . urlencode('Kullanıcı kimliği doğrulanamadı.'));
|
||||
exit;
|
||||
$redirectCallbackError('Kullanıcı kimliği doğrulanamadı.');
|
||||
}
|
||||
|
||||
// Oturum sabitleme saldırısını engellemek için giriş sonrası kimliği yenile.
|
||||
@@ -63,8 +88,7 @@ try {
|
||||
session_regenerate_id(true);
|
||||
}
|
||||
|
||||
$_SESSION['yaknet_token'] = $token->getToken();
|
||||
$_SESSION['yaknet_user'] = [
|
||||
$userRecord = [
|
||||
'id' => $userId,
|
||||
'name' => $userName,
|
||||
'email' => $userEmail,
|
||||
@@ -73,14 +97,25 @@ try {
|
||||
'synced_at' => date('Y-m-d H:i:s'),
|
||||
];
|
||||
|
||||
$_SESSION['yaknet_token'] = $token->getToken();
|
||||
$_SESSION['yaknet_user'] = $userRecord;
|
||||
|
||||
if ($desktopPort > 0 && $desktopNonce !== '') {
|
||||
$pdo = snapcad_get_pdo();
|
||||
if (!$pdo) {
|
||||
$redirectCallbackError('YakNet Bulut veritabanına ulaşılamadı.');
|
||||
}
|
||||
$exchangeCode = snapcad_create_desktop_exchange($pdo, $userRecord, $desktopNonce, $desktopDevice);
|
||||
header('Location: http://127.0.0.1:' . $desktopPort . '/oauth-callback?code=' . urlencode($exchangeCode) . '&nonce=' . urlencode($desktopNonce));
|
||||
exit;
|
||||
}
|
||||
|
||||
header('Location: /?cloud_login=1');
|
||||
exit;
|
||||
} catch (IdentityProviderException $e) {
|
||||
error_log('[SnapCAD OAuth] Sağlayıcı hatası: ' . $e->getMessage());
|
||||
header('Location: /?oauth_error=' . urlencode('YakNet kimlik doğrulaması başarısız oldu. Lütfen tekrar deneyin.'));
|
||||
exit;
|
||||
$redirectCallbackError('YakNet kimlik doğrulaması başarısız oldu. Lütfen tekrar deneyin.');
|
||||
} catch (Throwable $e) {
|
||||
error_log('[SnapCAD OAuth] Giriş hatası: ' . $e->getMessage());
|
||||
header('Location: /?oauth_error=' . urlencode('Giriş sırasında bir hata oluştu. Lütfen tekrar deneyin.'));
|
||||
exit;
|
||||
$redirectCallbackError('Giriş sırasında bir hata oluştu. Lütfen tekrar deneyin.');
|
||||
}
|
||||
Reference in New Issue
Block a user