Custom Security, best practice for integration?

Article piece from

Custom UserStore/RoleStore and UserManager

and github code in https://github.com/radzenhq/radzen-examples/tree/master/CustomSecurity

shows something that appears identical to what we need to implement.

From experience, what is the smoothest/painless way to integrate this code with a radzen prototype?
Complete the prototype so no more work needed on that side and then try to integrate the custom sscurity code?
Start "dymmy project" with default security, integrate the custom code and then build the rest?
Etc.

Any experience appreciated.

Cheers.

Greetings again friends.

Any words if wisdom you can offer?
What is the surest way to implement your custom security example in any application?

E.g.

“Start with existing app with [default security] OR [no security], etc....

Or

Start with the CustomSecurity app and then ....

Or

Use 2 data sources and 2 namespaces etc.,,,,, and

I have tried but there are almost always conflicts that render the app UN-compilable!

Thanks in advance!..

Not tried that code it but I would implement it in a simple test project initially. Did you change the namespaces to match your project? Are you using same version of dotnet core? What errors are you getting?

1 Like

Did the simple case, work fine.
Then I have to use the CustomSecurity setup in a bid dermo project with its own namespace, etc. Thsi one jhas already been setup with Default security as well as wityhout any security.

So, I have tried to:

  • Merge the 2 namespaces in one (too many conflicts in existing code).
  • Start demo without security and insert the custom setup.
  • Start it with Default and try to replace with the CustomSecuriity.
  • Start from Custom and slowwwlllyyyy recreate the Demo project over the CustomSecurity sample. (works but is totally inpractical!)

This is why I was inquiring from anyone that may have tried this to share an opinion about the "path of least resistance" in trying to do something like that!

DOTNET I am using 3.1 instead fo the 2.x that it was originally on.
Errors are indicative of ... a mess between namespaces after I cleaned as much as possible dual entries.
The only way possible for me was to start from the CustomSSecurity minimal example and go through the whole process of introdcung custom attribute with EF, and then start coding again on the original project database - I am using the community edition.

As far as I can tell, the easiest way would be with two namespaces and 2 databases but I have not been able to go though it to the end.

Finally, it seems that one has a single chance to start the CustomerSecurity project from scratch and then complete it! Maybe it is a Dotnet 3.x vs 2.x thing but if it goes through the "Infer schema" process a 2nd time after creating the sql server db instance, before even doing anything else,it comes up with exceptions like:

=============================================================================
dotnet: CustomSecurity.cs(11,29): error CS0234: The type or namespace name 'CustomSecurity' does not exist in the namespace 'CustomSecurity.Models' (are you missing an assembly reference?) [C:\Users\Administrator\Desktop\CustomSecurity\server\project.csproj]

CustomSecurity.cs(308,73): error CS0246: The type or namespace name 'User' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\Administrator\Desktop\CustomSecurity\server\project.csproj]

*dotnet: *
dotnet: The build failed. Fix the build errors and run again.
==============================================================================

Is all your serverside code in a single project?
I think Radzen uses settings in project.csproj when inferring the database and the namespace must be unique if you have multiple Radzen projects. Also check the namespace being generated by the Radzen generated code match. You can open the project in VS Community edition to view and build the project.

Did you check the Readme of that project? It says "all custom code is in the CustomSecurity.cs file". You need to copy that file to your Radzen application and update the namespaces to match. Then update all code which does database access to point to your user management data tables.

Thanks for the hint korchev.

Yes, I did read it and did try it. It did not go too well, the “editing” part was endless! I will try again though, since you suggested it.

Thanks.

mumfie,

I really appreciate your “ lonely” effort for assistance.
Yes, single back end, I do not think it is feasible to have dual backend with one handling security for the other!

I will take up korchev’s suggestion fir NIW and see if I am better at it after 2 months. onFail(I will be back)...!

Yes. You mentioned two namespaces and two databases in the thread above so not sure of your terminology.
You can access two databases by creating two data sources in the same project.
You will likely find it's a simple issue to resolve once you identify the root cause but it can be time-consuming finding it.