Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The server configuration is tailored from 2 configuration files, but the starting point is config/server/config.jsThis file will merge the configuration files inside the config/server/env folder. Inside this folder we will find 4 files, all.js configuration and 3 environment configuration, where all.js is going to be the base template for the final configuration.

Table of Contents

Code Block
languagejs
themeDJango
titleExample all.js
const DOMAIN_NAME = 'localhost'
const SERVER_PORT = process.env.PORT || 3000

module.exports = {
    domain: DOMAIN_NAME,
    app: {
        title: 'Enterprise Search',
        description: 'Enterprise Search',
        keywords: 'Enterprise Search, Independent'
    },
    port: SERVER_PORT,
    logging: {
        log_folder: __utils.absPath('./logs/'),
        express: {
            request: [
                // 'body', //only add if it's safe to display data
                'connection.remoteAddress',
                'authorizedCN'
            ],
            response: [
                // 'body' //only add if it's safe to display data
            ]
        },
        transports: {
            console: {
                level: 'info',
                enable: true
            },
            file: {
                level: 'info',
                enable: true
            }
        },
        response: {
            showStack: true
        }
    . . . },
    esui: {
        baseUrl: `http://${DOMAIN_NAME}:4200`
    },
    security: {
        protocol: process.env.PROTOCOL || 'http', // https or http

        /*******************************************************************************
         * Content Security Policy for the requests,
         *******************************************************************************/
        allowDomainsAccess: {
            // Defines the default policy for fetching resources such as JavaScript, Images, CSS, Fonts, AJAX requests, Frames, HTML5 Media
            defaults: [],
            // Defines valid sources of images.
            images: ['image.tmdb.org'],
            // Defines valid sources of stylesheets or CSS.
            styles: [],
            // Defines valid sources of JavaScript.
            scripts: [],
            // Applies to XMLHttpRequest (AJAX), WebSocket, fetch(), <a ping> or EventSource. If not allowed the browser emulates a 400
            connects: []
        },

        allowGroups: ['Administrators'], // Groups with access to the user interface

        encryptionmailer: {
            secretKey: __utils.absPath('./config/server/auth/epk'),
            iv: __utils.absPath('./config/server/auth/eiv')
        },

        /*******************************************************************************
         * SSL Certificate, only aplicable when protocol is https
         *******************************************************************************/
        serverCert. . .},
    analytics: {
            certFilePath: __utils.absPath('./config/certs/server/all/server-cert.pem'),
            keyFilePath: __utils.absPath('./config/certs/server/all/server-key.pem'),
            keyFilePassphrase: ''enable: true
        },

        /*******************************************************************************
         * Group Expansion
         *******************************************************************************/
        groupExpansionchat_forum: {
            enabledenable: false,
            url: 'http://localhost:50505/groupExpansion?username=${user.account}&json=1'
   history_size: 100
     },

        /*******************************************************************************
         * User Authentication
         *******************************************************************************/
 ElasticSearch connection      auth: {
            type: 'none',
            passport: {for permissions, and other features
                secret: 'SearchTech'
            },
            oauth2: elastic: {
                providerschema: 'googlehttp',
                callbackUrlDomain: DOMAIN_NAME,
                calllbackUrlPort: SERVER_PORT,
                google: {
                    scope: ['profile', 'email']host: 'localhost',
                    clientID: '790123979285-osjbhimrhnbvnaofplavp9auh9tgkq5k.apps.googleusercontent.com', // Client IDport: 9200,
                    clientSecretindexName: '9RjuURmdon0UePqIbS2wJB9hesui'
                },

                // Sample OKTA authentication
                // login: [email protected]
                // password: Horrible-Dotterel-75
                okta: {
                    domain: 'domain',
                    callbackUrlDomain: DOMAIN_NAME,
                    calllbackUrlPort: SERVER_PORT,
                    scope: ['profile', 'email'],
                    clientID: 'client-id', // Client ID
                    clientSecret: 'client-secret'
                }
            },
            saml2: {
                provider: 'google', // supported values: google
                google: {
                    entryPoint: 'https://accounts.google.com/o/saml2/idp?idpid=C02oz2242', // replace with value appropriate for your project
                    issuer: 'nikepoc', // replace with value appropriate for your project
                    certPath: __utils.absPath('./config/certs/saml2/all/google-saml2.pem'), // replace with value appropriate for your project
                    attributesMapping: { // key is the property name stored in the SEIA user profile, the value is the property name from the SAML profile
                        uid: 'nameID',
                        email: 'nameID',
                        firstName: 'firstName',
                        lastName: 'lastName',
                        groups: 'groups'
                    }
                },
                okta: {
                    entryPoint: 'https://cagsearchdemoseia.okta.com/app/cagsearchdemoorg743328_nikepocalex_1/exkpkxgzlpV0GyoMS356/sso/saml', // replace with value appropriate for your project
                    issuer: 'nikepoc', // replace with value appropriate for your project
                    certPath: __utils.absPath('./config/certs/saml2/all/okta-saml2.pem'), // replace with value appropriate for your project
                    attributesMapping: { // key is the property name stored in the SEIA user profile, the value is the property name from the SAML profile
                        uid: 'nameID',
                        email: 'nameID',
                        firstName: 'firstName',
                        lastName: 'lastName',
                        groups: 'groups'
                    }
                }
            },
            ldap: {
                provider: 'apacheds',
                apacheds: {
                    server: {
                        url: 'ldap://localhost:10389',
                        bindDN: 'uid=admin, ou=system', // Bind DN or User
                        bindCredentials: 'secret', // password
                        searchBase: 'ou=users,dc=esui,dc=com',
                        searchFilter: '(uid={{username}})',
                        searchAttributes: ['uid', 'cn', 'sn', 'displayName', 'ou', 'photo']
                    },
                    attributesMapping: { // key is the property name stored in the SEIA user profile, the value is the user attribute in LDAP
                        _id: 'uid', // _id is required
                        account: 'uid', // account is for roles and group expansion
                        email: 'uid',
                        firstName: 'cn',
                        lastName: 'sn',
                        name: 'cn',
                        alias: 'displayName', // if the alias is not given, one is created from the first and last name or roles
                        groups: 'ou',
                        photo: 'photo'
                    }
                },
                ad: {
                    server: {
                        url: 'ldaps://ad.corporate.com:636',
                        bindDN: 'cn=non-person,ou=system,dc=corp,dc=corporate,dc=com',
                        bindCredentials: 'secret',
                        searchBase: 'dc=corp,dc=corporate,dc=com',
                        searchFilter: '(&(objectcategory=person)(objectclass=user)(|(samaccountname={{username}})(mail={{username}})))',
                        searchAttributes: ['displayName', 'mail', 'samaccountname'],
                        tlsOptions: {
                            ca: [
                                // fs.readFileSync('/path/to/root_ca_cert.crt')
                            ]
                        }
                    },
                    attributesMapping: { // key is the property name stored in the SEIA user profile, the value is the user attribute in LDAP
                        uid: 'samaccountname',
                        account: 'samaccountname', // account is for roles and group expansion
                        email: 'mail',
                        firstName: 'givenName',
                        lastName: 'sn',
                        groups: 'groups'
                    }
                }
            }
        },
        permissions: {
            default_role: 'reader',
            file: __utils.absPath('./config/server/auth/permissions.csv')
        },
        roles: {
            file: __utils.absPath('./config/server/auth/roles.csv')
        }
    },
    mailer: {
        enable: false,
        type: 'gmail',
        user: '[email protected]',
        pass: 'password',
        subject: 'Email Subject',
        test: false,
        test_email: '[email protected]',
        plain_template_path: __utils.absPath('./config/templates/email_text.tlp'),
        html_template_path: __utils.absPath('./config/templates/email_html.tlp')
    },
    analytics: {
        enable: true
    },
    chat_forum: {
        enable: false,
        history_size: 100
    },
    // ElasticSearch connection for permissions, and other features
    elastic: {
        schema: 'http',
        host: 'localhost',
        port: 9200,
        indexName: 'esui'
    }
}
}

