I am working on a project that uses both MVC and KnockoutJS and I am wondering about how best to provide security to the site.
Here is my issue.
I am allowing views to be created using Razor and I am using Knockout to power a lot of the features via JQuery dialogs. I have a master view model that looks as follows:
my.MasterViewModel = function () {
var
CatalogsViewModel = ko.observable(null)
BulkUploadViewModel = ko.observable(null),
ExploitationTypeViewModel = ko.observable(null),
ExploitationViewModel = ko.observable(null),
InviteSongWriterViewModel = ko.observable(null),
ManageCollaboratorsViewModel = ko.observable(null),
ManageSongwriterViewModel = ko.observable(null),
ManageSongViewModel = ko.observable(null),
ProViewModel = ko.observable(null),
SongsViewModel = ko.observable(null),
TagsViewModel = ko.observable(null),
TweaksViewModel = ko.observable(null),
NotificationsViewModel = ko.observable(new my.notificationsviewmodel());
return {
CatalogsViewModel: CatalogsViewModel,
BulkUploadViewModel: BulkUploadViewModel,
ExploitationTypeViewModel: ExploitationTypeViewModel,
ExploitationViewModel: ExploitationViewModel,
InviteSongWriterViewModel: InviteSongWriterViewModel,
ManageCollaboratorsViewModel: ManageCollaboratorsViewModel,
ManageSongwriterViewModel: ManageSongwriterViewModel,
ManageSongViewModel: ManageSongViewModel,
ProViewModel: ProViewModel,
SongsViewModel: SongsViewModel,
TagsViewModel: TagsViewModel,
TweaksViewModel: TweaksViewModel,
NotificationsViewModel: NotificationsViewModel
};
}();
In my click handlers I then instantiate the required view models and all is well, this works great!
The issue that I'm having is that I have things as follows in my Razor syntax:
<li><a href="#" data-songid="@Model.Song.Id" class="icon-margin-left manage-song">Edit Song</a></li>
In my click handler I read the data-songid value and load the data from the server using knockout. This also works great, however, it is not exactly hard to change the data-songid value in chrome, or firebug, or any number of development tools. Once that value is changed the user can then click the link and edit a different entity... :S
Is there a better way for me to do this? I am very concerned that this is a HUGE security hole in my application.
Thanks in advance!