forkjo/templates/admin
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
..
applications Always use ctx.Locale.Tr inside templates (#27231) 2023-09-25 08:56:50 +00:00
auth allow synchronizing user status from OAuth2 login providers (#31572) 2024-07-22 15:44:13 +02:00
emails Migrate margin and padding helpers to tailwind (#30043) 2024-03-30 07:17:29 +01:00
org Migrate margin and padding helpers to tailwind (#30043) 2024-03-30 07:17:29 +01:00
packages Fix some URLs whose sub-path is missing (#31289) 2024-06-09 16:04:57 +02:00
repo Replace gt-word-break with tw-break-anywhere 2024-06-11 08:57:27 +05:00
runners Move secrets and runners settings to actions settings (#24200) 2023-04-27 20:08:47 -04:00
user ui(admin): improve names of user settings and add descriptions 2024-07-15 03:57:56 +00:00
actions.tmpl Added instance-level variables (#28115) 2023-12-25 07:28:59 +00:00
config.tmpl Add cache test for admins (#31265) 2024-06-23 11:27:03 +02:00
config_settings.tmpl Remove fomantic checkbox module (#30162) 2024-04-07 11:05:37 +02:00
cron.tmpl Migrate margin and padding helpers to tailwind (#30043) 2024-03-30 07:17:29 +01:00
dashboard.tmpl Don't show loading indicators when refreshing the system status (#30712) 2024-04-28 15:39:01 +02:00
hook_new.tmpl Always use ctx.Locale.Tr inside templates (#27231) 2023-09-25 08:56:50 +00:00
hooks.tmpl Change to vertical navbar layout for secondary navbar for repo/user/admin settings (#24246) 2023-04-23 18:21:21 +08:00
layout_footer.tmpl Change to vertical navbar layout for secondary navbar for repo/user/admin settings (#24246) 2023-04-23 18:21:21 +08:00
layout_head.tmpl Fix flash message for flex-container (#30657) 2024-04-28 15:39:00 +02:00
navbar.tmpl [CHORE] Remove Microsoft SQL Server Support 2024-04-05 23:37:36 +02:00
notice.tmpl Fix admin notice view-detail (#30450) 2024-04-15 20:01:36 +02:00
queue.tmpl Always use ctx.Locale.Tr inside templates (#27231) 2023-09-25 08:56:50 +00:00
queue_manage.tmpl Migrate margin and padding helpers to tailwind (#30043) 2024-03-30 07:17:29 +01:00
self_check.tmpl Add cache test for admins (#31265) 2024-06-23 11:27:03 +02:00
stacktrace-row.tmpl Migrate margin and padding helpers to tailwind (#30043) 2024-03-30 07:17:29 +01:00
stacktrace.tmpl Fix incorrect tailwind migration (#30007) 2024-03-26 19:04:27 +01:00
stats.tmpl [REFACTOR] Simplify converting struct to map in admin stats 2024-02-22 22:25:19 +01:00
system_status.tmpl Auto-update the system status in admin dashboard (#29163) 2024-02-17 23:24:31 +01:00