mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-09-16 20:00:35 +00:00
Merge eb312cc61d
into 4ea50ca40c
This commit is contained in:
@@ -59,6 +59,11 @@ function fetch(verb, path, data, options) {
|
||||
},
|
||||
|
||||
beforeSend: function (xhr) {
|
||||
// Allow unauthenticated access to get the oidc configuration
|
||||
if (path === 'settings/oidc-config' && verb === "get") {
|
||||
return;
|
||||
}
|
||||
|
||||
xhr.setRequestHeader('Authorization', 'Bearer ' + (token ? token.t : null));
|
||||
},
|
||||
|
||||
|
@@ -434,6 +434,11 @@ module.exports = {
|
||||
App.UI.showModalDialog(new View({model: model}));
|
||||
});
|
||||
}
|
||||
if (model.get('id') === 'oidc-config') {
|
||||
require(['./main', './settings/oidc-config/main'], function (App, View) {
|
||||
App.UI.showModalDialog(new View({model: model}));
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
@@ -1,7 +1,19 @@
|
||||
<td>
|
||||
<div><%- i18n('settings', 'default-site') %></div>
|
||||
<div>
|
||||
<% if (id === 'default-site') { %>
|
||||
<%- i18n('settings', 'default-site') %>
|
||||
<% } %>
|
||||
<% if (id === 'oidc-config') { %>
|
||||
<%- i18n('settings', 'oidc-config') %>
|
||||
<% } %>
|
||||
</div>
|
||||
<div class="small text-muted">
|
||||
<%- i18n('settings', 'default-site-description') %>
|
||||
<% if (id === 'default-site') { %>
|
||||
<%- i18n('settings', 'default-site-description') %>
|
||||
<% } %>
|
||||
<% if (id === 'oidc-config') { %>
|
||||
<%- i18n('settings', 'oidc-config-description') %>
|
||||
<% } %>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
@@ -9,6 +21,14 @@
|
||||
<% if (id === 'default-site') { %>
|
||||
<%- i18n('settings', 'default-site-' + value) %>
|
||||
<% } %>
|
||||
<% if (id === 'oidc-config' && meta && meta.name && meta.clientID && meta.clientSecret && meta.issuerURL && meta.redirectURL) { %>
|
||||
<%- meta.name %>
|
||||
<% if (!meta.enabled) { %>
|
||||
(<%- i18n('str', 'disabled') %>)
|
||||
<% } %>
|
||||
<% } else if (id === 'oidc-config') { %>
|
||||
<%- i18n('settings', 'oidc-not-configured') %>
|
||||
<% } %>
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
|
56
frontend/js/app/settings/oidc-config/main.ejs
Normal file
56
frontend/js/app/settings/oidc-config/main.ejs
Normal file
@@ -0,0 +1,56 @@
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title"><%- i18n('settings', id) %></h5>
|
||||
<button type="button" class="close cancel" aria-label="Close" data-dismiss="modal"> </button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form>
|
||||
<div class="row">
|
||||
<div class="col-sm-12 col-md-12">
|
||||
<div class="form-group">
|
||||
<div class="form-label"><%- description %></div>
|
||||
<div>
|
||||
<p><%- i18n('settings', 'oidc-config-hint-1') %></p>
|
||||
<p><%- i18n('settings', 'oidc-config-hint-2') %></p>
|
||||
</div>
|
||||
<div class="custom-controls-stacked">
|
||||
<div class="form-group">
|
||||
<label class="form-label"><%- i18n('str', 'name') %> <span class="form-required">*</span>
|
||||
<input class="form-control name-input" name="meta[name]" required type="text" value="<%- meta && typeof meta.name !== 'undefined' ? meta.name : '' %>">
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label">Client ID <span class="form-required">*</span>
|
||||
<input class="form-control id-input" name="meta[clientID]" required type="text" value="<%- meta && typeof meta.clientID !== 'undefined' ? meta.clientID : '' %>">
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label">Client Secret <span class="form-required">*</span>
|
||||
<input class="form-control secret-input" name="meta[clientSecret]" required type="text" value="<%- meta && typeof meta.clientSecret !== 'undefined' ? meta.clientSecret : '' %>">
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label">Issuer URL <span class="form-required">*</span>
|
||||
<input class="form-control issuer-input" name="meta[issuerURL]" required placeholder="https://" type="url" value="<%- meta && typeof meta.issuerURL !== 'undefined' ? meta.issuerURL : '' %>">
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label">Redirect URL <span class="form-required">*</span>
|
||||
<input class="form-control redirect-url-input" name="meta[redirectURL]" required placeholder="https://" type="url" value="<%- meta && typeof meta.redirectURL !== 'undefined' ? meta.redirectURL : document.location.origin + '/api/oidc/callback' %>">
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="form-label"><%- i18n('str', 'enable') %></div>
|
||||
<input class="form-check enabled-input" name="meta[enabled]" placeholder="" type="checkbox" <%- meta && (typeof meta.enabled !== 'undefined' && meta.enabled === true) || (JSON.stringify(meta) === '{}') ? 'checked="checked"' : '' %> >
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary cancel" data-dismiss="modal"><%- i18n('str', 'cancel') %></button>
|
||||
<button type="button" class="btn btn-teal save"><%- i18n('str', 'save') %></button>
|
||||
</div>
|
||||
</div>
|
46
frontend/js/app/settings/oidc-config/main.js
Normal file
46
frontend/js/app/settings/oidc-config/main.js
Normal file
@@ -0,0 +1,46 @@
|
||||
const Mn = require('backbone.marionette');
|
||||
const App = require('../../main');
|
||||
const template = require('./main.ejs');
|
||||
|
||||
require('jquery-serializejson');
|
||||
|
||||
module.exports = Mn.View.extend({
|
||||
template: template,
|
||||
className: 'modal-dialog wide',
|
||||
|
||||
ui: {
|
||||
form: 'form',
|
||||
buttons: '.modal-footer button',
|
||||
cancel: 'button.cancel',
|
||||
save: 'button.save',
|
||||
},
|
||||
|
||||
events: {
|
||||
'click @ui.save': function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
if (!this.ui.form[0].checkValidity()) {
|
||||
$('<input type="submit">').hide().appendTo(this.ui.form).click().remove();
|
||||
return;
|
||||
}
|
||||
|
||||
let view = this;
|
||||
let data = this.ui.form.serializeJSON();
|
||||
data.id = this.model.get('id');
|
||||
if (data.meta.enabled) {
|
||||
data.meta.enabled = data.meta.enabled === 'on' || data.meta.enabled === 'true';
|
||||
}
|
||||
|
||||
this.ui.buttons.prop('disabled', true).addClass('btn-disabled');
|
||||
App.Api.Settings.update(data)
|
||||
.then((result) => {
|
||||
view.model.set(result);
|
||||
App.UI.closeModal();
|
||||
})
|
||||
.catch((err) => {
|
||||
alert(err.message);
|
||||
this.ui.buttons.prop('disabled', false).removeClass('btn-disabled');
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user