More update on my Mix09 talk “building business applications with Silverlight 3”.

You can watch the original  video of the full session 

The demo requires (all 100% free and always free):

  1. VS2008 SP1 (Which includes Sql Express 2008)
  2. Silverlight 3 RTM
  3. .NET RIA Services July '09 Preview

Also, download the full demo files and check out the running application.

Today, we will talk about Authentication  

Business applications often access very important data.  It is important that you can audit, restrict and control access to your data.  Let’s look at how to use .NET RIA Services and SL3 to do that. 

Using the Silverlight Business Application Template this is super easy to do..  By default it is wired up the ASP.NET authentication system that offers a customizable user management system.   

I’ll show using Forms Auth, you can of course use Windows Auth with only very small tweaks to the template. 

image_thumb[56]

For this demo, I will show creating a new user, but if you already have a user base you can of course use that. 

image_thumb[57]

image_thumb[58]

Notice we get full validation here.  

Any now, when we log in the app knows who we are..

image_thumb[59]

Notice all of this UX on the client is completely customizable as all the source code is right there in the project.  But the out of box experience is not bad for many apps. 

Now that we are logged in, let’s do something with that user data.  For example, let’s make it such that only logged in users can access the super employee data.  Edit the SuperEmployeeDomainService class on the server to add the RequiresAuthentication attribute.  There are other attributes for things like “in role” and there is a way to do this in code if you’d like. 

[RequiresAuthentication]
public IQueryable<SuperEmployee> GetSuperEmployees()

Now, when we run this app and we are not logged in we get no data.  Notice this validation is done on the client for a good UX and again on the server to ensure security. 

image_thumb[60]

Then when we log in we get data!

image_thumb[61]