You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gitea/models
Rowan Bohde 416c36f303
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.

### Notes on updating permissions
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>
7 months ago
..
actions Drop `IDOrderDesc` for listing Actions task and always order by `id DESC` (#31150) 8 months ago
activities Refactor webhook (#31587) 7 months ago
admin Next round of `db.DefaultContext` refactor (#27089) 1 year ago
asymkey Enable more `revive` linter rules (#30608) 9 months ago
auth allow synchronizing user status from OAuth2 login providers (#31572) 7 months ago
avatars Replace 10 more gt- classes with tw- (#29945) 10 months ago
db [Refactor] Unify repo search order by logic (#30876) 8 months ago
dbfs Enable `unparam` linter (#31277) 8 months ago
fixtures Fix wrong display of recently pushed notification (#25812) 8 months ago
git Allow force push to protected branches (#28086) 7 months ago
issues Added default sorting milestones by name (#27084) 7 months ago
migrations Upgrade xorm to v1.3.9 and improve some migrations Sync (#29899) 7 months ago
organization Fix wrong display of recently pushed notification (#25812) 8 months ago
packages Fix package list performance (#30520) 10 months ago
perm Clarify permission "HasAccess" behavior (#30585) 10 months ago
project Rename project board -> column to make the UI less confusing (#30170) 8 months ago
pull Add support for sha256 repositories (#23894) 1 year ago
repo Refactor webhook (#31587) 7 months ago
secret Make runs-on support variable expression (#29468) 11 months ago
shared/types Refactor locale&string&template related code (#29165) 12 months ago
system Refactor deletion (#28610) 1 year ago
unit Refactor repo unit "disabled" check (#31389) 8 months ago
unittest Add some tests to clarify the "must-change-password" behavior (#30693) 9 months ago
user allow synchronizing user status from OAuth2 login providers (#31572) 7 months ago
webhook Store webhook event in database (#29145) 11 months ago
error.go Add merge style `fast-forward-only` (#28954) 12 months ago
fixture_generation.go Replace more db.DefaultContext (#27628) 1 year ago
fixture_test.go Replace more db.DefaultContext (#27628) 1 year ago
main_test.go make writing main test easier (#27270) 1 year ago
org.go Add user blocking (#29028) 11 months ago
org_team.go Clarify permission "HasAccess" behavior (#30585) 10 months ago
org_team_test.go Add user blocking (#29028) 11 months ago
org_test.go Add user blocking (#29028) 11 months ago
repo.go Refactor deletion (#28610) 1 year ago
repo_test.go Penultimate round of `db.DefaultContext` refactor (#27414) 1 year ago
repo_transfer.go chore: use errors.New to replace fmt.Errorf with no parameters will much better (#30621) 9 months ago