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):
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.
For this demo, I will show creating a new user, but if you already have a user base you can of course use that.
Notice we get full validation here.
Any now, when we log in the app knows who we are..
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.
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.
Then when we log in we get data!