Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A simple JS Reappt client that updates the security and system authentication stores.
var diffusion = require('diffusion');
// Connect to Reappt with admin credentials
diffusion.connect({
host : 'approvingBoldDaVinci.us.reappt.io',
port : 443,
secure : true,
principal : 'admin',
credentials : 'nimda'
}).then(function(session) {
// Change the security configuration to give the GATEKEEPER and REQUESTER roles the required permissions
var securityScriptBuilder = session.security.securityScriptBuilder();
var script = securityScriptBuilder.setGlobalPermissions('GATEKEEPER', ['VIEW_SESSION', 'MODIFY_SESSION'])
.setTopicPermissions('GATEKEEPER', 'closed', ['SELECT_TOPIC'])
.setTopicPermissions('REQUESTER', 'closed', ['READ_TOPIC'])
.setTopicPermissions('REQUESTER', 'open', ['SELECT_TOPIC', 'READ_TOPIC'])
.setTopicPermissions('TOPIC_CONTROL', 'closed', ['MODIFY_TOPIC', 'UPDATE_TOPIC'])
.setTopicPermissions('TOPIC_CONTROL', 'open', ['MODIFY_TOPIC', 'UPDATE_TOPIC'])
.build();
// Update the server-side store with the generated script
session.security.updateSecurityStore(script).then(function() {
console.log('Security configuration updated successfully');
}, function(error) {
console.log('Failed to update security configuration: ', error);
});
// Change the system authentication store to add users and give them roles
var authenticationScriptBuilder = session.security.authenticationScriptBuilder();
var addUserScript = authenticationScriptBuilder.addPrincipal('gatekeeper', 'repeeketag')
.assignRoles('gatekeeper', ['GATEKEEPER'])
.addPrincipal('requester', 'retseuqer')
.assignRoles('requester', ['REQUESTER'])
.build();
// Update the system authentication store
session.security.updateAuthenticationStore(addUserScript).then(function() {
console.log('Updated system authentication config');
}, function(error) {
console.log('Failed to update system authentication: ', error);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment