1
0
mirror of https://github.com/immich-app/immich.git synced 2025-07-03 05:46:58 +02:00

fix(web): OAuth quota size (#18526)

fix(server): oauth quota size
This commit is contained in:
Daimolean
2025-06-13 22:57:29 +08:00
committed by GitHub
parent e2dfbd66c3
commit 004c2f2496
12 changed files with 24 additions and 16 deletions

View File

@ -123,7 +123,7 @@ The default configuration looks like this:
"buttonText": "Login with OAuth",
"clientId": "",
"clientSecret": "",
"defaultStorageQuota": 0,
"defaultStorageQuota": null,
"enabled": false,
"issuerUrl": "",
"mobileOverrideEnabled": false,

View File

@ -204,7 +204,7 @@
"oauth_storage_quota_claim": "Storage quota claim",
"oauth_storage_quota_claim_description": "Automatically set the user's storage quota to the value of this claim.",
"oauth_storage_quota_default": "Default storage quota (GiB)",
"oauth_storage_quota_default_description": "Quota in GiB to be used when no claim is provided (Enter 0 for unlimited quota).",
"oauth_storage_quota_default_description": "Quota in GiB to be used when no claim is provided.",
"oauth_timeout": "Request Timeout",
"oauth_timeout_description": "Timeout for requests in milliseconds",
"password_enable_description": "Login with email and password",

View File

@ -43,7 +43,7 @@ class SystemConfigOAuthDto {
String clientSecret;
/// Minimum value: 0
num defaultStorageQuota;
int? defaultStorageQuota;
bool enabled;
@ -96,7 +96,7 @@ class SystemConfigOAuthDto {
(buttonText.hashCode) +
(clientId.hashCode) +
(clientSecret.hashCode) +
(defaultStorageQuota.hashCode) +
(defaultStorageQuota == null ? 0 : defaultStorageQuota!.hashCode) +
(enabled.hashCode) +
(issuerUrl.hashCode) +
(mobileOverrideEnabled.hashCode) +
@ -119,7 +119,11 @@ class SystemConfigOAuthDto {
json[r'buttonText'] = this.buttonText;
json[r'clientId'] = this.clientId;
json[r'clientSecret'] = this.clientSecret;
if (this.defaultStorageQuota != null) {
json[r'defaultStorageQuota'] = this.defaultStorageQuota;
} else {
// json[r'defaultStorageQuota'] = null;
}
json[r'enabled'] = this.enabled;
json[r'issuerUrl'] = this.issuerUrl;
json[r'mobileOverrideEnabled'] = this.mobileOverrideEnabled;
@ -148,7 +152,7 @@ class SystemConfigOAuthDto {
buttonText: mapValueOfType<String>(json, r'buttonText')!,
clientId: mapValueOfType<String>(json, r'clientId')!,
clientSecret: mapValueOfType<String>(json, r'clientSecret')!,
defaultStorageQuota: num.parse('${json[r'defaultStorageQuota']}'),
defaultStorageQuota: mapValueOfType<int>(json, r'defaultStorageQuota'),
enabled: mapValueOfType<bool>(json, r'enabled')!,
issuerUrl: mapValueOfType<String>(json, r'issuerUrl')!,
mobileOverrideEnabled: mapValueOfType<bool>(json, r'mobileOverrideEnabled')!,

View File

@ -14344,8 +14344,10 @@
"type": "string"
},
"defaultStorageQuota": {
"format": "int64",
"minimum": 0,
"type": "number"
"nullable": true,
"type": "integer"
},
"enabled": {
"type": "boolean"

View File

@ -1392,7 +1392,7 @@ export type SystemConfigOAuthDto = {
buttonText: string;
clientId: string;
clientSecret: string;
defaultStorageQuota: number;
defaultStorageQuota: number | null;
enabled: boolean;
issuerUrl: string;
mobileOverrideEnabled: boolean;

View File

@ -89,7 +89,7 @@ export interface SystemConfig {
buttonText: string;
clientId: string;
clientSecret: string;
defaultStorageQuota: number;
defaultStorageQuota: number | null;
enabled: boolean;
issuerUrl: string;
mobileOverrideEnabled: boolean;
@ -253,7 +253,7 @@ export const defaults = Object.freeze<SystemConfig>({
buttonText: 'Login with OAuth',
clientId: '',
clientSecret: '',
defaultStorageQuota: 0,
defaultStorageQuota: null,
enabled: false,
issuerUrl: '',
mobileOverrideEnabled: false,

View File

@ -360,7 +360,9 @@ class SystemConfigOAuthDto {
@IsNumber()
@Min(0)
defaultStorageQuota!: number;
@Optional({ nullable: true })
@ApiProperty({ type: 'integer', format: 'int64' })
defaultStorageQuota!: number | null;
@ValidateBoolean()
enabled!: boolean;

View File

@ -704,7 +704,7 @@ describe(AuthService.name, () => {
expect(mocks.user.create).toHaveBeenCalledWith(expect.objectContaining({ quotaSizeInBytes: 1_073_741_824 }));
});
it('should not set quota for 0 quota', async () => {
it('should set quota for 0 quota', async () => {
const user = factory.userAdmin({ oauthId: 'oauth-id' });
mocks.systemMetadata.get.mockResolvedValue(systemConfigStub.oauthWithStorageQuota);
@ -726,7 +726,7 @@ describe(AuthService.name, () => {
email: user.email,
name: ' ',
oauthId: user.oauthId,
quotaSizeInBytes: null,
quotaSizeInBytes: 0,
storageLabel: null,
});
});

View File

@ -300,7 +300,7 @@ export class AuthService extends BaseService {
name: userName,
email: profile.email,
oauthId: profile.sub,
quotaSizeInBytes: storageQuota * HumanReadableSize.GiB || null,
quotaSizeInBytes: storageQuota === null ? null : storageQuota * HumanReadableSize.GiB,
storageLabel: storageLabel || null,
});
}

View File

@ -112,7 +112,7 @@ const updatedConfig = Object.freeze<SystemConfig>({
buttonText: 'Login with OAuth',
clientId: '',
clientSecret: '',
defaultStorageQuota: 0,
defaultStorageQuota: null,
enabled: false,
issuerUrl: '',
mobileOverrideEnabled: false,

View File

@ -182,7 +182,7 @@
label={$t('admin.oauth_storage_quota_default').toUpperCase()}
description={$t('admin.oauth_storage_quota_default_description')}
bind:value={config.oauth.defaultStorageQuota}
required={true}
required={false}
disabled={disabled || !config.oauth.enabled}
isEdited={!(config.oauth.defaultStorageQuota == savedConfig.oauth.defaultStorageQuota)}
/>

View File

@ -9,7 +9,7 @@
interface Props {
inputType: SettingInputFieldType;
value: string | number | undefined;
value: string | number | undefined | null;
min?: number;
max?: number;
step?: string;