Skip to content

Commit 102571f

Browse files
committed
Add database columns to store OpenID Connect information for Proxy Hosts.
1 parent 46a2911 commit 102571f

File tree

6 files changed

+148
-7
lines changed

6 files changed

+148
-7
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
const migrate_name = 'openid_connect';
2+
const logger = require('../logger').migrate;
3+
4+
/**
5+
* Migrate
6+
*
7+
* @see http://knexjs.org/#Schema
8+
*
9+
* @param {Object} knex
10+
* @param {Promise} Promise
11+
* @returns {Promise}
12+
*/
13+
exports.up = function (knex/*, Promise*/) {
14+
logger.info('[' + migrate_name + '] Migrating Up...');
15+
16+
return knex.schema.table('proxy_host', function (proxy_host) {
17+
proxy_host.integer('openidc_enabled').notNull().unsigned().defaultTo(0);
18+
proxy_host.text('openidc_redirect_uri').notNull().defaultTo('');
19+
proxy_host.text('openidc_discovery').notNull().defaultTo('');
20+
proxy_host.text('openidc_auth_method').notNull().defaultTo('client_secret_post');
21+
proxy_host.text('openidc_client_id').notNull().defaultTo('');
22+
proxy_host.text('openidc_client_secret').notNull().defaultTo('');
23+
})
24+
.then(() => {
25+
logger.info('[' + migrate_name + '] proxy_host Table altered');
26+
});
27+
};
28+
29+
/**
30+
* Undo Migrate
31+
*
32+
* @param {Object} knex
33+
* @param {Promise} Promise
34+
* @returns {Promise}
35+
*/
36+
exports.down = function (knex/*, Promise*/) {
37+
return knex.schema.table('proxy_host', function (proxy_host) {
38+
proxy_host.dropColumn('openidc_enabled');
39+
proxy_host.dropColumn('openidc_redirect_uri');
40+
proxy_host.dropColumn('openidc_discovery');
41+
proxy_host.dropColumn('openidc_auth_method');
42+
proxy_host.dropColumn('openidc_client_id');
43+
proxy_host.dropColumn('openidc_client_secret');
44+
})
45+
.then(() => {
46+
logger.info('[' + migrate_name + '] proxy_host Table altered');
47+
});
48+
};

backend/schema/definitions.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,27 @@
222222
"description": "Should we cache assets",
223223
"example": true,
224224
"type": "boolean"
225+
},
226+
"openidc_enabled": {
227+
"description": "Is OpenID Connect authentication enabled",
228+
"example": true,
229+
"type": "boolean"
230+
},
231+
"openidc_redirect_uri": {
232+
"type": "string"
233+
},
234+
"openidc_discovery": {
235+
"type": "string"
236+
},
237+
"openidc_auth_method": {
238+
"type": "string",
239+
"pattern": "^(client_secret_basic|client_secret_post)$"
240+
},
241+
"openidc_client_id": {
242+
"type": "string"
243+
},
244+
"openidc_client_secret": {
245+
"type": "string"
225246
}
226247
}
227248
}

