1d9b1841c6701a4bc3743e4b11428ff2535f1998
[openwrt-luci.git] /
1 'use strict';
2 'require baseclass';
3 'require form';
4
5 /*
6 UI configuration for example authentication plugin.
7
8 This file provides the configuration interface for the auth plugin
9 in System > Plugins. It defines the plugin metadata and configuration
10 options that will be stored in the luci_plugins UCI config.
11
12 The filename must match the backend plugin UUID (32-char hex).
13 */
14
15 return baseclass.extend({
16         // Plugin classification
17         class: 'auth',
18         class_i18n: _('Authentication'),
19
20         type: 'login',
21         type_i18n: _('Login'),
22
23         // Plugin identity
24         name: 'Example Auth Plugin',
25         id: 'd0ecde1b009d44ff82faa8b0ff219cef',
26         title: _('Example Authentication Plugin'),
27         description: _('A simple example authentication plugin that demonstrates the auth plugin interface. ' +
28                        'This plugin adds a verification code challenge after password login.'),
29
30         // Add configuration form options
31         addFormOptions(s) {
32                 let o;
33
34                 o = s.option(form.Flag, 'enabled', _('Enabled'));
35                 o.default = o.disabled;
36                 o.rmempty = false;
37
38                 o = s.option(form.Value, 'priority', _('Priority'),
39                         _('Execution order. Lower values run first.'));
40                 o.default = '10';
41                 o.datatype = 'integer';
42                 o.depends('enabled', '1');
43
44                 o = s.option(form.Value, 'challenge_field', _('Challenge Field Name'),
45                         _('The form field name for the verification code input.'));
46                 o.default = 'verification_code';
47                 o.rmempty = false;
48                 o.depends('enabled', '1');
49
50                 o = s.option(form.Value, 'help_text', _('Help Text'),
51                         _('Text displayed to help users understand what to enter.'));
52                 o.default = 'Enter your verification code';
53                 o.depends('enabled', '1');
54
55                 o = s.option(form.Value, 'test_code', _('Test Code'),
56                         _('For demonstration purposes, the expected verification code. ' +
57                           'In a real plugin, this would integrate with TOTP/SMS/WebAuthn systems.'));
58                 o.default = '123456';
59                 o.password = true;
60                 o.depends('enabled', '1');
61         },
62
63         // Display current configuration summary
64         configSummary(section) {
65                 if (section.enabled != '1')
66                         return null;
67
68                 const challenge_field = section.challenge_field || 'verification_code';
69                 const help_text = section.help_text || 'Enter your verification code';
70
71                 return _('Field: %s - %s').format(challenge_field, help_text);
72         }
73 });
git clone https://git.99rst.org/PROJECT