Sync Framework - Check logic before synchronizing - azure

I'm wondering whether I can sync two databases with some logic.
DbSyncTableDescription user = SqlSyncDescriptionBuilder.GetDescriptionForTable("User", sqlServerConn);
DbSyncTableDescription role = SqlSyncDescriptionBuilder.GetDescriptionForTable("Role", sqlServerConn);
DbSyncTableDescription usersInRoles = SqlSyncDescriptionBuilder.GetDescriptionForTable("UsersInRoles", sqlServerConn);
For example, sync administrators to user table. Do not sync staffs.
Thank in advance!

you can define a filter in your scope... see: Walkthrough: Defining Filtered Scope and Provisioning Server Database
or if you want more logic around what needs to be synched, you can intercept the changes in the ChangesSelected event...see: Manipulating the change dataset in Sync Fx

Related

Developing Role Based Access Control in SQL and NodeJS

I am trying to develop a Role Based Access Control System in Sequelize (Postgresql). But cant figure out how should I go with my relationships in Sequelize.
Problem Statement:
So the hierarchy goes like this:-
There's a Company table which has many Branches
Each Branch can have many Employess and many custom Roles and many default Modules
Roles will provide access to the Modules
based on the roles employees can read the module or make changes in the module or have access to the modules
So far I have developed a DB structure like this:
// Company & Branch
Company.hasMany(Branch);
Branch.belongsTo(Company);
// Branch & Employee
Branch.hasMany(Employee);
Employee.belongsTo(Branch);
// Branch & Roles
Branch.hasMany(Role);
Role.belongsTo(Branch);
// Modules & Roles
Role.belongsToMany(Module, { through: Permission }); //Permission is where I have added read, write as a boolean datatype
Module.belongsToMany(Role, { through: Permission });
// Employee & Roles
Employee.hasOne(EmployeeRole);
EmployeeRole.belongsTo(Employee);
Role.hasMany(EmployeeRole);
But I think its all a mess, Can anyone please help me develop a solution for this problem.
(I am using sequelize as my ORM).

Tenant specific Resilience Configuration

We want to provide options to customers to configure resilence like for circuit breaker configuration. Kindly let us know is there a way we can provide tenant-specific configuration in cloud SDK.
We have already tried the multi-tenant approach for achieving resilience. But for our scenario we are use resilient approach even for customer systems (op systems) where the customers are asking to provide flexibility to decide parameters like slowCallRate etc according to their landscape. We want to know if we need to externalise the configuration for CircuitBreaker to customers so that they can alter some values as per their setup, how can we do it?
Thanks
Sagar
Let's assume you want to call the SAP BusinessPartner service (OData V2) for the destination as configured in your CloudFoundry Destination Service with the name "MyDestination".
Then your code would look like this with SAP Cloud SDK:
HttpDestination destination = DestinationAccessor.getDestination("MyDestination").asHttp();
BusinessPartnerService service = new DefaultBusinessPartnerService();
List<BusinessPartner> items = service
.getAllBusinessPartner()
.top(10)
.executeRequest(destination);
If you want to apply resilience features to the OData request, then it would look like this:
HttpDestination destination = DestinationAccessor.getDestination("MyDestination").asHttp();
BusinessPartnerService service = new DefaultBusinessPartnerService();
ResilienceConfiguration configuration = ResilienceConfiguration.of("ten-businesspartners");
List<BusinessPartner> items = ResilienceDecorator.executeSupplier(
() -> service.getAllBusinessPartner().top(10).executeRequest(destination),
configuration);
You can customize the instance of ResilienceConfiguration to your needs at runtime, e.g. thresholds for the circuit breaker, like this (with default values):
ResilienceConfiguration.of("ten-businesspartners")
.circuitBreakerConfiguration(ResilienceConfiguration.CircuitBreakerConfiguration.of()
.waitDuration(Duration.ofSeconds(10))
.closedBufferSize(10)
.failureRateThreshold(50)
.halfOpenBufferSize(5)
);

Syncing Azure Easy Table with WHERE clause