The 3 environment configuration are just mirror images of the all.js, these configuration have specific values for different properties which will overwrite the ones in all.js. And as the name suggest each environment configuration contains different values for different environment, so far the Enterprise Search manages 3 environments local, development and production.



Image Added

Selecting The Environment Configuration

As mention before the config/server/config.js manages the merging of the all.js with the environment configuration. 

To choose a configuration environment the enviroment variable NODE_ENV must be set, the server will look into this variable for the name of the configuration to use. By default if no environment is specified the one selected will be development.

Set Environment Variable 
Anchor
Set_Environment_Variable
Set_Environment_Variable
_

You can set this variable depending on the console, like this:

For Local

  • Powershell: $env:NODE_ENV="local"
  • CMD: set NODE_ENV="local"
  • Shell: export NODE_ENV="local"

For Development

  • Powershell: $env:NODE_ENV="development"
  • CMD: set NODE_ENV="development"
  • Shell: export NODE_ENV="development"

For Production

  • Powershell: $env:NODE_ENV="production"
  • CMD: set NODE_ENV="production"
  • Shell: export NODE_ENV="production"

This also means, more configuration enviroments can be added, as long as the nave in the environment variable matches with the configuration name, for examples if NODE_ENV value was test, then file name should be test.js

Image AddedImage Removed