MVC 5 with REST Security Constraint? - entity-framework

I am looking to build an MVC with Entity Framework app so users with proper credentials can enter and edit data. I then want to expose the data via a REST Web Service so a "public facing site" can consume the JSON data. All users of the public facing site need to be able to view the Web service data without needing to login.
If I lock down my MVC site, will that affect the REST API coming from it, or will the REST be "open"? The REST API will be consumed by a totally different site. I need to separate the editors from the Web users.
Thanks!
K.

You can decorate the controller with [AllowAnonymous] attribute. The rest of the MVC controller you need to decorate with the [Authorize] attribute in order to be protected.

Related

Using a Web activity along with a linked service to call a rest api

I have to send data to a rest API via data factory.
I get batches of records from a database, send them in the body of the REST API call, which provides a response that informs the action performed on each record.
I created a linked service to the base API URL, and this linked service does the authentication to the API.
My question is how I use this linked service along with a web activity in a pipeline?
The web activity requires me to enter a full URL, which feels redundant as the base URL is already in the linked service.
The web activity does let me add multiple linked services but I'm unsure why it allows multiple linked services and how this is supposed to work.
I would appreciate expertise regarding how the web activity works with a linked service.
Thanks!

REST API SERVICE FOR COLLECTING FORM DATA in JAVA

im planning to develop a webapplication using java and HTML implementing as REST Services and confused how ot start with what technologies..
As a First step my first requirement is just creating a login HTML page and create REST SERVICE for LOGIN which validates the user by connecting to Database and generates a session and next page say shopping page.
Please suggest the Java jars,ide, etc to start.
Sorry, your problem is very complex.
To make a website such as shopping page, you can write code with REST services or no need.
If REST Services is used, you must build and setup 2 system/application: web app & server app. (front-end & back-end). With any system/app, you need technologies its own.
To done, you must know many knowledges such as:
API, Rooter, OOP, MVC, how to connect DB,...
There are many IDE such as Eclipse,... or only need a Editor with a few plugin.

RESTful API Architecture

I'm developing a project to be used by both a smartphone app and a single page app website. I'm using Backbone.js for my data binding.
I've got a bit of an architectural question: How do I make my API restful, yet enrich the data coming back in my models.
An example:
I would like to change the roles of a user in a group.
In the restful case, I'd load a collection of the roles for a particular user in the group. I'd check and uncheck the roles I'd like to apply to the user in the context of that group, then save. I'm therefore doing a GET for the array of roles and a PUT to save the altered list. The issue I am facing is that I need to enrich my model with more meta data such as the Group's name, the User's name etc so the user has some context when editing the data.
I can quite easily do this but then I'm not really restful anymore with my model.
Does anyone have any resources they can point me to that can help me to architect my solution to achieve the best of both RESTfulness and usability using Backbone.js?
Backbone model does not make your application more or less restful.
For the most part, rest is about the interactions between the HTTP client and server.
Like in REST API URI Design Approach question, mostly the focus is on the URI design.
The more practical way of thinking or applying REST as the starting point (at least it works for me) is to think in the following ways:
1) Use only HTTP ‘GET/POST/PUT/DELETE’ as the way to model your domain ‘actions’ . Just like when you dealing with database, all your actions are mapped to CURD.
2) URI/URL is to identify resources only. Should never have any ‘actions’ in your URI.
3) The data exchanged should be in the body of the HTTP messages.
Just to simplify the discussions, not getting into how to model the data itself
Two great books on rest.
REST in Practice
Restful Web Services
You can create a Restful web service which can be consumed in both smartphone app and a single page app website.
Please have a look at
http://blogs.msdn.com/b/hongyes/archive/2012/08/30/single-page-application-with-backbone-js-and-asp-net-web-api.aspx
Here they are creating SPA with backbone.js and ASP.NET Web API ( to create Restful web service).
Other great resource can be found here:
http://www.asp.net/single-page-application/overview/templates/backbonejs-template
Thanks.

What is the benefit of RESTful Web Service Vs Using Just a simple Servlet?

Regardless of whether I create a RESTful Web service to be consumed by Ajax in my own pages, or by any user, I can provide the same functionality (data) to the application or user using a simple servlet.
I mean the user or application don't see any different between response provided by a simple servlet or respone provided by a RESTful web service. So, I'm guessing that the benefit is on the server side and to the developers. Can someone please tell me what are the benefits of using RESTful web services.
I appreciate any respone
By definition a webservice is intended to be consumed by any client granted access. If the client you are developing is the only application that you will ever need or want to access the resource then there is little benefit to creating a webservice. However, if you want to make the resource available as a service endpoint for more than just this application in a way that is implementation agnostic then a Restful webservice is a great way of doing it.

Silverlight RIA application using services from different web site

I have a Silverlight application that uses both a RIA authentication domain service and a RIA entity domain service. The application works properly when run in a standard deployment scenario where the RIA services are consumed from the same ASP.Net web site that the Sivlerlight app is downloaded from.
In order to make my deployments more flexible I'd like to use separate web applications for hosting the RIA services and to host the Silverlight application. I've managed to get the RIA services working in a separate site and updated my Silverlight application to point to them. The problem is the authentication seems to break. I've looked at the RIA requests in fiddler and the authentication cookies are seemingly correct.
Has anyone managed to deploy a Silverlight RIA application with the RIA services hosted on a web site different to the one the Silverlight app is downloaded from?
Edit: this won't help you either.
http://msdn.microsoft.com/en-us/library/ee707359%28v=vs.91%29.aspx
The domain context class contains three constructors:
A default constructor that embeds the URI necessary to communicate with the domain service over http using a WebDomainClient class.
A constructor that permits the client to specify an alternate URI.
A constructor that permits the client to provide a custom DomainClient implementation (typically used for unit testing or redirection to a custom transport layer).
In the end the only difference I used fiddler to look at the difference in the requests that were working for a self hosted RIA service and an external one and the only difference was the HTTP referrer header. It would seem strange that the RIA RequiresAuthentication attribute takes the referrer header into account so perhaps it's something else entirely.
I was able to find a way to consolidate my domain and authentication services into a single one and allow it to be hosted on a different web app which is very handy. The approach was to put the AuthenticationDomainService into the main domain service. It doesn't allow the same usage pattern on the client, authentication is an entity load operation, but it does still make it easy to use an ASP.Net membership provider for authentication.
[EnableClientAccess]
public class MyDomainService : LinqToEntitiesDomainService<MyEntities>, IAuthentication<User>
{
public class AuthenticationDomainService : AuthenticationBase<User>
{ }
private AuthenticationDomainService m_authService = new AuthenticationDomainService();
public User Login(string username, string password, bool isPersistent, string customData)
{
return m_authService.Login(username, password, isPersistent, customData);
}
....