Skip to content

Commit 86c9375

Browse files
committed
Add group mapping env var to LDAP config, update documentation.
1 parent 630b8d4 commit 86c9375

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

src/server_realtime_auth/README.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
This NodeJS/Express module can serve JSON-SCADA realtime data for the web-based interface.
44

5-
It can also server the HTML files from the src/AdminUI/dist folder.
5+
It can also serve the HTML files from the src/AdminUI/dist folder.
66

7-
It is possible to access Grafana on "/grafana" path adjusting the _JS_GRAFANA_SERVER_ environment variable.
7+
It is possible to route access Grafana on "/grafana" path by adjusting the _JS_GRAFANA_SERVER_ environment variable.
88

9-
It is recommended to apply a reverse proxy (Nginx) on top of this service to serve securely to client on external networks. For best scalability static files should be served directly via Nginx or Apache, redirecting _/grafana_ to the Grafana server and _/Invoke_ to this Node.js service.
9+
It is recommended to apply a reverse proxy (Nginx) on top of this service to serve securely (https) to clients on external networks. For best scalability static files should be served directly via Nginx or Apache, and redirecting _/Invoke_ (API calls) to this service.
10+
11+
This module also provides user authentication and role-based access control (RBAC) using JWT tokens and optional LDAP authentication.
1012

1113
### Example Nginx config as a reverse proxy
1214

@@ -304,16 +306,19 @@ To each user can be attributed a set of roles. Each right in each user role are
304306

305307
#### LDAP Authentication Configuration
306308

307-
- _**JS_LDAP_ENABLED**_ [Boolean] - Use "TRUE" to enable LDAP authentication. **Default="false"**.
309+
LDAP can be configured by editing the file ./app/config/auth.config.js or by setting the following environment variables. The environment variables have precedence over the configuration file.
310+
311+
- _**JS_LDAP_ENABLED**_ [Boolean] - Use "true" to enable LDAP authentication. **Default="false"**.
308312
- _**JS_LDAP_URL**_ [String] - LDAP server URL. **E.g."ldap://localhost:389"**.
309313
- _**JS_LDAP_BIND_DN**_ [String] - LDAP bind DN. **E.g."cn=read-only-admin,dc=example,dc=com"**.
310314
- _**JS_LDAP_BIND_CREDENTIALS**_ [String] - LDAP bind password. **E.g."secret"**.
311-
- _**JS_LDAP_SEARCH_BASE**_ [String] - LDAP search base. **E.g."dc=example,dc=com"**.
312-
- _**JS_LDAP_SEARCH_FILTER**_ [String] - LDAP search filter. **E.g."(uid={{username}})"**.
313-
- _**JS_LDAP_ATTRIBUTES_USERNAME**_ [String] - LDAP attribute for username. **E.g."uid"**.
315+
- _**JS_LDAP_SEARCH_BASE**_ [String] - LDAP search base for users. **E.g."dc=example,dc=com"**.
316+
- _**JS_LDAP_SEARCH_FILTER**_ [String] - LDAP search filter. **E.g."(uid={{username}})" or "(|(sAMAccountName={{username}})(cn={{username}}))"**.
317+
- _**JS_LDAP_ATTRIBUTES_USERNAME**_ [String] - LDAP attribute for username. **E.g."uid" or "sAMAccountName"**.
314318
- _**JS_LDAP_ATTRIBUTES_EMAIL**_ [String] - LDAP attribute for email. **E.g."mail"**.
315319
- _**JS_LDAP_ATTRIBUTES_DISPLAYNAME**_ [String] - LDAP attribute for display name. **E.g."cn"**.
316320
- _**JS_LDAP_GROUP_SEARCH_BASE**_ [String] - LDAP group search base. **E.g."ou=JSON-SCADA,dc=ad,dc=gpfs,dc=net"**.
321+
- _**JS_LDAP_GROUP_MAPPING**_ [String] - LDAP group mapping as a JSON object. **E.g.'{"ou=mathematicians,dc=example,dc=com":"admin","ou=scientists,dc=example,dc=com":"user"}'**.
317322
- _**JS_LDAP_TLS_REJECT_UNAUTHORIZED**_ [Boolean] - LDAP TLS reject unauthorized. **Default="true"**.
318323
- _**JS_LDAP_TLS_CA**_ [String] - LDAP TLS CA file location. **E.g."/etc/ssl/certs/ca-certificates.crt"**.
319324
- _**JS_LDAP_TLS_CERT**_ [String] - LDAP TLS cert file location. **E.g."/etc/ssl/certs/client-cert.pem"**.

src/server_realtime_auth/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ if (process.env.JS_LDAP_TLS_MIN_VERSION)
9898
config.ldap.tlsOptions.minVersion = process.env.JS_LDAP_TLS_MIN_VERSION
9999
if (process.env.JS_LDAP_TLS_MAX_VERSION)
100100
config.ldap.tlsOptions.maxVersion = process.env.JS_LDAP_TLS_MAX_VERSION
101+
if (process.env.JS_LDAP_GROUP_MAPPING) {
102+
try {
103+
config.ldap.groupMapping = JSON.parse(process.env.JS_LDAP_GROUP_MAPPING)
104+
} catch (e) {
105+
Log.log('Error parsing JS_LDAP_GROUP_MAPPING: ' + e.message)
106+
}
107+
}
101108

102109
Log.log('LDAP enabled: ' + config.ldap.enabled)
103110
if (config.ldap.enabled && !config.ldap.url.startsWith('ldaps')) {

0 commit comments

Comments
 (0)