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>
2024-07-16 20:33:16 +02:00
..
actions Drop IDOrderDesc for listing Actions task and always order by id DESC (#31150) 2024-05-31 02:30:02 +00:00
activities Refactor webhook (#31587) 2024-07-10 11:37:16 +00:00
admin Next round of db.DefaultContext refactor (#27089) 2023-09-16 14:39:12 +00:00
asymkey Enable more revive linter rules (#30608) 2024-04-22 11:48:42 +00:00
auth allow synchronizing user status from OAuth2 login providers (#31572) 2024-07-16 20:33:16 +02:00
avatars Replace 10 more gt- classes with tw- (#29945) 2024-03-22 13:45:10 +00:00
db [Refactor] Unify repo search order by logic (#30876) 2024-06-13 09:13:11 +00:00
dbfs Enable unparam linter (#31277) 2024-06-11 18:47:45 +00:00
fixtures Fix wrong display of recently pushed notification (#25812) 2024-05-21 17:00:35 +00:00
git Allow force push to protected branches (#28086) 2024-07-05 18:21:56 +00:00
issues Added default sorting milestones by name (#27084) 2024-07-16 10:08:54 +02:00
migrations Upgrade xorm to v1.3.9 and improve some migrations Sync (#29899) 2024-07-14 17:15:59 -04:00
organization Fix wrong display of recently pushed notification (#25812) 2024-05-21 17:00:35 +00:00
packages Fix package list performance (#30520) 2024-04-20 13:07:00 +02:00
perm Clarify permission "HasAccess" behavior (#30585) 2024-04-20 03:15:04 +00:00
project Rename project board -> column to make the UI less confusing (#30170) 2024-05-27 08:59:54 +00:00
pull Add support for sha256 repositories (#23894) 2024-01-19 17:05:02 +01:00
repo Refactor webhook (#31587) 2024-07-10 11:37:16 +00:00
secret Make runs-on support variable expression (#29468) 2024-03-08 06:14:35 +00:00
shared/types Refactor locale&string&template related code (#29165) 2024-02-14 21:48:45 +00:00
system Refactor deletion (#28610) 2023-12-25 21:25:29 +01:00
unit Refactor repo unit "disabled" check (#31389) 2024-06-18 00:51:13 +00:00
unittest Add some tests to clarify the "must-change-password" behavior (#30693) 2024-04-27 12:23:37 +00:00
user allow synchronizing user status from OAuth2 login providers (#31572) 2024-07-16 20:33:16 +02:00
webhook Store webhook event in database (#29145) 2024-03-07 23:18:38 +01:00
error.go Add merge style fast-forward-only (#28954) 2024-02-12 23:37:23 +01:00
fixture_generation.go Replace more db.DefaultContext (#27628) 2023-10-15 17:46:06 +02:00
fixture_test.go Replace more db.DefaultContext (#27628) 2023-10-15 17:46:06 +02:00
main_test.go make writing main test easier (#27270) 2023-09-28 01:38:53 +00:00
org_team_test.go Add user blocking (#29028) 2024-03-04 08:16:03 +00:00
org_team.go Clarify permission "HasAccess" behavior (#30585) 2024-04-20 03:15:04 +00:00
org_test.go Add user blocking (#29028) 2024-03-04 08:16:03 +00:00
org.go Add user blocking (#29028) 2024-03-04 08:16:03 +00:00
repo_test.go Penultimate round of db.DefaultContext refactor (#27414) 2023-10-11 04:24:07 +00:00
repo_transfer.go chore: use errors.New to replace fmt.Errorf with no parameters will much better (#30621) 2024-04-21 19:44:03 +00:00
repo.go Refactor deletion (#28610) 2023-12-25 21:25:29 +01:00