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/user
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
..
avatar.go Fix duplicate sub-path for avatars (#31365) 9 months ago
avatar_test.go Fix duplicate sub-path for avatars (#31365) 9 months ago
badge.go Add admin API route for managing user's badges (#23106) 1 year ago
block.go Add user blocking (#29028) 12 months ago
email_address.go Refactor sha1 and time-limited code (#31023) 9 months ago
email_address_test.go migrate some more "OptionalBool" to "Option[bool]" (#29479) 1 year ago
error.go Remove unused `KeyID`. (#29167) 1 year ago
external_login_user.go allow synchronizing user status from OAuth2 login providers (#31572) 7 months ago
follow.go Add user blocking (#29028) 12 months ago
follow_test.go Next round of `db.DefaultContext` refactor (#27089) 1 year ago
list.go Reduce usage of `db.DefaultContext` (#27073) 1 year ago
main_test.go make writing main test easier (#27270) 1 year ago
must_change_password.go Add command to bulk set must-change-password (#22823) 2 years ago
openid.go More refactoring of `db.DefaultContext` (#27083) 1 year ago
openid_test.go More refactoring of `db.DefaultContext` (#27083) 1 year ago
redirect.go Another round of `db.DefaultContext` refactor (#27103) 1 year ago
redirect_test.go Another round of `db.DefaultContext` refactor (#27103) 1 year ago
search.go migrate some more "OptionalBool" to "Option[bool]" (#29479) 1 year ago
setting.go More refactoring of `db.DefaultContext` (#27083) 1 year ago
setting_keys.go Show outdated comments in files changed tab (#24936) 2 years ago
setting_test.go More refactoring of `db.DefaultContext` (#27083) 1 year ago
user.go Allow disabling authentication related user features (#31535) 8 months ago
user_system.go Replace -1 with GhostUserID (#27703) 1 year ago
user_test.go Use FullName in Emails to address the recipient if possible (#31527) 8 months ago
user_update.go Implement FSFE REUSE for golang files (#21840) 2 years ago