Skip to content

Commit 8e10b7d

Browse files
Subvjc21
authored andcommitted
Add UI tab for specifying OpenID Connect options for proxy hosts.
1 parent fb8f2c2 commit 8e10b7d

File tree

3 files changed

+86
-8
lines changed

3 files changed

+86
-8
lines changed

frontend/js/app/nginx/proxy/form.ejs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<li role="presentation" class="nav-item"><a href="#locations" aria-controls="tab4" role="tab" data-toggle="tab" class="nav-link"><i class="fe fe-layers"></i> <%- i18n('all-hosts', 'locations') %></a></li>
1212
<li role="presentation" class="nav-item"><a href="#ssl-options" aria-controls="tab2" role="tab" data-toggle="tab" class="nav-link"><i class="fe fe-shield"></i> <%- i18n('str', 'ssl') %></a></li>
1313
<li role="presentation" class="nav-item"><a href="#advanced" aria-controls="tab3" role="tab" data-toggle="tab" class="nav-link"><i class="fe fe-settings"></i> <%- i18n('all-hosts', 'advanced') %></a></li>
14+
<li role="presentation" class="nav-item"><a href="#openidc" aria-controls="tab3" role="tab" data-toggle="tab" class="nav-link"><i class="fe fe-settings"></i>OpenID Connect</a></li>
1415
</ul>
1516
<div class="tab-content">
1617

@@ -270,6 +271,54 @@
270271
</div>
271272
</div>
272273
</div>
274+
275+
<!-- OpenID Connect -->
276+
<div role="tabpanel" class="tab-pane" id="openidc">
277+
<div class="row">
278+
<div class="col-sm-12 col-md-12">
279+
<div class="form-group">
280+
<label class="custom-switch">
281+
<input type="checkbox" class="custom-switch-input" name="openidc_enabled" value="1<%- openidc_enabled ? ' checked' : '' %>">
282+
<span class="custom-switch-indicator"></span>
283+
<span class="custom-switch-description">Use OpenID Connect authentication <span class="form-required">*</span></span>
284+
</label>
285+
</div>
286+
</div>
287+
<div class="col-sm-12 col-md-12 openidc">
288+
<div class="form-group">
289+
<label class="form-label">Redirect URI<span class="form-required">*</span></label>
290+
<input type="text" name="openidc_redirect_uri" class="form-control text-monospace" placeholder="" value="<%- openidc_redirect_uri %>" autocomplete="off" maxlength="255" required>
291+
</div>
292+
</div>
293+
<div class="col-sm-12 col-md-12 openidc">
294+
<div class="form-group">
295+
<label class="form-label">Well-known discovery endpoint<span class="form-required">*</span></label>
296+
<input type="text" name="openidc_discovery" class="form-control text-monospace" placeholder="" value="<%- openidc_discovery %>" autocomplete="off" maxlength="255" required>
297+
</div>
298+
</div>
299+
<div class="col-sm-12 col-md-12 openidc">
300+
<div class="form-group">
301+
<label class="form-label">Token endpoint auth method<span class="form-required">*</span></label>
302+
<select name="openidc_auth_method" class="form-control custom-select" placeholder="client_secret_post">
303+
<option value="client_secret_post" <%- openidc_auth_method === 'client_secret_post' ? 'selected' : '' %>>client_secret_post</option>
304+
<option value="client_secret_basic" <%- openidc_auth_method === 'client_secret_basic' ? 'selected' : '' %>>client_secret_basic</option>
305+
</select>
306+
</div>
307+
</div>
308+
<div class="col-sm-12 col-md-12 openidc">
309+
<div class="form-group">
310+
<label class="form-label">Client ID<span class="form-required">*</span></label>
311+
<input type="text" name="openidc_client_id" class="form-control text-monospace" placeholder="" value="<%- openidc_client_id %>" autocomplete="off" maxlength="255" required>
312+
</div>
313+
</div>
314+
<div class="col-sm-12 col-md-12 openidc">
315+
<div class="form-group">
316+
<label class="form-label">Client secret<span class="form-required">*</span></label>
317+
<input type="text" name="openidc_client_secret" class="form-control text-monospace" placeholder="" value="<%- openidc_client_secret %>" autocomplete="off" maxlength="255" required>
318+
</div>
319+
</div>
320+
</div>
321+
</div>
273322
</div>
274323
</form>
275324
</div>

