Skip to content

Conversation

@francescocaponio
Copy link

About this PR

Tries to implement the request in #4602 and #7437

With the help of Copilot, we added the support for OIDC authentication.

The OIDC parameters are edited in the admin section, stored in the DB. It is possible to select if the OIDC authentication method is the only available or coexists with other authentication methods in the login form.

The oidc authentication backend is based on the go-oidc module.

It supports auto-discovery of the auth endpoints via the .well-known mechanism.

The login button can be customized with a custom icon (loaded from a user specified url), background color and text color.

It supports the oidc groups claim and the user can specify the name of a group where users who belongs to this group are automatically elevated to admin roles in gogs.

Checklist

  • I agree to follow the Code of Conduct by submitting this pull request.
  • I have read and acknowledge the Contributing guide.
  • I have added test cases to cover the new code or have provided the test plan.
  • I have tested the behavior of the code with a OpenID Connect Identity Provider.

Test plan

I'm attaching some screenshots of the configuration and login forms:

Authentication sources list:

image

New/edit auth source form:

image

Login form (OIDC as default login source):

image

Login form (OIDC not as default login source):

image

Copilot AI and others added 14 commits September 17, 2025 14:41
…-4c65-b083-8b2862842437

Implement OIDC (OpenID Connect) authentication support with OIDC-only login mode, group-based admin assignment, and customizable button styling
francescocaponio and others added 15 commits October 18, 2025 21:02
- Added DISABLE_WIKI and DISABLE_ISSUES configuration options in [repository] section
- Updated RepositoryOpts struct in conf/static.go to include DisableWiki and DisableIssues fields
- Modified CreateRepository to respect global settings when creating new repositories
- Modified ForkRepository to respect global settings when forking repositories
- Updated admin config template to display new settings
- Added English locale strings for the new settings
- Updated golden test to include new configuration options

Co-authored-by: nuclearinstruments-devops <[email protected]>
- Updated repository settings route to prevent enabling wiki/issues when globally disabled
- Modified settings template to disable checkboxes and show message when features are globally disabled
- Added locale string for "disabled globally" message
- Passed global configuration to template for UI display

Co-authored-by: nuclearinstruments-devops <[email protected]>
…isabled

- Modified ForkRepository to use baseRepo.EnableWiki && !conf.Repository.DisableWiki
- Modified ForkRepository to use baseRepo.EnableIssues && !conf.Repository.DisableIssues
- This preserves the base repository's settings when global disabling is not in effect

Co-authored-by: nuclearinstruments-devops <[email protected]>
- Added DISABLE_REPO_CREATION configuration option to prevent repository creation
- Added DISABLE_MIGRATION configuration option to prevent repository migration
- Modified Create/CreatePost to check DISABLE_REPO_CREATION and return 404 if disabled
- Modified Migrate/MigratePost to check DISABLE_MIGRATION and return 404 if disabled
- Changed mirror checkbox default to checked in migration form
- Removed private and unlisted visibility options from migration template
- Updated admin config template to display new settings
- Added English locale strings for new settings

Co-authored-by: nuclearinstruments-devops <[email protected]>
- Modified Create API endpoint to check DISABLE_REPO_CREATION
- Modified CreateOrgRepo API endpoint to check DISABLE_REPO_CREATION
- Modified Migrate API endpoint to check DISABLE_MIGRATION
- All endpoints return 403 Forbidden when features are globally disabled
- Ensures consistency between web UI and API endpoints

Co-authored-by: nuclearinstruments-devops <[email protected]>
- Added DisableRepoCreation, DisableMigration, and DisableIssuesGlobally to context data
- Hide "Create Repository" menu item when DISABLE_REPO_CREATION is true
- Hide "Migrate Repository" menu item when DISABLE_MIGRATION is true
- Hide "Issues" link in repository navbar when DISABLE_ISSUES is globally true
- Hide create repository button in user dashboard when globally disabled
- All changes apply to both main navbar dropdown and dashboard

Co-authored-by: nuclearinstruments-devops <[email protected]>
…al-setting-to-disable-wiki-issues

Add global configuration to disable wiki, issues, repository creation, and migration
… and size limit validation

Co-authored-by: nuclearinstruments-devops <[email protected]>
…l-profile-image-import

Add OIDC profile picture import as custom user avatar
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