New ACS: SE allows checking if various services are enabled
This commit is contained in:
parent
86d2aeb9de
commit
22349a23ec
|
@ -936,6 +936,7 @@ function peg$parse(input, options) {
|
||||||
const UserProps = require('./user_property.js');
|
const UserProps = require('./user_property.js');
|
||||||
const Log = require('./logger.js').log;
|
const Log = require('./logger.js').log;
|
||||||
const User = require('./user.js');
|
const User = require('./user.js');
|
||||||
|
const Config = require('./config.js').get;
|
||||||
|
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const moment = require('moment');
|
const moment = require('moment');
|
||||||
|
@ -946,6 +947,86 @@ function peg$parse(input, options) {
|
||||||
function checkAccess(acsCode, value) {
|
function checkAccess(acsCode, value) {
|
||||||
try {
|
try {
|
||||||
return {
|
return {
|
||||||
|
SE: function servicesEnabled() {
|
||||||
|
if (!Array.isArray(value)) {
|
||||||
|
value = [value];
|
||||||
|
}
|
||||||
|
const config = Config();
|
||||||
|
const webEnabled = () => {
|
||||||
|
return (
|
||||||
|
true === _.get(config, 'contentServers.web.http.enabled') ||
|
||||||
|
true === _.get(config, 'contentServers.web.https.enabled')
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const allEnabled = value.every(svcName => {
|
||||||
|
switch (svcName) {
|
||||||
|
case 'http':
|
||||||
|
return (
|
||||||
|
true ===
|
||||||
|
_.get(config, 'contentServers.web.http.enabled')
|
||||||
|
);
|
||||||
|
|
||||||
|
case 'https':
|
||||||
|
return (
|
||||||
|
true ===
|
||||||
|
_.get(config, 'contentServers.web.https.enabled')
|
||||||
|
);
|
||||||
|
|
||||||
|
case 'web':
|
||||||
|
return webEnabled();
|
||||||
|
|
||||||
|
case 'gopher':
|
||||||
|
return (
|
||||||
|
true ===
|
||||||
|
_.get(config, 'contentServers.gopher.enabled')
|
||||||
|
);
|
||||||
|
|
||||||
|
case 'nttp':
|
||||||
|
return (
|
||||||
|
true ===
|
||||||
|
_.get(config, 'contentServers.nntp.nntp.enabled')
|
||||||
|
);
|
||||||
|
|
||||||
|
case 'nntps':
|
||||||
|
return (
|
||||||
|
true ===
|
||||||
|
_.get(config, 'contentServers.nntp.nntps.enabled')
|
||||||
|
);
|
||||||
|
|
||||||
|
case 'activitypub':
|
||||||
|
return (
|
||||||
|
webEnabled() &&
|
||||||
|
true ===
|
||||||
|
_.get(
|
||||||
|
config,
|
||||||
|
'contentServers.web.handlers.activityPub.enabled'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
case 'nodeinfo2':
|
||||||
|
return (
|
||||||
|
webEnabled() &&
|
||||||
|
true ===
|
||||||
|
_.get(
|
||||||
|
config,
|
||||||
|
'contentServers.web.handlers.nodeInfo2.enabled'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
case 'webfinger':
|
||||||
|
return (
|
||||||
|
webEnabled() &&
|
||||||
|
true ===
|
||||||
|
_.get(
|
||||||
|
config,
|
||||||
|
'contentServers.web.handlers.webFinger.enabled'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return allEnabled;
|
||||||
|
},
|
||||||
LC: function isLocalConnection() {
|
LC: function isLocalConnection() {
|
||||||
return client && client.isLocal();
|
return client && client.isLocal();
|
||||||
},
|
},
|
||||||
|
|
|
@ -911,6 +911,10 @@ module.exports = () => {
|
||||||
name: 'ActivityPub',
|
name: 'ActivityPub',
|
||||||
desc: 'Public ActivityPub messages',
|
desc: 'Public ActivityPub messages',
|
||||||
|
|
||||||
|
acs: {
|
||||||
|
read: 'GM[users]SE[activitypub]',
|
||||||
|
},
|
||||||
|
|
||||||
areas: {
|
areas: {
|
||||||
activitypub_shared: {
|
activitypub_shared: {
|
||||||
name: 'ActivityPub Public',
|
name: 'ActivityPub Public',
|
||||||
|
|
|
@ -50,6 +50,7 @@ The following are ACS codes available as of this writing:
|
||||||
| AF<i>authFactor</i> | User's current *Authentication Factor* is >= _authFactor_. Authentication factor 1 refers to username + password (or PubKey) while factor 2 refers to 2FA such as One-Time-Password authentication. |
|
| AF<i>authFactor</i> | User's current *Authentication Factor* is >= _authFactor_. Authentication factor 1 refers to username + password (or PubKey) while factor 2 refers to 2FA such as One-Time-Password authentication. |
|
||||||
| AR<i>authFactorReq</i> | Current user **requires** an Authentication Factor >= _authFactorReq_ |
|
| AR<i>authFactorReq</i> | Current user **requires** an Authentication Factor >= _authFactorReq_ |
|
||||||
| PV[_name,_value_] | Checks that the property by _name_ for the current user is exactly _value_. This ACS allows arbitrary user property values to be checked. For example, `PV[message_conf,local]` checks that the user is currently in the "local" message conference.
|
| PV[_name,_value_] | Checks that the property by _name_ for the current user is exactly _value_. This ACS allows arbitrary user property values to be checked. For example, `PV[message_conf,local]` checks that the user is currently in the "local" message conference.
|
||||||
|
| SE[_service_,_service_,...] | Checks that all services listed by _service_ listed are enabled. Available services: `http`, `https`, `web` (`http` or `https`), `gopher`, `nntp`, `nntps`, `activitypub` (requires `web`), `nodeinfo2` (requires `web`), `webfinger` (requires `web`). Example: `SE[activitypub]`.
|
||||||
|
|
||||||
## ACS Strings
|
## ACS Strings
|
||||||
ACS strings are one or more ACS codes in addition to some basic language semantics.
|
ACS strings are one or more ACS codes in addition to some basic language semantics.
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
const UserProps = require('./user_property.js');
|
const UserProps = require('./user_property.js');
|
||||||
const Log = require('./logger.js').log;
|
const Log = require('./logger.js').log;
|
||||||
const User = require('./user.js');
|
const User = require('./user.js');
|
||||||
|
const Config = require('./config.js').get;
|
||||||
|
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const moment = require('moment');
|
const moment = require('moment');
|
||||||
|
@ -13,6 +14,48 @@
|
||||||
function checkAccess(acsCode, value) {
|
function checkAccess(acsCode, value) {
|
||||||
try {
|
try {
|
||||||
return {
|
return {
|
||||||
|
SE : function servicesEnabled() {
|
||||||
|
if (!Array.isArray(value)) {
|
||||||
|
value = [ value];
|
||||||
|
}
|
||||||
|
const config = Config();
|
||||||
|
const webEnabled = () => {
|
||||||
|
return (true === _.get(config, 'contentServers.web.http.enabled') ||
|
||||||
|
true === _.get(config, 'contentServers.web.https.enabled'));
|
||||||
|
};
|
||||||
|
|
||||||
|
const allEnabled = value.every(svcName => {
|
||||||
|
switch (svcName) {
|
||||||
|
case 'http':
|
||||||
|
return true === _.get(config, 'contentServers.web.http.enabled');
|
||||||
|
|
||||||
|
case 'https':
|
||||||
|
return true === _.get(config, 'contentServers.web.https.enabled');
|
||||||
|
|
||||||
|
case 'web':
|
||||||
|
return webEnabled();
|
||||||
|
|
||||||
|
case 'gopher':
|
||||||
|
return true === _.get(config, 'contentServers.gopher.enabled');
|
||||||
|
|
||||||
|
case 'nttp':
|
||||||
|
return true === _.get(config, 'contentServers.nntp.nntp.enabled');
|
||||||
|
|
||||||
|
case 'nntps':
|
||||||
|
return true === _.get(config, 'contentServers.nntp.nntps.enabled');
|
||||||
|
|
||||||
|
case 'activitypub':
|
||||||
|
return webEnabled() && true === _.get(config, 'contentServers.web.handlers.activityPub.enabled');
|
||||||
|
|
||||||
|
case 'nodeinfo2':
|
||||||
|
return webEnabled() && true === _.get(config, 'contentServers.web.handlers.nodeInfo2.enabled');
|
||||||
|
|
||||||
|
case 'webfinger':
|
||||||
|
return webEnabled() && true === _.get(config, 'contentServers.web.handlers.webFinger.enabled');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return allEnabled;
|
||||||
|
},
|
||||||
LC : function isLocalConnection() {
|
LC : function isLocalConnection() {
|
||||||
return client && client.isLocal();
|
return client && client.isLocal();
|
||||||
},
|
},
|
||||||
|
@ -304,4 +347,3 @@ arg
|
||||||
= list
|
= list
|
||||||
/ num:number?
|
/ num:number?
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue