I need to have bunch of settings for each user. Theese settings are same for all the users but every user can change their values. I'm looking for a good approach to create such an infrastructure. My best guess for now is table with all the settings in DB and a table with SettingId UserId and value. Not sure this is the best way tho.
In .net core , you can also use appsettings.json to store such configuration like as below:
{
"Users": {
"Arun": {
"Id": "ArunId",
"Name": "ArunName"
},
"Santa": {
"Id": "SantaId",
"Name": "SantaName"
}
}
}
you can directly convert these to strong type object with help of IConfiguration interface like below :
_configuration.GetSection("Users")
Related
I'm working on a marketplace backend application with role based authorization, and I'm handling access to actions using those roles. The admins manage all products and their filtering categories while the sellers choose which one to sell, with its filter options and its price. By the way, I'm quite new to asp.net core and ef core, so forgive me if this is a simple request.
If a seller sends a put request with data like this, it can update the filter option name, but that is a action that should be available only to admins on another path/action.
Is there a simple good solution other than create specific models for each action? Something like block the update access to that resource when it's part of another one?
{
"productId": "1",
"options": [
{
"filterCategoryId": "2",
"filterOptionId": "4",
"filterOptionName": "Blue"
},
{
"filterCategoryId": "1",
"filterOptionId": "1",
"filterOptionName": "XL"
}
],
"price": "123.00",
"amount": "5"
}
You can use User.IsInRole("roleName") in the Action to control whether or not the filter options may be changed. For Example:
public async Task<ActionResult>(ProductDetails p)
{
if(User.IsInRole("Administrator"))
{
//Update Filter Names
}
//do whatever else you need to...
}
I've been having to give a role to new users, problem I have to add them to 2 different cubes in 6 different environments, which is 12 times adding the user and processing the rights table, which amounts to around an hour on my company's rather weak laptop, for EVERY new user.
Is there any way to juste write some code with a list of users you wanna add to a list of cubes, and you'd just tell it to process the table after each addition ? It'd be a real life saver right now.
In SSIS, you can use the Analysis Services Execute DDL Task. This can take a TMSL script as input, which would look like below.
1) sequence - this command allows you to perform multiple operations
2) createOrReplace - this will refresh the role with the new list of members. Note that every existing member needs to be included in the role or they will be wiped out
3) refresh - processes the table
In ssis, you might create a connection to each environment and loop through a set of script files, so that you would not need to modify the package to add new members.
However, I would also suggest switching to an AD group instead of adding explicit users to the role. Then you would only need to refresh table.
{
"sequence": {
"operations": [{
"createOrReplace": {
"object": {
"database": "<Your Database>",
"role": "<Your Role Name>"
},
"role": {
"name": "Reader",
"modelPermission": "read",
"members": [{
"memberName": "<Your Domain>\\<User 1>",
"memberName": "<Your Domain>\\<User 2>",
<All the users in the role...>
}
]
}
}
}, {
"refresh": {
"type": "full",
"objects": [{
"database": "<Your Database>",
"table": "<Your Table>"
}
]
}
}
]
}
}
i have a console application. i built this application and uploaded it to the Azure blob storage. Then i run this application Azure data factory pipeline. All are fine but the problem is if i want to add new parameters(get input) to console application how can i do that? Is there any specific way to do it?
{
"name": "samplebatch",
"type": "Custom",
"policy": {
"timeout": "7.00:00:00",
"retry": 0,
"retryIntervalInSeconds": 30,
"secureOutput": false
},
"typeProperties": {
"command": "SampleApp.exe",
"folderPath": "customactv2/SampleApp",
"resourceLinkedService": {
"referenceName": "StorageLinkedService",
"type": "LinkedServiceReference"
}
"linkedServiceName": {
"referenceName": "dataloadbatchservice",
"type": "LinkedServiceReference"
}
}
This is what i have done so far in the data factory pipeline code.
Please refer to the extendedProperties property in typeProperties, you could use it.
User-defined properties that can be passed to the custom application
in JSON format so your custom code can reference additional properties
Doc: https://learn.microsoft.com/en-us/azure/data-factory/transform-data-using-dotnet-custom-activity#custom-activity
Sample:https://github.com/Azure/Azure-DataFactory/blob/master/Samples/ADFv2CustomActivitySample/MyCustomActivityPipeline.json
I have a web application and am planning to move all the authentication to Azure AD b2c.
I need to create user through Graph API and now i can create user through Graph API, i also need to add claims
When adding user or updating user, after further googling i found out, you need to add extension property, I tried adding extensions, but it seems to be not working for me. Any help will greatly appreciated.
I am using the sample provided by MSFT https://github.com/AzureADQuickStarts/B2C-GraphAPI-DotNet . I can now create an extension with the below JSON
{
"accountEnabled": true,
"signInNames": [
{
"type": "emailAddress",
"value": "kart.kala1#test.com"
}
],
"creationType": "LocalAccount",
"displayName": "Joe Consumer",
"mailNickname": "joec",
"passwordProfile": {
"password": "P#$$word!",
"forceChangePasswordNextLogin": false
},
"passwordPolicies": "DisablePasswordExpiration",
"city": "San Diego",
"country": null,
"facsimileTelephoneNumber": null,
"givenName": "Joe",
"mail": null,
"mobile": null,
"otherMails": [],
"postalCode": "92130",
"preferredLanguage": null,
"state": "California",
"streetAddress": null,
"surname": "Consumer",
"telephoneNumber": null,
"extension_a550f811ccfe41f19e895f7931f7a28a_admin": "admin1"
}
Above extension_a550f811ccfe41f19e895f7931f7a28a_admin": "admin1" property worked for me to add extension, but i created a user thru sign-signin profile in azure portal and then added the details which is got from "GET-USER" of another user and re-used the name. What is the alpha numeric value? is it created run time or can it be resolved using any value from the user data ?. I will have two accounts stage and production and i cannot be resolving the value or changing it runtime.
Don't have the rep to comment so need to put it in answer form.
I am not entirely sure what the question is, but I have successfully used the Graph API to set/get the extension data (for example using the JSON attribute extension_a550f811ccfe41f19e895f7931f7a28a_admin).
I am not sure how you are getting the user info but it seems as though it might be by name, which may not be unique.
For getting/setting B2C user info you need to use the objectId of the user as it is guaranteed unique. This means you need to store that objectId in your database/storage for that user.
I am in the process of learning ASP.NET vNext. I need to store two connection strings in the config.json file. How do I store those? Can I do this:
config.json
{
"connectionStrings" : {
"connection-1" : "server=...",
"connection-2" : "server=..."
}
}
I have not been able to find a schema for config.json. For that reason, I wasn't sure how to do it. I saw the use of IConfiguration here. Still, I wasn't sure how Configuration was available in the app.
This is the official Configuration repo and this is a great blog post explaining the configuration system.
Long story short:
You need one or more Microsoft.Framework.ConfigurationModel.* NuGet packages in your application. The list of available packages is here.
Add the configuration sources that you need
Build the config file(s)
Read the configuration sources
Here is how you can do it:
{
"Data": {
"connection-1": {
"ConnectionString": "Server=..."
},
"connection-2": {
"ConnectionString": "Server=..."
}
}
}
This is how it's done these days...
{
"ConnectionStrings": {
"myDb1": "Server=myServer;Database=myDb1;Trusted_Connection=True;",
"myDb2": "Server=myServer;Database=myDb2;Trusted_Connection=True;"
}
}
From: Store and read connection string in appsettings.json