Skip to content

Commit 6be3af8

Browse files
committed
feat: cleanup disclaimer and command to add users
1 parent 2ceb5da commit 6be3af8

File tree

3 files changed

+27
-14
lines changed

3 files changed

+27
-14
lines changed

api/src/unraid-api/cli/sso/add-sso-user.command.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,21 @@ export class AddSSOUserCommand extends CommandRunner {
2828
}
2929

3030
async run(_input: string[], options: AddSSOUserCommandOptions): Promise<void> {
31-
options = await this.inquirerService.prompt(AddSSOUserQuestionSet.name, options);
31+
try {
32+
options = await this.inquirerService.prompt(AddSSOUserQuestionSet.name, options);
3233

33-
if (options.disclaimer === 'y') {
34-
await store.dispatch(loadConfigFile());
35-
store.dispatch(addSsoUser(options.username));
36-
writeConfigSync('flash');
37-
this.logger.info('User added ' + options.username);
34+
if (options.disclaimer === 'y' && options.username) {
35+
await store.dispatch(loadConfigFile());
36+
store.dispatch(addSsoUser(options.username));
37+
writeConfigSync('flash');
38+
this.logger.info('User added ' + options.username);
39+
}
40+
} catch (e: unknown) {
41+
if (e instanceof Error) {
42+
this.logger.error('Error adding user: ' + e.message);
43+
} else {
44+
this.logger.error('Error adding user');
45+
}
3846
}
3947
}
4048

api/src/unraid-api/cli/sso/add-sso-user.questions.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Question, QuestionSet } from 'nest-commander';
2+
import { v4 as uuidv4 } from 'uuid';
23

34

45

@@ -9,7 +10,12 @@ export class AddSSOUserQuestionSet {
910
static name = 'add-user';
1011

1112
@Question({
12-
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)',
13+
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.
14+
15+
Please note: your existing username and password will continue to work alongside SSO.
16+
17+
Are you sure you want to proceed with adding a user for SSO? (y/n)
18+
`,
1319
name: 'disclaimer',
1420
validate(input) {
1521
if (!input) {
@@ -29,14 +35,17 @@ export class AddSSOUserQuestionSet {
2935
}
3036

3137
@Question({
32-
message: 'What is the cognito username (NOT YOUR UNRAID USERNAME)? Find it in your Unraid Account at https://account.unraid.net',
38+
message:
39+
"What is your Unique Unraid Account ID? Find it in your Unraid Account at https://account.unraid.net/settings\n",
3340
name: 'username',
3441
validate(input) {
3542
if (!input) {
3643
return 'Username is required';
3744
}
38-
if (!/^[a-zA-Z0-9-]+$/.test(input)) {
39-
return 'Username must be alphanumeric and can include dashes.';
45+
const randomUUID = uuidv4();
46+
47+
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)) {
48+
return `Username must be in the format of a UUID (e.g., ${randomUUID}).`;
4049
}
4150
return true;
4251
},

plugin/plugins/dynamix.unraid.net.plg

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -759,10 +759,6 @@ if ([[ -n "${email}" && (-z "${apikey}" || "${#apikey}" -ne "64") ]]); then
759759
}' "${CFG}">"${CFG}-new" && mv "${CFG}-new" "${CFG}" CFG_CLEANED=1
760760
echo "⚠️ Automatically signed out of Unraid.net"
761761
fi
762-
# if there wasn't an email or the CFG was cleaned
763-
if [[ -z "${email}" ]] || [[ CFG_CLEANED -eq 1 ]]; then
764-
echo "✨ Sign In to Unraid.net to use Unraid Connect ✨"
765-
fi
766762
767763
# configure flash backup to stop when the system starts shutting down
768764
[[ ! -d /etc/rc.d/rc6.d ]] && mkdir /etc/rc.d/rc6.d

0 commit comments

Comments
 (0)