开发者

Authentication and Roles in WPF

I am doing a project in WPF. I got a requirement to authenticate a us开发者_C百科er and providing accessibilty for the modules based on the role. Do i have a better way to achieve this in WPF.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