I'm developing a Xamarin.Forms app which uses an Azure app service with SQL database linked through EasyTables. I've run the samples and successfully tested querying tables etc on the server and enabled offline sync so as a localdb is created.
I've created the store, defined the table & sync'd it, however I want to be able to query it somehow with a where clause - is that possible? Can I add a where clause to the client.GetSyncTable line?
var store = new MobileServiceSQLiteStore("localstore.db");
store.DefineTable<Journey_Stages>();
client.SyncContext.InitializeAsync(store);
tbl_Stages = client.GetSyncTable<Journey_Stages>();
Some of the tables I'm pulling down will grow over time & are linked to individual user profiles, so I only want data which belongs to that user and I don't want to be bringing down masses of data each time, preferably let the server handle that and only bring down what I need on a user by user basis.
Thanks,
Steve
You should add this filtering logic on the server side, so that each user's data isn't exposed to all your other users. See for example this sample if you are using the Node.js backend -- line 17 adds a WHERE clause for the table read query. If you have the .Net backend, similar logic would go in your table controller.
// Configure specific code when the client does a request
// READ - only return records belonging to the authenticated user
table.read(function (context) {
context.query.where({ userId: context.user.id });
return context.execute();
});

Is it possible to re-use schema specific reports on different schemas in iccube?

I have created standard dashboards connected to a single schema.
Now I would like to re-use the same dashboards definition on different schemas. These schemas are all equivalent (same dimensions, measures, but different client data).
Is this possible?
I think of the process sequence:
user logs on, dashboards connects to schema defined in the dashboard
if the user has no access to this schema, connect to the schema the user has access to
allow a user to select from the schemas to which he/she is authorized
You can do that when opening a report using the javascript API. Somehow, you would have an instance of ic3.Reporting.
var ic3reporting = new ic3.Reporting();
Then before opening the report you can register an event to listen when its definition is received:
ic3reporting.bind(vizEventType.onReportJSON, function(ic3report){
ic3report.schemaName("...");
});
In the callback function you get the opportunity to change the name of the schema being used by this report.
[edit: vizEventType.onReportJSON is actually the string 'ic3reportJSON']

how to set exclusive permissions on a SharePoint document library?

I have a requirement to lock down access to a SharePoint library: Only users that belong to all the groups associated with the library should have read access; others should not be allowed to read.
Let's say I have a document library that concerns three projects:
12345
13579
24680
I have users that belong to one or more projects:
Joe: 12345, 24680
Jane: 13579, 24680
Jim: 24680
Harry: 12345, 13579, 24680
I need to restrict access to this library to only users who belong to ALL projects. I.e., only Harry should have access; the others should be denied. We'd use SharePoint groups named after each project to represent the 'belongs' relationship.
Edited with more detail:
We plan to create the doc lib and set up the initial security via a workflow. However, more projects may be associated with the doclib after it's created, based on info entered in a form, and people can get moved in and out of project groups by admins (e.g. for promotions, new hires....)
For now, if a form submission adds a new project after inital setup, an admin will probably create a new group if necessary, and assign it access to the doclib. Eventually, we'd do this in a workflow.
Currently, we're writing code to assign the initial security state for the site:
We scan a list of projects entered by a user into a form, create new project groups if necessary, create a site and a couple of doclibs, break role inheritance and assign our groups read access to the doclib. We add some users to each project group.
At this point, any of those users have read access. What we don't know how to do is restrict access to only users who are members of all the groups.
You've made it hard on yourself.. SharePoint nor AD works this way, I'd go back to the drawing board because this will only cause pain ;)
I would decouple management of groups and their assignment to document libraries and sync rights throughout SharePoint like Koen mentioned.
e.g. you manage group membership separate from the groups you use to connect them to document libraries. Then you need a process to enumerate over these separate groups and assign the users in there to the document libraries individually according to your business rules. Brittle at best.
You could set your document library to BreakRoleInheritance and set permissions to your items individually.
This is a example:
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite("http://..."))
{
using (SPWeb web = site.OpenWeb())
{
web.AllowUnsafeUpdates = true;
SPRoleType role = SPRoleType.Reader;
SPRoleAssignment assignment =
new SPRoleAssignment(web.Groups["groupname"]);
assignment.RoleDefinitionBindings.Add(
web.RoleDefinitions.GetByType(role));
SPList list = web.Lists["name"];
SPListItemCollection items = list.GetItems(new SPQuery());
foreach (SPListItem item in items)
{
if (!item.HasUniqueRoleAssignments)
item.BreakRoleInheritance(false);
while (item.RoleAssignments.Count != 0) // remove all
item.RoleAssignments.Remove(
item.RoleAssignments.Count - 1);
item.RoleAssignments.Add(assignment);
}
}
}
});
The only way I can think of achieving this is to create a custom timer job that updates your document library every day by deleting all the rights, and then adding them again overnight. That would mean that people who join those projects will have to wait 1 day to get acces. You would just create a collection of all the users of group1, and check for each one if they exist in group 2, 3, ... and if they don't remove them from the collection.

Resources