mirror of
https://github.com/unraid/api.git
synced 2025-12-31 13:39:52 -06:00
feat: cleanup disclaimer and command to add users
This commit is contained in:
@@ -28,13 +28,21 @@ export class AddSSOUserCommand extends CommandRunner {
|
||||
}
|
||||
|
||||
async run(_input: string[], options: AddSSOUserCommandOptions): Promise<void> {
|
||||
options = await this.inquirerService.prompt(AddSSOUserQuestionSet.name, options);
|
||||
try {
|
||||
options = await this.inquirerService.prompt(AddSSOUserQuestionSet.name, options);
|
||||
|
||||
if (options.disclaimer === 'y') {
|
||||
await store.dispatch(loadConfigFile());
|
||||
store.dispatch(addSsoUser(options.username));
|
||||
writeConfigSync('flash');
|
||||
this.logger.info('User added ' + options.username);
|
||||
if (options.disclaimer === 'y' && options.username) {
|
||||
await store.dispatch(loadConfigFile());
|
||||
store.dispatch(addSsoUser(options.username));
|
||||
writeConfigSync('flash');
|
||||
this.logger.info('User added ' + options.username);
|
||||
}
|
||||
} catch (e: unknown) {
|
||||
if (e instanceof Error) {
|
||||
this.logger.error('Error adding user: ' + e.message);
|
||||
} else {
|
||||
this.logger.error('Error adding user');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Question, QuestionSet } from 'nest-commander';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
|
||||
|
||||
@@ -9,7 +10,12 @@ export class AddSSOUserQuestionSet {
|
||||
static name = 'add-user';
|
||||
|
||||
@Question({
|
||||
message: 'Are you sure you wish to add a user for SSO - this will enable single sign on in Unraid and has certain security implications? (y/n)',
|
||||
message: `Enabling Single Sign-On (SSO) will simplify authentication by centralizing access to your Unraid server. However, this comes with certain security considerations: if your SSO account is compromised, unauthorized access to your server could occur.
|
||||
|
||||
Please note: your existing username and password will continue to work alongside SSO.
|
||||
|
||||
Are you sure you want to proceed with adding a user for SSO? (y/n)
|
||||
`,
|
||||
name: 'disclaimer',
|
||||
validate(input) {
|
||||
if (!input) {
|
||||
@@ -29,14 +35,17 @@ export class AddSSOUserQuestionSet {
|
||||
}
|
||||
|
||||
@Question({
|
||||
message: 'What is the cognito username (NOT YOUR UNRAID USERNAME)? Find it in your Unraid Account at https://account.unraid.net',
|
||||
message:
|
||||
"What is your Unique Unraid Account ID? Find it in your Unraid Account at https://account.unraid.net/settings\n",
|
||||
name: 'username',
|
||||
validate(input) {
|
||||
if (!input) {
|
||||
return 'Username is required';
|
||||
}
|
||||
if (!/^[a-zA-Z0-9-]+$/.test(input)) {
|
||||
return 'Username must be alphanumeric and can include dashes.';
|
||||
const randomUUID = uuidv4();
|
||||
|
||||
if (!/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/.test(input)) {
|
||||
return `Username must be in the format of a UUID (e.g., ${randomUUID}).`;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
@@ -759,10 +759,6 @@ if ([[ -n "${email}" && (-z "${apikey}" || "${#apikey}" -ne "64") ]]); then
|
||||
}' "${CFG}">"${CFG}-new" && mv "${CFG}-new" "${CFG}" CFG_CLEANED=1
|
||||
echo "⚠️ Automatically signed out of Unraid.net"
|
||||
fi
|
||||
# if there wasn't an email or the CFG was cleaned
|
||||
if [[ -z "${email}" ]] || [[ CFG_CLEANED -eq 1 ]]; then
|
||||
echo "✨ Sign In to Unraid.net to use Unraid Connect ✨"
|
||||
fi
|
||||
|
||||
# configure flash backup to stop when the system starts shutting down
|
||||
[[ ! -d /etc/rc.d/rc6.d ]] && mkdir /etc/rc.d/rc6.d
|
||||
|
||||
Reference in New Issue
Block a user