My company is going to redesign a large project from scratch. We are currently thinking about how to implement data providers. I have used to integrate some web services in the last few months and to a large extent as processing data in this way. So I was thinking about RESTful design. We will use ColdFusion 10, which comes with REST support, but I really don't like the component structure needed for this.
The biggest advantage is probably that we can use REST to provide data for all our platforms, namely: website, mobile site, and iOS / Android application. My approach to security will be as follows: Access to public data can be obtained by anyone (obviously). Access to private data is possible only with BasicAuth. Using BasicAuth also allows us to create user roles with different access levels. Authorization will be implicit and based on the session / login.
<cfset requestedID = 123> <cfhttp url="/customer/#requestedID#" method="get" username="#APPLICATION.REST_SYSTEMUSER#" password="#APPLICATION.REST_SYSTEMUSER_PW#"> <cfhttpparam type="url" name="includeAddresses" value="true"> </cfhttp> { "ID": 123, "FirstName": "John", "LastName": "Doe", "Birthday": "1970-01-01", "BillingAddress": { "Receiver": "John Doe", "Street": { "Name": "Main Street", "Number": "13", "Addition": "" } "City": { "ZipCode": "AB-123", "Name": "Sampletown", "District": "" } }, "ShippingAddresses": [ ] } <cfset customerJSON = deserializeJSON(CFHTTP.FileContent)> <cfset customer = createObject("component", "Customer").init(customerJSON)>
Here are the questions that came to my mind:
- Can this general REST approach be used for everything on every page? (Is it wise to use REST on websites to start with?)
- Do local HTTP requests affect performance and slow page loading?
- Is BasicAuth sufficient to protect data? (I would just add minor security features, such as anti-spam protection).
- Is it better to avoid dependencies in the web service, for example
/customer/ to access /address/ to get your data?
On one of the other (older) websites, we have file-based data providers (including components and components that take care of accessing the database, etc.), but we ran into several problems with more complex pages ( for example, by the verification process), for example, name conflicts include, opaque and heavy components, mixing model / view / controller elements, etc.