backend/schema/endpoints/proxy-hosts.json

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,24 @@
6464
"advanced_config": {
6565
"type": "string"
6666
},
67+
"openidc_enabled": {
68+
"$ref": "../definitions.json#/definitions/openidc_enabled"
69+
},
70+
"openidc_redirect_uri": {
71+
"$ref": "../definitions.json#/definitions/openidc_redirect_uri"
72+
},
73+
"openidc_discovery": {
74+
"$ref": "../definitions.json#/definitions/openidc_discovery"
75+
},
76+
"openidc_auth_method": {
77+
"$ref": "../definitions.json#/definitions/openidc_auth_method"
78+
},
79+
"openidc_client_id": {
80+
"$ref": "../definitions.json#/definitions/openidc_client_id"
81+
},
82+
"openidc_client_secret": {
83+
"$ref": "../definitions.json#/definitions/openidc_client_secret"
84+
},
6785
"enabled": {
6886
"$ref": "../definitions.json#/definitions/enabled"
6987
},
@@ -161,6 +179,24 @@
161179
"advanced_config": {
162180
"$ref": "#/definitions/advanced_config"
163181
},
182+
"openidc_enabled": {
183+
"$ref": "#/definitions/openidc_enabled"
184+
},
185+
"openidc_redirect_uri": {
186+
"$ref": "#/definitions/openidc_redirect_uri"
187+
},
188+
"openidc_discovery": {
189+
"$ref": "#/definitions/openidc_discovery"
190+
},
191+
"openidc_auth_method": {
192+
"$ref": "#/definitions/openidc_auth_method"
193+
},
194+
"openidc_client_id": {
195+
"$ref": "#/definitions/openidc_client_id"
196+
},
197+
"openidc_client_secret": {
198+
"$ref": "#/definitions/openidc_client_secret"
199+
},
164200
"enabled": {
165201
"$ref": "#/definitions/enabled"
166202
},
@@ -251,6 +287,24 @@
251287
"advanced_config": {
252288
"$ref": "#/definitions/advanced_config"
253289
},
290+
"openidc_enabled": {
291+
"$ref": "#/definitions/openidc_enabled"
292+
},
293+
"openidc_redirect_uri": {
294+
"$ref": "#/definitions/openidc_redirect_uri"
295+
},
296+
"openidc_discovery": {
297+
"$ref": "#/definitions/openidc_discovery"
298+
},
299+
"openidc_auth_method": {
300+
"$ref": "#/definitions/openidc_auth_method"
301+
},
302+
"openidc_client_id": {
303+
"$ref": "#/definitions/openidc_client_id"
304+
},
305+
"openidc_client_secret": {
306+
"$ref": "#/definitions/openidc_client_secret"
307+
},
254308
"enabled": {
255309
"$ref": "#/definitions/enabled"
256310
},
@@ -324,6 +378,24 @@
324378
"advanced_config": {
325379
"$ref": "#/definitions/advanced_config"
326380
},
381+
"openidc_enabled": {
382+
"$ref": "#/definitions/openidc_enabled"
383+
},
384+
"openidc_redirect_uri": {
385+
"$ref": "#/definitions/openidc_redirect_uri"
386+
},
387+
"openidc_discovery": {
388+
"$ref": "#/definitions/openidc_discovery"
389+
},
390+
"openidc_auth_method": {
391+
"$ref": "#/definitions/openidc_auth_method"
392+
},
393+
"openidc_client_id": {
394+
"$ref": "#/definitions/openidc_client_id"
395+
},
396+
"openidc_client_secret": {
397+
"$ref": "#/definitions/openidc_client_secret"
398+
},
327399
"enabled": {
328400
"$ref": "#/definitions/enabled"
329401
},

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@
185185
<div class="col-sm-12 col-md-12">
186186
<div class="form-group">
187187
<label class="custom-switch">
188-
<input type="checkbox" class="custom-switch-input" name="openidc_enabled" value="1<%- openidc_enabled ? ' checked' : '' %>">
188+
<input type="checkbox" class="custom-switch-input" name="openidc_enabled" value="1"<%- openidc_enabled ? ' checked' : '' %>>
189189
<span class="custom-switch-indicator"></span>
190190
<span class="custom-switch-description">Use OpenID Connect authentication <span class="form-required">*</span></span>
191191
</label>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ module.exports = Mn.View.extend({
9494
},
9595

9696
'change @ui.openidc_enabled': function () {
97-
console.log('Changing');
9897
let checked = this.ui.openidc_enabled.prop('checked');
9998

10099
if (checked) {
@@ -289,6 +288,7 @@ module.exports = Mn.View.extend({
289288

290289
// OpenID Connect
291290
this.ui.openidc.hide().find('input').prop('required', false);
291+
this.ui.openidc_enabled.trigger('change');
292292
},
293293

294294
initialize: function (options) {

frontend/js/models/proxy-host.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ const model = Backbone.Model.extend({
2323
http2_support: false,
2424
advanced_config: '',
2525
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,
26+
openidc_redirect_uri: '',
27+
openidc_discovery: '',
28+
openidc_auth_method: 'client_secret_post',
29+
openidc_client_id: '',
30+
openidc_client_secret: '',
3131
enabled: true,
3232
meta: {},
3333
// The following are expansions:

0 commit comments

Comments
 (0)