Merge pull request #653 from jmwebslave/dont-pass-auth-header

Pass/Don't Pass Auth Header
This commit is contained in:
jc21 2020-10-15 10:10:33 +10:00 committed by GitHub
commit e3b680c351
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 71 additions and 1 deletions

View File

@ -31,6 +31,7 @@ const internalAccessList = {
.insertAndFetch({ .insertAndFetch({
name: data.name, name: data.name,
satisfy_any: data.satisfy_any, satisfy_any: data.satisfy_any,
pass_auth: data.pass_auth,
owner_user_id: access.token.getUserId(1) owner_user_id: access.token.getUserId(1)
}); });
}) })
@ -128,6 +129,7 @@ const internalAccessList = {
.patch({ .patch({
name: data.name, name: data.name,
satisfy_any: data.satisfy_any, satisfy_any: data.satisfy_any,
pass_auth: data.pass_auth,
}); });
} }
}) })

View File

@ -0,0 +1,41 @@
const migrate_name = 'pass_auth';
const logger = require('../logger').migrate;
/**
* Migrate
*
* @see http://knexjs.org/#Schema
*
* @param {Object} knex
* @param {Promise} Promise
* @returns {Promise}
*/
exports.up = function (knex/*, Promise*/) {
logger.info('[' + migrate_name + '] Migrating Up...');
return knex.schema.table('access_list', function (access_list) {
access_list.integer('pass_auth').notNull().defaultTo(1);
})
.then(() => {
logger.info('[' + migrate_name + '] access_list Table altered');
});
};
/**
* Undo Migrate
*
* @param {Object} knex
* @param {Promise} Promise
* @returns {Promise}
*/
exports.down = function (knex/*, Promise*/) {
logger.info('[' + migrate_name + '] Migrating Down...');
return knex.schema.table('access_list', function (access_list) {
access_list.dropColumn('pass_auth');
})
.then(() => {
logger.info('[' + migrate_name + '] access_list pass_auth Column dropped');
});
};

View File

@ -93,6 +93,10 @@ class AccessList extends Model {
get satisfy() { get satisfy() {
return this.satisfy_any ? 'satisfy any' : 'satisfy all'; return this.satisfy_any ? 'satisfy any' : 'satisfy all';
} }
get passauth() {
return this.pass_auth ? '' : 'proxy_set_header Authorization "";';
}
} }
module.exports = AccessList; module.exports = AccessList;

View File

@ -42,6 +42,9 @@
"satisfy_any": { "satisfy_any": {
"type": "boolean" "type": "boolean"
}, },
"pass_auth": {
"type": "boolean"
},
"meta": { "meta": {
"type": "object" "type": "object"
} }
@ -102,6 +105,9 @@
"satisfy_any": { "satisfy_any": {
"$ref": "#/definitions/satisfy_any" "$ref": "#/definitions/satisfy_any"
}, },
"pass_auth": {
"$ref": "#/definitions/pass_auth"
},
"items": { "items": {
"type": "array", "type": "array",
"minItems": 0, "minItems": 0,
@ -167,6 +173,9 @@
"satisfy_any": { "satisfy_any": {
"$ref": "#/definitions/satisfy_any" "$ref": "#/definitions/satisfy_any"
}, },
"pass_auth": {
"$ref": "#/definitions/pass_auth"
},
"items": { "items": {
"type": "array", "type": "array",
"minItems": 0, "minItems": 0,

View File

@ -27,6 +27,8 @@ server {
# Authorization # Authorization
auth_basic "Authorization required"; auth_basic "Authorization required";
auth_basic_user_file /data/access/{{ access_list_id }}; auth_basic_user_file /data/access/{{ access_list_id }};
{{ access_list.passauth }}
{% endif %} {% endif %}
# Access Rules # Access Rules

View File

@ -31,6 +31,16 @@
</label> </label>
</div> </div>
</div> </div>
<div class="col-sm-6 col-md-6">
<div class="form-group">
<label class="custom-switch">
<input type="checkbox" class="custom-switch-input" name="pass_auth" value="1"<%- typeof pass_auth !== 'undefined' && pass_auth ? ' checked' : '' %>>
<span class="custom-switch-indicator"></span>
<span class="custom-switch-description"><%- i18n('access-lists', 'pass-auth') %></span>
</label>
</div>
</div>
</div> </div>
</div> </div>

View File

@ -73,6 +73,7 @@ module.exports = Mn.View.extend({
let data = { let data = {
name: form_data.name, name: form_data.name,
satisfy_any: !!form_data.satisfy_any, satisfy_any: !!form_data.satisfy_any,
pass_auth: !!form_data.pass_auth,
items: items_data, items: items_data,
clients: clients_data clients: clients_data
}; };

View File

@ -206,7 +206,8 @@
"authorization": "Authorization", "authorization": "Authorization",
"access": "Access", "access": "Access",
"satisfy": "Satisfy", "satisfy": "Satisfy",
"satisfy-any": "Satisfy Any" "satisfy-any": "Satisfy Any",
"pass-auth": "Pass Auth to Host"
}, },
"users": { "users": {
"title": "Users", "title": "Users",