Skip to content

How create custom security

rleon edited this page Feb 18, 2020 · 1 revision

Custom Security

By default, just a basic security is enabled. In order to disable it, change security.enable to false in application.json. Addtionally you can delete npmModule and configModule in application.json

If you need to create a custom security (users in a database ,an external api, oauth, google, etc), basically you just need to create a plugin in form of an npm module with the following interface:

my-custom-security-module

function MyCustomSecurity(expressServer, options) {

  // required method
  this.ensureAuthenticated = function(req, res, next) {
    //put here your custom logic
  }

  //add another functions
}

module.exports = MyCustomSecurity;

Configure it in your application.json:

"npmModule": {
  "name": "my-custom-security-module"
},
"configModule": {
  "param1": "at-field",
  "param_n": "dummy-eva"
}

And add it to your package.json.

configModule will be passed as argument to your plugin. Line 32 in security/SecurityConfigurator.js

Note: You must publish your module in the public npm registry, in github or in your private npm registry. At least option, you could add your code to the geofrontend code.

Clone this wiki locally