The sri-audit-broadcast
module gives you a possibility to create an audit trail of all your sri resources.
It also has a build-in broadcast services that sends out broadcasts when a new version has been created.
Here you can find a example server.js
file:
//Load all required dependencies.
var express = require('express');
var app = express();
var pg = require('pg');
var http = require('http');
var srv = new http.Server(app);
var auditBroadcast = require('sri-audit-broadcast');
//Sri4node authentication functions.
var authentication = require('vsko-authentication')(app);
authentication.init();
//Functions in order to do security lookup
var resourceToSecurityComponent = function (resource) {
return '/security/components/samenscholing-api';
};
var meToHref = function (me) {
return '/persons/' + me.uuid;
};
//The configuration and initalisation
auditBroadcast.init({
app: app,
server: srv,
express: express,
pg: pg,
databaseUrl: prosess.env.DATABASE_URL,
authenticate: authentication.isAuthenticated,
identify: authentication.getMe,
security: {
enabled: true,
host: 'http://localhost:8080/api',
component: resourceToSecurityComponent,
currentPersonHref: meToHref,
username: 'myBasicAuthUsername',
password: 'myBasicAuthPassword',
headers: {}
}
});
//Start the http server
srv.listen(process.env.PORT || 3000, function(){
console.log('Node app is running at http://localhost:' + (process.env.PORT || 3000));
});
- An sri interface
- A running sri-security-api to do security
- You need to use express on node.js
- postgress 9.4
- a reddis server
You need to pass these variables because we need to plug in our resources into your application.
Is a sri4node function you can find the documentation here
Is a sri4node function you can find the documentation here
We also need to set some variables in order to connect to the security api
Where is the security api located.
This function has to return a component href to check the rights of this component. It receives these parameter :
resource
a href to the resource for which a version has been created.
This function has to return a person href to check if this person has rights to the contents of a version. It receives these parameter :
me
the result of the identify function.
If the access to the security api requires basic authentication you can specify the credentials.
If the access to the security api requires you to have custom headers set you can add these.
You can test the broadcast api by going to: http://localhost:3000/test