iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
Hi
just installed sp1 (clientui) which was supposed to fix the RoleRequired so that it accepts more than one role separated by commas. My user is a member of 'Admins' but not 'Teachers' - in the RolesRequired I have "Admins, Teachers" but the page won't load saying I do not have authority. Can you please advise.
Thanks
Richard
I have ensured that the binding process works by creating a simple test project. I even have re-tested the project today and found no problem.
I enclosed the Model, ViewModel, and View folder of my test project. Please have the attached folders tested on your end and let us know whether it works or not.
Thank you for your valuable feedback and the sent sample. It really helps to reproduce the reported problem in here.
I started my investigation by comparing both of the projects (ClientUIBusinessApp1 project – attached on May 27, 2013; and RolesRequiredTest project – attached on June 5, 2013) and found that if TransitionStrategy property is not set then the reported problem is no longer persisting.
The step by step below shows how to apply the changes in RolesRequiredTest project.
<Style TargetType="Intersoft:UXFrame"> <Setter Property="EnablePageTransition" Value="True"/> <Setter Property="BackTransitionEffect" Value="Custom"/> <Setter Property="DefaultTransitionEffect" Value="Custom"/> <Setter Property="NewTransitionEffect" Value="Custom"/> <Setter Property="ForwardTransitionEffect" Value="Custom"/> <Setter Property="AutoDetectNavigationDirection" Value="True"/> <Setter Property="UseCachedVisualForTransition" Value="False"/> <!--<Setter Property="TransitionStrategy" Value="WaitContentReady"/>--> <Setter Property="PresenterStyle" Value="{StaticResource EasingContentTransitionStyle}"/> </Style>
I will continue my investigation to find out other possibilities or solution which may cause the problematic behavior. Should you have different result, please feel free to let us know.
Hi Richard,
Currently, the RolesRequired implemented "and" algorithm for the multiple roles, which follows the original implementation in .NET.
However, we realize that this may be not ideal in certain scenarios. Do you have any feedback on the ideal implementation that can support both "and" and "or" algorithm?
Thanks.
Thanks for the quick reply.
Firstly I would suggest the default implementation is for ‘or’ (and not ‘and’) – that is access should be granted if a user is in 'role1' or say 'role2'. This I believe is the correct and usual way to implement role based authorisation – the way aspnet role membership works. See web.config below
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<authorization>
<allow roles="Interviewers,InsiteAdmin" />
<deny users="?" />
</authorization>
</system.web>
</configuration>
<allow roles="Interviewers,InsiteAdmin" /> means users in either “Interviewers” or “InsiteAdmin” have access.
See http://msdn.microsoft.com/en-us/library/acsd09b0(VS.80).aspx
If you had a page/process that allows access by users in ‘AdminsRole’ and other users in ‘ManagersRole’ then your implementation would require all ‘Admins’ users to be added into the ‘Managers’ role as well – this does not make sense!!!
Hope this makes it clearer.
The documentation mentions that this property (rolesrequired) can be databinded (to a property in viewmodel/model) – is this implemented? This would enable the developer to add more complex logic if required. If so can you provide some sample code, thanks.
I await your reply.
Thank you for your reply and feedback.
We will change the required role implementation to an "or" logic in the upcoming hotfix (should be due next week).
Yes, the property can be databound to a view model. You simply need to have a property in your view model that describes the required role for the page, then bind that property to the RequiredRole property of the UXPage. This should be similar to the basic implementation in MVVM pattern.
Let me know if you have any other questions.
Hope this helps,Jimmy
thanks.
Data binding..if this is correct below...it does not work.
ViewModel property as below
Public ReadOnly Property GetRoles As String
Get
Return "Teachers"
End Get
End Property
View
RequiresAuthentication="True" RequiresRole="{Binding Path=GetRoles}"
Below is the step-by-step when I tried to bind the RequiresRole property.
I added a new class to the ViewModel folder and name it as TestClass1.cs. Next, following code is added into the TestClass1.cs.
using Intersoft.Client.Framework.Input; namespace ClientUIBusinessApp1.ViewModels { public class TestClass1 : ViewModelBase { // Fields private string _rolesRequired = null; // Constructors public TestClass1() { _rolesRequired = "Administrators"; } // Views public string RolesRequired { get { return _rolesRequired; } set { _rolesRequired = value; OnPropertyChanged("RolesRequired"); } } // Methods private bool Validate() { // TODO: Put your application logic here return true; } } }
After done with the TestClass1.cs, open the xaml page and declare the namespace that maps to the TestClass1.cs class in the corresponding page.
<Intersoft:UXPage ... xmlns:ViewModels="clr-namespace:ClientUIBusinessApp1.ViewModels" ... >
Instantiate a new instance of the TestClass1 class in the UXPage data context.
<Intersoft:UXPage.DataContext> <ViewModels:TestClass1 /> </Intersoft:UXPage.DataContext>
Bind RequiresRole property of the UXPage to the RolesRequired property that exist in the ViewModel.
<Intersoft:UXPage ... xmlns:ViewModels="clr-namespace:ClientUIBusinessApp1.ViewModels" RequiresRole="{Binding RolesRequired}" ... >
Hope this helps.
have you tried this and it works - It does not work for me - in my viewmodel the RolesRequired property is called as the page loads - so it appears to bind but does not actually work as intended.
public string RolesRequired { get { return _rolesRequired; } set { _rolesRequired = value; OnPropertyChanged("RolesRequired"); } }
If I change back from
RequiresRole="{Binding RolesRequired}"to RequiresRole="Administrators" it works.Can you confirm you have tested and works, thanks?Richard
still can't get this to work. Once I have set up (I copied the Customers xaml code into my customers.xaml and added the TestClass1.cs (viewmodel) - the form does call the RolesRequired property of the Viewmodel but does not correctly apply the authentication i.e. it allows access to the page when user in not the the Group (Administrators) - when I set the RolesRequired back from 'Binding RolesRequired' to a string 'Administrators' it works.
You say you have this working - have you got this working and tested with proper users and roles set up i.e. proper data??
For binding to work this way the framework would need to be able to handle instantiating the viewmodel class (and getting the rolesrequired) then be able back out and stop the page loading (without other viewmodel business logic being run e.g. loading lists etc) if the user is not in a particular role - I'm not sure it does this yet.
After being investigated by our ClientUI development team, we’ve found that the binding process was too late. Since the binding is a feature in Silverlight/WPF itself, there is nothing we can do for workaround.
The ClientUI development team has agreed to enhance this binding scenario so that the binding can still work with this feature. The enhancement is filed under Task #872.
I apologize for any inconvenience this problem may have caused you. I will keep you updated with any news I heard from the team regarding Task #872.
Can you please update me as this is still not working in the latest version, thanks
I enclosed a simple Silverlight project which implements binding on the RolesRequired property. In the project, I have created four usernames.
I have tested and checked that Customers.xaml page can only be viewed by users which have Administrators role.
Please have the attached sample evaluated on your end and let us know if you have different result. (fyi: I’m using latest build of ClientUI 8 assembly files).
Thanks for prompt reply - will look at and report back -once tested
The sample app you supplied does work as intended....however I am using the Metro template and this does not work the same. I have supplied a sample Metro app (using same customers.xaml and copeid your aspnet.mdb) to show you.
The code works ok if say 'jilldoe' signs in - she is prevented from accessing the Customers page - however if no one has signed and you try to access the Customers page the Login page pops up for a second then disappears and the customers page is loaded. Looks like a bug to me!!
I await your findings, thanks
Initial tests appear to show it now working correctly, thanks. I will do more testing over the next weeks and report back any issues.
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname