Skip to content

Commit 538d5c8

Browse files
authored
feat: reset oauth ids (#20798)
1 parent 9ecaa3f commit 538d5c8

File tree

15 files changed

+247
-6
lines changed

15 files changed

+247
-6
lines changed

i18n/en.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,9 @@
355355
"trash_number_of_days_description": "Number of days to keep the assets in trash before permanently removing them",
356356
"trash_settings": "Trash Settings",
357357
"trash_settings_description": "Manage trash settings",
358+
"unlink_all_oauth_accounts": "Unlink all OAuth accounts",
359+
"unlink_all_oauth_accounts_description": "Remember to unlink all OAuth accounts before migrating to a new provider.",
360+
"unlink_all_oauth_accounts_prompt": "Are you sure you want to unlink all OAuth accounts? This will reset the OAuth ID for each user and cannot be undone.",
358361
"user_cleanup_job": "User cleanup",
359362
"user_delete_delay": "<b>{user}</b>'s account and assets will be scheduled for permanent deletion in {delay, plural, one {# day} other {# days}}.",
360363
"user_delete_delay_settings": "Delete delay",
@@ -921,6 +924,7 @@
921924
"paths_validation_failed": "{paths, plural, one {# path} other {# paths}} failed validation",
922925
"profile_picture_transparent_pixels": "Profile pictures cannot have transparent pixels. Please zoom in and/or move the image.",
923926
"quota_higher_than_disk_size": "You set a quota higher than the disk size",
927+
"something_went_wrong": "Something went wrong",
924928
"unable_to_add_album_users": "Unable to add users to album",
925929
"unable_to_add_assets_to_shared_link": "Unable to add assets to shared link",
926930
"unable_to_add_comment": "Unable to add comment",

mobile/openapi/README.md

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mobile/openapi/lib/api.dart

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mobile/openapi/lib/api/auth_admin_api.dart

Lines changed: 54 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mobile/openapi/lib/model/permission.dart

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

open-api/immich-openapi-specs.json

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,34 @@
214214
"description": "This endpoint requires the `activity.delete` permission."
215215
}
216216
},
217+
"/admin/auth/unlink-all": {
218+
"post": {
219+
"operationId": "unlinkAllOAuthAccountsAdmin",
220+
"parameters": [],
221+
"responses": {
222+
"204": {
223+
"description": ""
224+
}
225+
},
226+
"security": [
227+
{
228+
"bearer": []
229+
},
230+
{
231+
"cookie": []
232+
},
233+
{
234+
"api_key": []
235+
}
236+
],
237+
"tags": [
238+
"Auth (admin)"
239+
],
240+
"x-immich-admin-only": true,
241+
"x-immich-permission": "adminAuth.unlinkAll",
242+
"description": "This endpoint is an admin-only route, and requires the `adminAuth.unlinkAll` permission."
243+
}
244+
},
217245
"/admin/notifications": {
218246
"post": {
219247
"operationId": "createNotification",
@@ -12687,7 +12715,8 @@
1268712715
"adminUser.create",
1268812716
"adminUser.read",
1268912717
"adminUser.update",
12690-
"adminUser.delete"
12718+
"adminUser.delete",
12719+
"adminAuth.unlinkAll"
1269112720
],
1269212721
"type": "string"
1269312722
},

open-api/typescript-sdk/src/fetch-client.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1646,6 +1646,15 @@ export function deleteActivity({ id }: {
16461646
method: "DELETE"
16471647
}));
16481648
}
1649+
/**
1650+
* This endpoint is an admin-only route, and requires the `adminAuth.unlinkAll` permission.
1651+
*/
1652+
export function unlinkAllOAuthAccountsAdmin(opts?: Oazapfts.RequestOpts) {
1653+
return oazapfts.ok(oazapfts.fetchText("/admin/auth/unlink-all", {
1654+
...opts,
1655+
method: "POST"
1656+
}));
1657+
}
16491658
export function createNotification({ notificationCreateDto }: {
16501659
notificationCreateDto: NotificationCreateDto;
16511660
}, opts?: Oazapfts.RequestOpts) {
@@ -4669,7 +4678,8 @@ export enum Permission {
46694678
AdminUserCreate = "adminUser.create",
46704679
AdminUserRead = "adminUser.read",
46714680
AdminUserUpdate = "adminUser.update",
4672-
AdminUserDelete = "adminUser.delete"
4681+
AdminUserDelete = "adminUser.delete",
4682+
AdminAuthUnlinkAll = "adminAuth.unlinkAll"
46734683
}
46744684
export enum AssetMediaStatus {
46754685
Created = "created",
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Controller, HttpCode, HttpStatus, Post } from '@nestjs/common';
2+
import { ApiTags } from '@nestjs/swagger';
3+
import { AuthDto } from 'src/dtos/auth.dto';
4+
import { Permission } from 'src/enum';
5+
import { Auth, Authenticated } from 'src/middleware/auth.guard';
6+
import { AuthAdminService } from 'src/services/auth-admin.service';
7+
8+
@ApiTags('Auth (admin)')
9+
@Controller('admin/auth')
10+
export class AuthAdminController {
11+
constructor(private service: AuthAdminService) {}
12+
@Post('unlink-all')
13+
@Authenticated({ permission: Permission.AdminAuthUnlinkAll, admin: true })
14+
@HttpCode(HttpStatus.NO_CONTENT)
15+
unlinkAllOAuthAccountsAdmin(@Auth() auth: AuthDto): Promise<void> {
16+
return this.service.unlinkAll(auth);
17+
}
18+
}

server/src/controllers/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { APIKeyController } from 'src/controllers/api-key.controller';
44
import { AppController } from 'src/controllers/app.controller';
55
import { AssetMediaController } from 'src/controllers/asset-media.controller';
66
import { AssetController } from 'src/controllers/asset.controller';
7+
import { AuthAdminController } from 'src/controllers/auth-admin.controller';
78
import { AuthController } from 'src/controllers/auth.controller';
89
import { DownloadController } from 'src/controllers/download.controller';
910
import { DuplicateController } from 'src/controllers/duplicate.controller';
@@ -40,6 +41,7 @@ export const controllers = [
4041
AssetController,
4142
AssetMediaController,
4243
AuthController,
44+
AuthAdminController,
4345
DownloadController,
4446
DuplicateController,
4547
FaceController,

server/src/enum.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ export enum Permission {
235235
AdminUserRead = 'adminUser.read',
236236
AdminUserUpdate = 'adminUser.update',
237237
AdminUserDelete = 'adminUser.delete',
238+
239+
AdminAuthUnlinkAll = 'adminAuth.unlinkAll',
238240
}
239241

240242
export enum SharedLinkType {

0 commit comments

Comments
 (0)