Skip to content

Conversation

@naspirato
Copy link
Owner

No description provided.

- Introduced a new function to validate and normalize redirect URLs, ensuring only internal paths are allowed to prevent open redirect attacks.
- Updated the GitHub login route to save validated redirect URLs from query parameters.
- Enhanced the workflow trigger route to save relative paths for redirects when authentication is required.
- Added comprehensive tests for OAuth redirect URL validation and preservation of query parameters.
- Improved frontend to dynamically set the redirect URL for authentication links.
- Added a new active state for the primary button to indicate when a workflow can be run, improving user feedback.
- Updated CSS to define styles for the active button state, including hover effects.
- Modified JavaScript logic to manage the button's active state based on workflow permissions and conditions, ensuring accurate visual representation of button status.
@naspirato naspirato requested a review from Copilot December 1, 2025 17:03
@github-actions
Copy link

github-actions bot commented Dec 1, 2025

🚀 Quick Actions

🧪 Run Tests

Test Type Actions
All ▶ All ⚙️
Unit ▶ Unit ⚙️
Integration ▶ Integration ⚙️

📦 Backport

Branch Actions
release/v1.0 ▶ Backport ⚙️
release/v2.0 ▶ Backport ⚙️
stable ▶ Backport ⚙️

Choose branches to backport manually:

⚙️ 📦 Backport (Custom)

▶ - immediately runs the workflow with default parameters.

⚙️ - opens UI to review and modify parameters before running.


These links will automatically comment on this PR with the workflow results.

Tip: To open links in a new tab, use Ctrl+Click (Windows/Linux) or Cmd+Click (macOS).

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements security improvements and UX enhancements for OAuth redirect handling in a FastAPI application. The changes prevent open redirect attacks by validating redirect URLs and ensure query parameters are preserved during authentication flows.

Key changes:

  • Adds URL validation to prevent external redirects during OAuth flows
  • Updates redirect URL handling to use relative paths instead of full URLs
  • Translates Russian UI text to English

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
backend/routes/auth.py Adds validate_redirect_url() function and integrates validation into OAuth login/callback flows
backend/routes/workflow.py Changes redirect URL storage from full URL to relative path with query parameters
frontend/templates/index.html Updates auth link to include redirect parameters and translates logout button; adds btn-active class management
frontend/templates/result.html Translates Russian UI messages to English
frontend/static/style.css Adds styling for active/inactive button states with new btn-active class
tests/test_auth_redirect.py Adds comprehensive test coverage for OAuth redirect validation and parameter preservation
tests/test_app.py Updates tests to handle redirect responses and skips complex session-dependent tests

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 1009 to 1015
// Обновляем ссылку на авторизацию, чтобы она передавала текущий URL с параметрами
const authLink = document.getElementById('auth-link');
if (authLink && window.location.search) {
const currentUrl = window.location.href;
const redirectAfter = encodeURIComponent(currentUrl);
authLink.href = `/auth/github?redirect_after=${redirectAfter}`;
}
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code comment is in Russian. It should be translated to English to match the rest of the codebase changes in this PR. Consider: 'Update the authorization link to pass the current URL with parameters'.

Copilot uses AI. Check for mistakes.
authLink.href = `/auth/github?redirect_after=${redirectAfter}`;
}

// Инициализируем скрытое поле return_url из URL параметров, если его нет
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code comment is in Russian. It should be translated to English to match the rest of the codebase changes in this PR. Consider: 'Initialize the hidden return_url field from URL parameters if not present'.

Suggested change
// Инициализируем скрытое поле return_url из URL параметров, если его нет
// Initialize the hidden return_url field from URL parameters if not present

Copilot uses AI. Check for mistakes.
}
}

// Инициализация при загрузке
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code comment is in Russian. It should be translated to English to match the rest of the codebase changes in this PR. Consider: 'Initialize on page load'.

Suggested change
// Инициализация при загрузке
// Initialize on page load

Copilot uses AI. Check for mistakes.
secondRow.style.display = 'flex';
}
} else if (attempts < maxAttempts) {
// Продолжаем опрос
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code comment is in Russian while the UI text in the same file has been translated to English. For consistency, translate to: 'Continue polling'.

Suggested change
// Продолжаем опрос
// Continue polling

Copilot uses AI. Check for mistakes.
Comment on lines +31 to +32
if not url:
return "/"
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The early return for empty URL in validate_redirect_url() lacks test coverage. Consider adding a test case in test_auth_redirect.py that explicitly tests empty string input to ensure this branch is covered.

Copilot uses AI. Check for mistakes.
Comment on lines +57 to +58
if not url.startswith('/'):
url = '/' + url
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The normalization of paths without leading slashes lacks explicit test coverage. While test_oauth_login_accepts_internal_paths tests a path without leading slash at line 17, it doesn't verify the normalized output. Consider adding an assertion that specifically validates the normalized path.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

github-actions bot commented Dec 1, 2025

Tests completed successfully!

  • Test type: all
  • Workflow run: View run
  • Status: ✅ Success

…ments

- Translated comments in index.html and result.html from Russian to English for better accessibility.
- Enhanced clarity of comments to accurately describe the functionality of JavaScript code related to authorization links and workflow actions.
- Improved consistency in comment style across templates to maintain a uniform codebase.
@github-actions
Copy link

github-actions bot commented Dec 1, 2025

🚀 Quick Actions

🧪 Run Tests

Test Type Actions
All ▶ All ⚙️
Unit ▶ Unit ⚙️
Integration ▶ Integration ⚙️

📦 Backport

Branch Actions
release/v1.0 ▶ Backport ⚙️
release/v2.0 ▶ Backport ⚙️
stable ▶ Backport ⚙️

Choose branches to backport manually:

⚙️ 📦 Backport (Custom)

▶ - immediately runs the workflow with default parameters.

⚙️ - opens UI to review and modify parameters before running.


These links will automatically comment on this PR with the workflow results.

Tip: To open links in a new tab, use Ctrl+Click (Windows/Linux) or Cmd+Click (macOS).

@naspirato naspirato merged commit 137d609 into main Dec 1, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant