1
0
mirror of https://github.com/immich-app/immich.git synced 2024-12-25 10:43:13 +02:00

feat(server): Add OAuth auto-redirect enable/disable CLI commands (#7841)

* Rebase

* format fix

* docs format

* Change to enable/disable oauth master

* spell change for oauth

* Fix filename
This commit is contained in:
Dhrumil Shah 2024-03-11 23:32:00 -04:00 committed by GitHub
parent d09980f646
commit bbed14a9ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 56 additions and 1 deletions

View File

@ -8,6 +8,8 @@ The `immich-server` docker image comes preinstalled with an administrative CLI (
| `reset-admin-password` | Reset the password for the admin user | | `reset-admin-password` | Reset the password for the admin user |
| `disable-password-login` | Disable password login | | `disable-password-login` | Disable password login |
| `enable-password-login` | Enable password login | | `enable-password-login` | Enable password login |
| `enable-oauth-login` | Enable OAuth login |
| `disable-oauth-login` | Disable OAuth login |
| `list-users` | List Immich users | | `list-users` | List Immich users |
## How to run a command ## How to run a command
@ -36,13 +38,27 @@ immich-admin disable-password-login
Password login has been disabled. Password login has been disabled.
``` ```
Enabled Password Login Enable Password Login
``` ```
immich-admin enable-password-login immich-admin enable-password-login
Password login has been enabled. Password login has been enabled.
``` ```
Enable OAuth login
```
immich-admin enable-oauth-login
OAuth login has been enabled.
```
Disable OAuth login
```
immich-admin disable-oauth-login
OAuth login has been disabled.
```
List Users List Users
``` ```

View File

@ -2,6 +2,7 @@ import { DomainModule } from '@app/domain';
import { InfraModule } from '@app/infra'; import { InfraModule } from '@app/infra';
import { Module } from '@nestjs/common'; import { Module } from '@nestjs/common';
import { ListUsersCommand } from './commands/list-users.command'; import { ListUsersCommand } from './commands/list-users.command';
import { DisableOAuthLogin, EnableOAuthLogin } from './commands/oauth-login';
import { DisablePasswordLoginCommand, EnablePasswordLoginCommand } from './commands/password-login'; import { DisablePasswordLoginCommand, EnablePasswordLoginCommand } from './commands/password-login';
import { PromptPasswordQuestions, ResetAdminPasswordCommand } from './commands/reset-admin-password.command'; import { PromptPasswordQuestions, ResetAdminPasswordCommand } from './commands/reset-admin-password.command';
@ -12,6 +13,8 @@ import { PromptPasswordQuestions, ResetAdminPasswordCommand } from './commands/r
PromptPasswordQuestions, PromptPasswordQuestions,
EnablePasswordLoginCommand, EnablePasswordLoginCommand,
DisablePasswordLoginCommand, DisablePasswordLoginCommand,
EnableOAuthLogin,
DisableOAuthLogin,
ListUsersCommand, ListUsersCommand,
], ],
}) })

View File

@ -0,0 +1,36 @@
import { SystemConfigService } from '@app/domain';
import { Command, CommandRunner } from 'nest-commander';
@Command({
name: 'enable-oauth-login',
description: 'Enable OAuth login',
})
export class EnableOAuthLogin extends CommandRunner {
constructor(private configService: SystemConfigService) {
super();
}
async run(): Promise<void> {
const config = await this.configService.getConfig();
config.oauth.enabled = true;
await this.configService.updateConfig(config);
console.log('OAuth login has been enabled.');
}
}
@Command({
name: 'disable-oauth-login',
description: 'Disable OAuth login',
})
export class DisableOAuthLogin extends CommandRunner {
constructor(private configService: SystemConfigService) {
super();
}
async run(): Promise<void> {
const config = await this.configService.getConfig();
config.oauth.enabled = false;
await this.configService.updateConfig(config);
console.log('OAuth login has been disabled.');
}
}