Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Authentication and Roles in WPF

I am doing a project in WPF. I got a requirement to authenticate a user and providing accessibilty for the modules based on the role. Do i have a better way to achieve this in WPF.

like image 661
Novice Avatar asked Jan 19 '11 05:01

Novice


People also ask

How to secure WPF application?

If your application uses the WPF WebBrowser control, another way to increase security and mitigate attacks is to enable Internet Explorer feature controls.

How do you do role based authorization?

For role-based authorization, the customer is responsible for providing the user ID, any optional attributes, and all mandatory user attributes necessary to define the user to Payment Feature Services. The customer must also define the roles that are assigned to the user.

What is role based authentication asp net?

Role based authorization checks: Are declarative and specify roles which the current user must be a member of to access the requested resource. Are applied to Razor Pages, controllers, or actions within a controller.

What can you use to identify whether an authenticated user is a member of a role?

The RolePrincipal object's IsInRole(roleName) method calls Roles. GetRolesForUser to get the roles for the user in order to determine whether the user is a member of roleName. When using the SqlRoleProvider , this results in a query to the role store database.


1 Answers

It will depend in part on how secure you need the code to be.

For all your use cases, though, use a Model-View-ViewModel pattern. In each ViewModel, perhaps best placed in a base class for all your ViewModel classes, include a state variable which returns a string and raises the PropertyChanged event whenever the security state changes.

Base your presentation for each View class on the value of that string, following a pattern similar to the accepted answer to this SO question:

https://stackoverflow.com/questions/3868164/

The answer describes how to do this with boolean values, but you can use any string value other than "True" or "False" if your ViewModel state variable needs more than two states.

All .NET code, including WPF, can be easily reverse-engineered. If your code needs to be more secure than that, that is, if your use case assumes that your users will hack your WPF program, then you will want to obfuscate and/or encrypt much of the ViewModel code, using commercially available products like InishTech's SLPS or Dotfuscator or whatever.

Alternatively, you could use the same MVVM pattern and write a Silverlight application, but I'm not sure if a Silverlight user has access to the binary files the way a desktop WPF user would.

like image 113
Rob Perkins Avatar answered Oct 10 '22 11:10

Rob Perkins