1
0
Fork 0
Beyond coding. We forge. https://codeberg.org/forgejo/forgejo
Find a file
Rowan Bohde 21fdd28f08
allow synchronizing user status from OAuth2 login providers (#31572)
This leverages the existing `sync_external_users` cron job to
synchronize the `IsActive` flag on users who use an OAuth2 provider set
to synchronize. This synchronization is done by checking for expired
access tokens, and using the stored refresh token to request a new
access token. If the response back from the OAuth2 provider is the
`invalid_grant` error code, the user is marked as inactive. However, the
user is able to reactivate their account by logging in the web browser
through their OAuth2 flow.

Also changed to support this is that a linked `ExternalLoginUser` is
always created upon a login or signup via OAuth2.

Ideally, we would also refresh permissions from the configured OAuth
provider (e.g., admin, restricted and group mappings) to match the
implementation of LDAP. However, the OAuth library used for this `goth`,
doesn't seem to support issuing a session via refresh tokens. The
interface provides a [`RefreshToken`
method](https://github.com/markbates/goth/blob/master/provider.go#L20),
but the returned `oauth.Token` doesn't implement the `goth.Session` we
would need to call `FetchUser`. Due to specific implementations, we
would need to build a compatibility function for every provider, since
they cast to concrete types (e.g.
[Azure](https://github.com/markbates/goth/blob/master/providers/azureadv2/azureadv2.go#L132))

---------

Co-authored-by: Kyle D <kdumontnu@gmail.com>
(cherry picked from commit 416c36f3034e228a27258b5a8a15eec4e5e426ba)

Conflicts:
	- tests/integration/auth_ldap_test.go
	  Trivial conflict resolved by manually applying the change.
	- routers/web/auth/oauth.go
	  Technically not a conflict, but the original PR removed the
	  modules/util import, which in our version, is still in use. Added it
	  back.
2024-07-22 15:44:13 +02:00
.devcontainer
.forgejo docs: add a PR checklist template (#4564) 2024-07-22 05:23:54 +00:00
assets
build
cmd feat(cli): add --keep-labels flag to forgejo actions register (#4610) 2024-07-22 07:33:45 +00:00
contrib
custom/conf Add option to change mail from user display name (#31528) 2024-07-22 15:44:13 +02:00
docker
models allow synchronizing user status from OAuth2 login providers (#31572) 2024-07-22 15:44:13 +02:00
modules Add option to change mail from user display name (#31528) 2024-07-22 15:44:13 +02:00
options
public
release-notes
releases/images
routers allow synchronizing user status from OAuth2 login providers (#31572) 2024-07-22 15:44:13 +02:00
services allow synchronizing user status from OAuth2 login providers (#31572) 2024-07-22 15:44:13 +02:00
templates allow synchronizing user status from OAuth2 login providers (#31572) 2024-07-22 15:44:13 +02:00
tests allow synchronizing user status from OAuth2 login providers (#31572) 2024-07-22 15:44:13 +02:00
tools
web_src Lock file maintenance 2024-07-22 00:07:27 +00:00
.air.toml
.deadcode-out
.dockerignore
.editorconfig
.eslintrc.yaml
.gitattributes
.gitignore
.gitmodules
.gitpod.yml
.golangci.yml
.ignore
.markdownlint.yaml
.npmrc
.spectral.yaml
.yamllint.yaml
BSDmakefile
build.go
CODEOWNERS
CONTRIBUTING.md
DCO
Dockerfile
Dockerfile.rootless
flake.lock
flake.nix
go.mod
go.sum
LICENSE
main.go
Makefile Update renovate to v37.438.2 2024-07-22 00:04:06 +00:00
package-lock.json Lock file maintenance 2024-07-22 00:07:27 +00:00
package.json
playwright.config.js
poetry.lock
poetry.toml
pyproject.toml
README.md
RELEASE-NOTES.md
renovate.json
stylelint.config.js
tailwind.config.js
vitest.config.js
webpack.config.js

Welcome to Forgejo

Hi there! Tired of big platforms playing monopoly? Providing Git hosting for your project, friends, company or community? Forgejo (/for'd͡ʒe.jo/ inspired by forĝejo the Esperanto word for forge) has you covered with its intuitive interface, light and easy hosting and a lot of builtin functionality.

Forgejo was created in 2022 because we think that the project should be owned by an independent community. If you second that, then Forgejo is for you! Our promise: Independent Free/Libre Software forever!

What does Forgejo offer?

If you like any of the following, Forgejo is literally meant for you:

  • Lightweight: Forgejo can easily be hosted on nearly every machine. Running on a Raspberry? Small cloud instance? No problem!
  • Project management: Besides Git hosting, Forgejo offers issues, pull requests, wikis, kanban boards and much more to coordinate with your team.
  • Publishing: Have something to share? Use releases to host your software for download, or use the package registry to publish it for docker, npm and many other package managers.
  • Customizable: Want to change your look? Change some settings? There are many config switches to make Forgejo work exactly like you want.
  • Powerful: Organizations & team permissions, CI integration, Code Search, LDAP, OAuth and much more. If you have advanced needs, Forgejo has you covered.
  • Privacy: From update checker to default settings: Forgejo is built to be privacy first for you and your crew.
  • Federation: (WIP) We are actively working to connect software forges with each other through ActivityPub, and create a collaborative network of personal instances.

Learn more

Dive into the documentation, subscribe to releases and blog post on our website, find us on the Fediverse or hop into our Matrix room if you have any questions or want to get involved.

Get involved

If you are interested in making Forgejo better, either by reporting a bug or by changing the governance, please take a look at the contribution guide.