An example of a Secure Dynamic Data Site is
available on the Dynamic Data samples page on CodePlex:
http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=14473.The
Secure Dynamic Data Site allows or denies user's access to the database tables based on the user's authenticated role.
Furthermore, it allows or denies user's table actions based on the user's authorization.The site integrates the ASP.NET forms authentication with a new concept of authorization
provided by Dynamic Data.
To achieve these objectives the Web site uses the following security mechanisms:
·Authentication (forms authentication) performed by ASP.NET. It provides the first security level, which enables you to allow or deny access to a table to authenticated users in function of their role.
·Authorization performed by Dynamic Data. It provides the second security level which enables you to allow or deny access to tables and specific actions on the tables as specified by the
SecurityAttribute properties in the data model. The roles used in the attribute must be the same role used by ASP.NET authentication.
Note Only the tables flagged with
SecurtyAttribute are displayed in a
scaffolded site.
The site uses scaffolding, which is enabled. It also uses a SQL-Express database for both AdventureWorksLT and Aspnetdb (security database).
Steve, I want to thank you for your remarks. Please, feel free to modify my example and let us know what you can come up with.
Remember that the two basic design principles I adopted are as follows:
1.Use ASP.NET Forms Authentication to discriminate the user's roles.
Everything you do in terms of authentication such as modify permissions, if I understand you correctly, must be integrated I believe with ASP.NET authentication mechanism.
2.Use ASP.NET Dynamic Data to authorize authenticated users to perform tasks at lower level, tasks only understood by Dynamic Data. Probably the centralization of field security should be done at this level. May be you
can expand on this: I'm still looking into a way of centralizing the Field Security.
Thanks,
Michael (aka veloce)
This posting is provided "AS IS" with no warranties, and confers no rights.
Yes I understand the principals have a look at this post
Dynamic Data - Default FieldGenerator which I think could be the way forward for Field Security.
[:D]
Dynamic DataAttributes Based Permissions
See my blog C# Bits | Twitter @sjnaughton Always seeking an elegant solution.
Thanks heaps for sample, I have implemented on my site and it works ok. I had a couple of questions.
Delete is only available for the role tagged as 'administrator' How would I go about allowing other user roles to have delete access on certain tables? I tried adding the 'Delete' action in attributes but it didn't work.
Hi Mdausmann, in this sample from Veloce, you have to be admin to get delete facility you will need to look at the test on each page e.g. List page:
// Enable delete button only to allowed users.
private void SetDelete(TableRow row)
{
// Instantiate the SecurityInformation
// utility object.
DynamicDataSecurity secInfo =
new DynamicDataSecurity();
foreach (Control c in row.Cells[0].Controls)
{
// Deny delete capability to users that are
// not administrators
if (!secInfo.IsUserInAdmimistrativeRole() &&
secInfo.IsUserInAuthenticatedRole())
{
// Do not allow delete.
LinkButton btn = c as LinkButton;
if (btn != null &&
btn.CommandName ==
DataControlCommands.DeleteCommandName)
{
btn.Visible = false;
btn.OnClientClick = null;
btn.Enabled = false;
}
}
}
}
if you note the statement:
if (!secInfo.IsUserInAdmimistrativeRole() &&
secInfo.IsUserInAuthenticatedRole())
you will need to change the !secInfo.IsUserInAdmimistrativeRole() to some other test the will test that will check for a role with delete.
Hope that makes sense [:D]
Dynamic DataSecuring Dynamic Data
See my blog C# Bits | Twitter @sjnaughton Always seeking an elegant solution.
The example of a Secure Dynamic Data Site Use CustomDynamicDataRouteHandler to achieve security,but how to transport data of session to
CustomDynamicDataRouteHandler? I need transport custom logined user infomation to
CustomDynamicDataRouteHandler.
I have read your article "Securing Dynamic Data Preview 4 Refresh – Part 1",but it don't demo how to transport session data to
CustomDynamicDataRouteHandler? I need transport custom logined user infomation to
CustomDynamicDataRouteHandler,example:
Roles 、Permissions and orgnization of the logined user.
veloce
Member
196 Points
52 Posts
Microsoft
Secure Dynamic Data Site
Nov 05, 2008 06:55 PM|LINK
To achieve these objectives the Web site uses the following security mechanisms:
· Authentication (forms authentication) performed by ASP.NET. It provides the first security level, which enables you to allow or deny access to a table to authenticated users in function of their role.
· Authorization performed by Dynamic Data. It provides the second security level which enables you to allow or deny access to tables and specific actions on the tables as specified by the SecurityAttribute properties in the data model. The roles used in the attribute must be the same role used by ASP.NET authentication.Note Only the tables flagged with SecurtyAttribute are displayed in a scaffolded site.
The site uses scaffolding, which is enabled. It also uses a SQL-Express database for both AdventureWorksLT and Aspnetdb (security database).
You can move the information to a complete SQL database. For more information, see Deploying a SQL Database to a Remote Hosting Environment.
Please, play with this example and have fun as I did.[cool]
More can be done. I would like to hear from you.Thanks,MichaelI blog at: Technical Notes
sjnaughton
All-Star
27308 Points
5458 Posts
MVP
Re: Secure Dynamic Data Site
Nov 07, 2008 10:33 AM|LINK
Hi Veloce, I like your solution although it doesn't have the granularity that some may want, do you mind if I adapt it into my solution here:
Which in turn extends the earlier articles here:
I think I could adapt it to do the table part, but I'm still looking into a way of centralising the Field Security.
Dynamic Data Roles Permissions Security
Always seeking an elegant solution.
veloce
Member
196 Points
52 Posts
Microsoft
Re: Secure Dynamic Data Site
Nov 07, 2008 07:07 PM|LINK
Steve, I want to thank you for your remarks. Please, feel free to modify my example and let us know what you can come up with.
Remember that the two basic design principles I adopted are as follows:
1. Use ASP.NET Forms Authentication to discriminate the user's roles.
Everything you do in terms of authentication such as modify permissions, if I understand you correctly, must be integrated I believe with ASP.NET authentication mechanism.
2. Use ASP.NET Dynamic Data to authorize authenticated users to perform tasks at lower level, tasks only understood by Dynamic Data. Probably the centralization of field security should be done at this level. May be you can expand on this: I'm still looking into a way of centralizing the Field Security.
Thanks,
Michael (aka veloce)
I blog at: Technical Notes
sjnaughton
All-Star
27308 Points
5458 Posts
MVP
Re: Secure Dynamic Data Site
Nov 08, 2008 05:04 PM|LINK
Yes I understand the principals have a look at this post Dynamic Data - Default FieldGenerator which I think could be the way forward for Field Security.
[:D]
Dynamic Data Attributes Based Permissions
Always seeking an elegant solution.
mdausmann
Member
2 Points
2 Posts
Re: Secure Dynamic Data Site
Jul 11, 2009 02:38 AM|LINK
Hi
Thanks heaps for sample, I have implemented on my site and it works ok. I had a couple of questions.
Delete is only available for the role tagged as 'administrator' How would I go about allowing other user roles to have delete access on certain tables? I tried adding the 'Delete' action in attributes but it didn't work.
[Security(Role = "Anonymous", Action = "AnonymousList")]
[Security(Role = "Developer", Action = "List")]
[Security(Role = "Developer", Action = "Details")]
[Security(Role = "Rule Author", Action = "List")]
[Security(Role = "Rule Author", Action = "Details")]
[Security(Role = "Rule Author", Action = "Edit")]
[Security(Role = "Rule Author", Action = "Delete")]
public partial class BehaviourDocument
{
}
Michael
sjnaughton
All-Star
27308 Points
5458 Posts
MVP
Re: Secure Dynamic Data Site
Jul 11, 2009 08:43 AM|LINK
Hi Mdausmann, I'll have a look at my sample and get back you.
Dynamic Data
Always seeking an elegant solution.
sjnaughton
All-Star
27308 Points
5458 Posts
MVP
Re: Secure Dynamic Data Site
Jul 11, 2009 09:02 AM|LINK
Hi Mdausmann, in this sample from Veloce, you have to be admin to get delete facility you will need to look at the test on each page e.g. List page:
// Enable delete button only to allowed users. private void SetDelete(TableRow row) { // Instantiate the SecurityInformation // utility object. DynamicDataSecurity secInfo = new DynamicDataSecurity(); foreach (Control c in row.Cells[0].Controls) { // Deny delete capability to users that are // not administrators if (!secInfo.IsUserInAdmimistrativeRole() && secInfo.IsUserInAuthenticatedRole()) { // Do not allow delete. LinkButton btn = c as LinkButton; if (btn != null && btn.CommandName == DataControlCommands.DeleteCommandName) { btn.Visible = false; btn.OnClientClick = null; btn.Enabled = false; } } } }if you note the statement:
if (!secInfo.IsUserInAdmimistrativeRole() && secInfo.IsUserInAuthenticatedRole())you will need to change the !secInfo.IsUserInAdmimistrativeRole() to some other test the will test that will check for a role with delete.
Hope that makes sense [:D]
Dynamic Data Securing Dynamic Data
Always seeking an elegant solution.
zzdfc
Member
142 Points
149 Posts
Re: Secure Dynamic Data Site
Jul 12, 2009 02:32 PM|LINK
The example of a Secure Dynamic Data Site Use CustomDynamicDataRouteHandler to achieve security,but how to transport data of session to CustomDynamicDataRouteHandler? I need transport custom logined user infomation to CustomDynamicDataRouteHandler.
Thanks.
sjnaughton
All-Star
27308 Points
5458 Posts
MVP
Re: Secure Dynamic Data Site
Jul 12, 2009 03:16 PM|LINK
Hi Zzdfc, I'm working on a simplified sample based on Veloces work, I should have part 1 ready early this week.
Dynamic Data Securing Dynamic Data
Always seeking an elegant solution.
zzdfc
Member
142 Points
149 Posts
Re: Secure Dynamic Data Site
Jul 14, 2009 01:41 PM|LINK
Hi sjnaughton:
I have read your article "Securing Dynamic Data Preview 4 Refresh – Part 1",but it don't demo how to transport session data to CustomDynamicDataRouteHandler? I need transport custom logined user infomation to CustomDynamicDataRouteHandler,example:
Roles 、Permissions and orgnization of the logined user.