How To Securely Mobilize Data Using a REST API Backend
Don't leave that data unsecured. Employ a REST API backend to securely mobilize it. We'll look at native installs, auto-generated services, and a RESTful platform.
Join the DZone community and get the full member experience.Join For Free
we get lots of inquiries about how the dreamfactory rest api platform helps secure data access, particularly from larger enterprise and government users. it's a valid concern: a growing number of web and mobile apps need to access sensitive data, and proper controls must be implemented in the services used to access that data from an expanding number of apps.
the good news for users is that securing data was one of our top design goals when architecting the dreamfactory platform. we can even argue that it can provide better data security than most custom-built apis. but rather than arguing, i thought i'd just simply explain the inherently secure characteristics of the dreamfactory platform and the explicit security features that have been engineered into the plaform to help users securely mobilize data.
dreamfactory is an open source software package that runs in the cloud or on premises. single-click installers are available for most of the infrastructure as a service (iaas) and platform as a service (paas) cloud vendors. you can also run dreamfactory on a linux, windows, or mac desktop computer. the software package includes a complete lamp stack with php and a dedicated sql database that can be installed on any server.
these versatile installation options enhance security by putting organizations in control. they can use the same secure deployment practices for dreamfactory that they already use for their other applications. they can monitor usage, make backups, control cost, optimize performance, configure firewalls, and deploy applications with familiar tools and systems. companies can choose a trusted cloud vendor or their own data center to manage application security.
native installation and operation is a major advantage over mobile backend-as-a-service (mbaas) offerings. since dreamfactory is not hosting the platform, there is no risk of our company losing your data. you do not need to worry about where our data center is located, who has access to your private information, or how we keep your data separate from other customer accounts.
automatically generated services
rest api complexity is a major security challenge. with each new mobile or web project, there is a tendency to create more and more project-specific rest apis. each service may be written in-house, by different developers, or by external consultants. these services typically have different user-management systems, different security protocols, different parameter styles, and different requests and responses. they will be hardwired to various data sources, and designed to run on different pieces of physical infrastructure. over time, the server-side infrastructure can become increasingly complex, and each new rest api endpoint can potentially introduce new security vulnerabilities. and while api management and gateway products can help manage api endpoint access, they don't address the security and user permissions of the underlying services.
by contrast, dreamfactory automatically generates rest apis and provides users with a unified rest api services platform, designed expressly with security in mind. this provides organizations with a single type of system for managing data access in a purpose-built rest api platform. the provides better security than trying to implement security features into an ever growing number of custom-built rest api endpoints.
dreamfactory provides a comprehensive palette of secure, reusable, customizable rest api services. all of the various backend data sources are accessed through a unified rest api interface, providing a secure, restful services platform for general-purpose application development. the total number of exposed service endpoints is greatly reduced, and the connections and access controls to backend data sources are standardized and managed within a purpose-built system.
restful services platform
in a typical mobile development project, there is a client team and a server team, and the two groups must agree on a rest api interface. by auto-generating the needed rest apis, dreamfactory stops this back and forth interface negotiation and allows each side to focus on their respective areas. dreamfactory enhances security by “decoupling” client-side application development from server-side user management and administration.
applications written on a unified restful services platform also benefit from virtualization provided by the services layer. services are no longer tied to specific pieces of backend infrastructure. moving an application from development to testing and on to production is much easier. the services platform can be installed anywhere, so applications can be moved between the cloud and data center. application staging becomes simpler, and overall application lifecycle management becomes more secure.
in many projects, external consultants create the client-side application, and in some cases, they also build the server-side interface. with dreamfactory, trusted members of the it staff can easily and instantly create secure rest apis for each new mobile project. the platform can provide access to a staging or production database as needed. the client application can be moved from development, to testing, and on to production without code changes. this reduces the need to expose corporate information and backend systems to external partners working on development projects.
when a user signs on to dreamfactory they receive a session id, which is securely managed as a browser cookie in an html5 application or as a transient local variable in a native application. all network transactions can be conducted over https, thus adding the security capabilities of ssl/tls to standard http communications.
administrative updates to user roles and permissions are instantly reflected in the current session. for example, if a user is inactivated his session becomes invalid immediately. this provides a more secure environment for people entering or leaving the company, and for lost devices or security breaches.
role-based access controls
sql databases have various tables, nosql databases have collections of documents, and file storage systems have different folders. dreamfactory users can define role-based access controls that govern which of these components are visible to a given user, along with http verbs such as get, post, or delete that govern access.
role-based access controls allow information to be hidden from certain groups. for example, individual salespeople might not have access to salary information, while this data might be available to managers. this capability prevents accidental data loss or disclosure of sensitive information. roles also control which users can see which applications. this capability limits application access to unauthorized users.
record-level access control
roles can be customized with server-side filters to implement record-level access control. each filter takes the form of a "field operator value" equation that must be true to enable access. the record-level access controls can impose constraints on external data sources. for example, you can limit data visibility only to records that the user created. this feature provides fine-grained security control of data sources.
dreamfactory provides very extensive user management features. single sign-on, user roles, guest users, open registration, password resets, email services, email templates, and password hashing are all carefully implemented. the standardization of user management as a service and the integration of user management with the rest api platform prevent the security holes often found in custom api implementations.
inheriting sql security
dreamfactory acts as a secure proxy for external data sources. when a sql database is hooked up with a connection string, dreamfactory automatically inherits the security characteristics of that database. for example, if the connection string is for a read-only database user, then the rest api will deliver all the services as read-only, regardless of other access control settings.
dreamfactory can also inherit more complex permissions from a sql database. you can configure server-side lookup keys to connect a user or role to the corresponding user or role on a remote database. this allows dreamfactory to mimic existing database security permissions, or change them as needed for mobile deployments.
master credential storage
dreamfactory can connect to any number of external data sources and services. dreamfactory functions as a secure proxy that creates rest api services, provides server-side scripting, and enforces role-based access control. each external data source or service will typically require a connection string, username, password, developer key, or some other type of master credential for access.
these master credentials are entered by an administrator in the dreamfactory admin console and encrypted for secure storage on the dreamfactory services platform. when an end user logs in through single sign-on, they have controlled access to external data sources and services as enabled by their user role, but there is no way for them to discover the master credentials.
this capability to hide master credentials securely on the dreamfactory server removes the need for client applications to use the master credentials for any external service. end-user access is provided through single sign-on and limited by the user-base access controls. another benefit of this architecture is that external services can be activated, deactivated, or redirected without changing the client software.
dreamfactory is written with the latest version of php and the laravel framework. php is the world’s most widely used server-side scripting language, and laravel is the fastest growing framework for php. there is a very large community of professional developers using these products, and many mission critical websites depend on them for secure implementations. dreamfactory uses laravel’s user management system and url routing system for reliable and secure operation.
programmable cors access
dreamfactory implements cross-origin resource sharing (cors) as a system level web service. the admin panel has a simple interface that can enable any host domain to use the dreamfactory rest api. by default, cors is turned off and the services are only available from the originating host. programmable cors support prevents cross-site scripting attacks and use of the api from unauthorized sources.
scripting and customization can be used for formula fields, field validations, workflow triggers, access control, custom services, and usage limits. a third party can use server-side scripts to safely customize the backend system. custom security protections and notifications can also be implemented with server-side scripts.
server-side scripts can use the rest api when needed. for example, a script might call the email service, trigger a push notification, or store some information in the database. the role-based access controls have separate settings that govern data access for both client-side applications and server-side scripts. this capability enables server-side scripts to safely perform special operations that are not available from the client-side rest api.
sql injection attacks
the dreamfactory rest api for sql includes the ability to use query filter strings as url parameters. for example, you could request all of the opportunities greater than a certain amount, or created before a particular date. each query filter string typically has a field name, operator, and target value. they can be combined into complex expressions with parentheses and logical operators.
a sql injection attack can occur when a hacker types a tricky text string into a search field or constructs a malformed query filter for use in a rest api call. they might use strange escape sequences, incorrect type handling, or unusual patterns of fields, operators, and values.
dreamfactory deconstructs each query filter string into individual name, operator, and value components. the field name must match the object, the operator must make sense, and the field value must be well formed. after this, the query filter string is reconstructed with only valid parameters. this prevents unauthorized sql statements from being injected into the database.
url routing attacks
another attack vector concerns spoofed url strings, illegal url parameters, or tricky http headers that somehow manage to bypass role-based access controls or otherwise returning sensitive data from the platform. dreamfactory uses the routing engine in the laravel php framework to avoid this problem.
the security of the rest api interface has also been rigorously tested by hundreds of thousands of dreamfactory users actively building projects. the fact that all of the rest api calls have a single entry point is also more secure than having separate entry points for each backend system.
the dreamfactory source code is available under the apache license on github. an open source product has "many eyes" on the code base. we have signed up for third-party security audits as well. dreamfactory software also has quality assurance engineers looking for security problems on a regular basis. thousands of independent developers are also testing the platform daily. the open source nature of the code base enhances security.
a secure ending
most organizations only want authorized users to access sensitive data and api services must be secure--on multiple levels--to provide adequate security. as i mentioned at the top of this blog, dreamfactory was designed from the start to provide a highly-secure rest api services platform . i've summarized the many ways dreamfactory helps users securely mobilize their data. perhaps i've even stimulated some thoughts (or concerns!) about security vulnernabilities in your current custom-built apis.
should you have additional questions on dreamfactory security features, the engineering team and i welcome your questions.
Published at DZone with permission of Bill Appleton, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.