frontend/js/app/nginx/proxy/form.js

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ module.exports = Mn.View.extend({
4343
dns_provider_credentials: 'textarea[name="meta[dns_provider_credentials]"]',
4444
propagation_seconds: 'input[name="meta[propagation_seconds]"]',
4545
forward_scheme: 'select[name="forward_scheme"]',
46-
letsencrypt: '.letsencrypt'
46+
letsencrypt: '.letsencrypt',
47+
openidc_enabled: 'input[name="openidc_enabled"]',
48+
openidc: '.openidc'
4749
},
4850

4951
regions: {
@@ -113,7 +115,7 @@ module.exports = Mn.View.extend({
113115
} else {
114116
this.ui.dns_provider.prop('required', false);
115117
this.ui.dns_provider_credentials.prop('required', false);
116-
this.ui.dns_challenge_content.hide();
118+
this.ui.dns_challenge_content.hide();
117119
}
118120
},
119121

@@ -125,13 +127,24 @@ module.exports = Mn.View.extend({
125127
this.ui.credentials_file_content.show();
126128
} else {
127129
this.ui.dns_provider_credentials.prop('required', false);
128-
this.ui.credentials_file_content.hide();
130+
this.ui.credentials_file_content.hide();
131+
}
132+
},
133+
134+
'change @ui.openidc_enabled': function () {
135+
console.log('Changing');
136+
let checked = this.ui.openidc_enabled.prop('checked');
137+
138+
if (checked) {
139+
this.ui.openidc.show().find('input').prop('required', true);
140+
} else {
141+
this.ui.openidc.hide().find('input').prop('required', false);
129142
}
130143
},
131144

132145
'click @ui.add_location_btn': function (e) {
133146
e.preventDefault();
134-
147+
135148
const model = new ProxyLocationModel.Model();
136149
this.locationsCollection.add(model);
137150
},
@@ -167,25 +180,26 @@ module.exports = Mn.View.extend({
167180
data.hsts_enabled = !!data.hsts_enabled;
168181
data.hsts_subdomains = !!data.hsts_subdomains;
169182
data.ssl_forced = !!data.ssl_forced;
170-
183+
data.openidc_enabled = data.openidc_enabled === '1';
184+
171185
if (typeof data.meta === 'undefined') data.meta = {};
172186
data.meta.letsencrypt_agree = data.meta.letsencrypt_agree == 1;
173187
data.meta.dns_challenge = data.meta.dns_challenge == 1;
174-
188+
175189
if(!data.meta.dns_challenge){
176190
data.meta.dns_provider = undefined;
177191
data.meta.dns_provider_credentials = undefined;
178192
data.meta.propagation_seconds = undefined;
179193
} else {
180-
if(data.meta.propagation_seconds === '') data.meta.propagation_seconds = undefined;
194+
if(data.meta.propagation_seconds === '') data.meta.propagation_seconds = undefined;
181195
}
182196

183197
if (typeof data.domain_names === 'string' && data.domain_names) {
184198
data.domain_names = data.domain_names.split(',');
185199
}
186200

187201
// Check for any ___domain names containing wildcards, which are not allowed with letsencrypt
188-
if (data.certificate_id === 'new') {
202+
if (data.certificate_id === 'new') {
189203
let domain_err = false;
190204
if (!data.meta.dns_challenge) {
191205
data.domain_names.map(function (name) {
@@ -203,6 +217,12 @@ module.exports = Mn.View.extend({
203217
data.certificate_id = parseInt(data.certificate_id, 10);
204218
}
205219

220+
// OpenID Connect won't work with multiple ___domain names because the redirect URL has to point to a specific one
221+
if (data.openidc_enabled && data.domain_names.length > 1) {
222+
alert('Cannot use mutliple ___domain names when OpenID Connect is enabled');
223+
return;
224+
}
225+
206226
let method = App.Api.Nginx.ProxyHosts.create;
207227
let is_new = true;
208228

@@ -344,6 +364,9 @@ module.exports = Mn.View.extend({
344364
view.ui.certificate_select[0].selectize.setValue(view.model.get('certificate_id'));
345365
}
346366
});
367+
368+
// OpenID Connect
369+
this.ui.openidc.hide().find('input').prop('required', false);
347370
},
348371

349372
initialize: function (options) {

frontend/js/models/proxy-host.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ const model = Backbone.Model.extend({
2222
block_exploits: false,
2323
http2_support: false,
2424
advanced_config: '',
25+
openidc_enabled: false,
26+
openidc_redirect_uri: null,
27+
openidc_discovery: null,
28+
openidc_auth_method: null,
29+
openidc_client_id: null,
30+
openidc_client_secret: null,
2531
enabled: true,
2632
meta: {},
2733
// The following are expansions:

0 commit comments

Comments
 (0)