2.5 KiB
2.5 KiB
Manual VK ID OAuth 2.1 Smoke Test Guide
This guide describes how to perform an end-to-end manual verification of VK ID login without checking secrets into git or CI.
1. Prerequisites & Environment Setup
Create or update your local .env.local (never commit this file):
# VK ID Application Credentials (from https://dev.vk.com/admin)
VK_APP_ID="<your_vk_app_id>"
VK_CLIENT_SECRET="<your_vk_client_secret>"
# Canonical Application URLs
APP_BASE_URL="http://localhost:3000"
VK_REDIRECT_URI="http://localhost:3000/api/auth/vk/callback"
# Security Keys
AUTH_SECRET="<32_char_random_hex_for_session>"
TOKEN_ENCRYPTION_KEY="<32_char_random_hex_for_aes_gcm>"
# Storage Driver (memory or database)
STORAGE_DRIVER="memory"
In the VK Developer Console:
- Add
http://localhost:3000/api/auth/vk/callbackto the list of Authorized Redirect URIs. - Set Trusted Domain to
localhost:3000.
2. Step-by-Step Test Procedure
Step A: Start Server
npm run dev
Step B: Initiate OAuth Login
- Open
http://localhost:3000in your browser. - Click Войти через VK ID.
- Verify redirection to
https://id.vk.com/authorizewith:client_idmatchingVK_APP_IDredirect_urimatchingVK_REDIRECT_URIcode_challenge(S256 hash)code_challenge_method=s256state(unpredictable base64url string)
Step C: Complete Authorization
- Authorize the application on the VK screen.
- VK redirects to
http://localhost:3000/api/auth/vk/callback?code=...&state=.... - Check network and cookies:
- Response sets
randomayzer_sessioncookie (HttpOnly; SameSite=Lax). - Browser is redirected to
/(or specifiedredirectTarget). - Header displays the logged-in user's name and avatar.
- Response sets
Step D: Inspect Active Session
Visit http://localhost:3000/api/auth/me:
{
"authenticated": true,
"user": {
"id": "usr_...",
"vkUserId": "...",
"firstName": "...",
"lastName": "...",
"avatarUrl": "..."
}
}
Step E: Test Giveaway Creation & Scoped Listing
- Create a new giveaway via UI or
POST /api/giveaways. - Visit
GET /api/giveaways: observe that only giveaways created by this user are returned. - Open incognito window without cookie
\rightarrowGET /api/giveawaysreturns401 Unauthorized.
Step F: Test Logout
- Click Выйти in header (or
POST /api/auth/logout). - Verify
randomayzer_sessioncookie is cleared. - Verify
GET /api/auth/mereturns{"authenticated": false}.