Skip to content

feat: add and standardize OAuth provider support#70

Merged
appleboy merged 4 commits intomainfrom
gitlab
Mar 3, 2026
Merged

feat: add and standardize OAuth provider support#70
appleboy merged 4 commits intomainfrom
gitlab

Conversation

@appleboy
Copy link
Member

@appleboy appleboy commented Mar 3, 2026

  • Introduce full GitLab OAuth support, including provider implementation, configuration, bootstrap wiring, and login UI icon
  • Refactor Gitea user info fetching to use a precomputed API URL instead of deriving it from the auth endpoint
  • Add a shared apiURL field to OAuth providers for cleaner and more consistent user info requests
  • Add comprehensive test coverage for GitHub, Gitea, GitLab, and Microsoft OAuth providers, including success paths and error cases
  • Improve provider constructors to normalize base URLs by stripping trailing slashes
  • Extend provider dispatch logic to handle GitLab and add tests for unsupported providers and display names

- Introduce full GitLab OAuth support, including provider implementation, configuration, bootstrap wiring, and login UI icon
- Refactor Gitea user info fetching to use a precomputed API URL instead of deriving it from the auth endpoint
- Add a shared apiURL field to OAuth providers for cleaner and more consistent user info requests
- Add comprehensive test coverage for GitHub, Gitea, GitLab, and Microsoft OAuth providers, including success paths and error cases
- Improve provider constructors to normalize base URLs by stripping trailing slashes
- Extend provider dispatch logic to handle GitLab and add tests for unsupported providers and display names

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
Copilot AI review requested due to automatic review settings March 3, 2026 05:43
@codecov
Copy link

codecov bot commented Mar 3, 2026

Codecov Report

❌ Patch coverage is 72.13115% with 17 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/bootstrap/oauth.go 10.52% 17 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Contributor

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 adds GitLab as a first-class OAuth provider and standardizes instance-based OAuth providers by introducing a precomputed apiURL for user-info fetching, alongside expanded provider test coverage.

Changes:

  • Add GitLab OAuth support end-to-end (config/env, bootstrap wiring, provider implementation, login-page icon).
  • Refactor Gitea user-info fetching to use a precomputed API URL and add apiURL to provider struct for consistency.
  • Add/expand unit tests across OAuth providers (GitHub, Gitea, GitLab, Microsoft), including success and error paths.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
internal/templates/login_page.templ Adds GitLab icon rendering for OAuth login buttons.
internal/config/config.go Adds GitLab OAuth configuration fields and env loading.
internal/bootstrap/oauth.go Wires GitLab provider initialization into bootstrap/provider registry.
internal/auth/oauth_provider.go Adds apiURL, normalizes base URLs, adds GitLab provider constructor, dispatches GitLab user info.
internal/auth/oauth_gitea.go Switches Gitea user-info fetch to use p.apiURL.
internal/auth/oauth_gitlab.go Implements GitLab /api/v4/user user-info fetch and mapping.
internal/auth/oauth_provider_test.go Adds shared testing utilities and tests for display name + unsupported providers.
internal/auth/oauth_github_test.go Adds GitHub provider constructor + user-info tests (including email fallback behavior).
internal/auth/oauth_gitea_test.go Adds Gitea provider constructor + user-info tests (including error cases).
internal/auth/oauth_gitlab_test.go Adds GitLab provider constructor + user-info tests (including error cases).
internal/auth/oauth_microsoft_test.go Adds Microsoft provider constructor + user-info tests (including error cases).

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

appleboy and others added 3 commits March 3, 2026 13:58
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Add styling for a GitLab OAuth login button, including colors, hover effects, and SVG icon sizing

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
@appleboy appleboy merged commit 3533740 into main Mar 3, 2026
7 of 15 checks passed
@appleboy appleboy deleted the gitlab branch March 3, 2026 06:00
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.

2 participants