0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-12-26 22:24:27 +01:00
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
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
repo Refactor webhook (#31587) 2024-07-10 11:37:16 +00:00
secret
shared/types
system
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
error.go
fixture_generation.go
fixture_test.go
main_test.go
org.go
org_team.go Clarify permission "HasAccess" behavior (#30585) 2024-04-20 03:15:04 +00:00
org_team_test.go
org_test.go
repo.go
repo_test.go
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