Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Articles
Search: 

Designing Security In Your Visual FoxPro Applications
Janis Booth, January 1, 2001
This material was presented at GLGDW and DevCon and will be presented at Frankfurt next month. Overview We have all heard it, "This application needs security in it that is very powerful and that protects the data?". What does that mean? What is "Powerful" security? What does the data need to b...
This material was presented at GLGDW and DevCon and will be presented at Frankfurt next month.

Overview

We have all heard it, "This application needs security in it that is very powerful and that protects the data?". What does that mean? What is "Powerful" security? What does the data need to be protected from? How much should this security cost? How do we measure the cost of the security?

Consider your home, you would like to feel that there is some security there. You can use deadbolt locks, you can install an alarm system, you can dig a moat around your home, your can build a 3 foot thick concrete wall 10 feet tall with razor wire on the top, you can do all sorts of things to secure your home. But how far should you go? The moat and wall may be overkill, but why?

The answer to these questions can be found by doing a security analysis. This analysis is the subject of this presentation.

The Security Problem

Before you can successfully solve any problem you must thoroughly understand what the problem is and what the pieces of the problem are. The security problem is comprised of two pieces, a potential threat and a potential loss. If either of these is missing then there is no need for security.

If a system has no potential threat then nothing can violate security so why bother building it. Conversely, if a system has no potential loss then there is no cost justification for providing security because there is no loss to prevent.

Potential Threat

What kinds of potential threats can there be against a database application? The types of threats can range from unauthorized changes to data to confidentiality violations. These threats can come form inside the organization or form external sources.

Who is it that poses the threat? The source of the threat can be from employees, hackers, or professional corporate espionage agents. It is important to assay the source of the threat because the measures you take for protecting from amateurs will vary greatly from the measures you would take to protect from professional espionage agents.

Potential Loss

As well as assaying what the potential threat is you need to now what the potential loss can be. The potential of the loss will aid greatly is deciding what cost for security can be justified. First determine what the loss might be.

Losses can be a violation of privacy, the entry of invalid data, or a business disruption. Any one of these can result in a financial loss. You need to quantify the potential financial loss in order to evaluate the cost justification of the security measures you will undertake.

Cost of Protection

You determine the potential cost of a loss by factoring the potential threat and the potential loss. Both need to be considered in order to quantify the factor.

You then need to determine the cost of protection. Cost of protection is not a simple issue, there are many factors involved including the cost of development, the lost efficiency due to the protection's interference with using the of application as well as reduction in productivity due to a reduction in performance of the application as a result of the overhead of the security layer.

Protection Points

As you have seen the nature of the threat and the source of the threat can be wide ranging, because of this the approach to providing protection can also cover a wide variety of issues. Some of the threats will require that we prevent the potential culprit from even accessing the computer at all. In this instance physical security can play a role. Providing locks on rooms and security guards for the buildings may be required. Alarms systems can be involved at this level.

Computer or Network

The physical securing of the computer or network is outside the realm of our application. Most networks provide a level of security built into the network operating system and there are third party solutions that can be purchased to enhance the security provided by the network system. It may become necessary to retain a computer security consultant to provide the level of security needed for the network or the computer system itself.

Application Access

The first level of protection we can provide within our application is to secure access to the application entirely. This can be provided in one of two ways, we can either set security access within the network system to prevent unauthorized users from even seeing the application on the network or we can secure the application with a login process that verifies the identity of the user when they try to launch the application.

Often we will use both of these approaches, providing what security we can at the network level and requiring the user to log into the application with some method of identity verification. The method of identity validation can range from a simple password to some very sophisticated third party systems of identification.

Menu Security

Menus can be secured in one of two ways, either by having unauthorized menu options visible but disabled or by removing the unauthorized menu options from the menu system completely. Visual FoxPro is able to handle either method or even a combination of both approaches simultaneously.

You can use the SKIP FOR option of the menu options to control the enabling and disabling of the menu items. To provide for the presence or absence of menu items you can either modify Genmenu.prg or you can use GenMenuX (a public domain utility) to provide IF/ENDIF statements around the DEFINE commands in the menu program.

Form Security

In some cases it is required that an entire form be made unavailable to a particular user. This can be accomplished by either disabling or removing the menu item for that form or by having the form check its availability in the security system during the form's Init and then returning either .T. or .F. according to the rights of the user.

Functionality in Forms

Even though a particular user has rights to access a certain form, that user's security rights may require that certain functionality be made unavailable. Perhaps the user is allowed to view the information in the form but is not allowed to edit or add records. The provision of this level of form security is dependent on how the functionality is made available in the form. If the interface uses toolbars then the toolbar buttons can be enabled/disabled appropriately. If the form is using buttons contained inside the form then those buttons must be enabled or disabled to restrict or allow access to the functionality.

Tables and Fields

If it is necessary to grant and/or restrict rights on a field level you will need to provide this security in the control classes. Since it is the controls that manage access to fields it make sense that the control would be used to control security to the fields. The control's Init can access the security system to determine the access level allowed for the user and then set the appropriate properties of itself to provide that level of security.

Security Manager

To coordinate all of the aspects of the security system it would be helpful to have a security manager object as part of the framework of the application. This security manager would have methods that any form, menu, or control could call upon to determine the proper level of security for itself. This approach centralizes al of the security code in a single object with other objects requesting information from it.

In order for a security manager object to be able to provide the information that other objects may request it would be necessary to provide a data structure to store that information. The figure below is an example of a possible security data structure.

In addition to providing the structure to store this information you would also need to provide the forms that would allowed the system administrator to enter the information.

How might it all work?

Security needs to be designed into the overall framework of your application. The general design of the framework will dictate exactly how the security subsystem will fit in, but here is an example of how it might work.

On starting the application the user would interact with a login form identifying themselves and entering a password for verification. The current user would be recorded by the application framework somewhere for future reference.

The framework would create a security manager object to provide the various security services to the application.

Menus, forms, toolbars, and data controls would all check with the security manager to determine their security levels. The security manager would investigate the object requesting security information and the then current user and mask the information on the security data to see what the security level is. This security level information is then sent back to the object inquiring and that object does what it needs to do in order to comply with the security level.

A menu might eliminate an item form itself or set the skip for setting. A form may refuse to instantiate. Toolbars would enable or disable their buttons according to the user's rights. Data controls would set their properties to provide the required securing of the data.

The exact code required to accomplish these goals would vary according to the overall structure of the framework and the security features required in the design of the application.

Janis Booth, Webmd
Janis is a senior developer for WebMD. Janis is Microsoft Certified Professional. She has received the Microsoft Most Valued Professional award each year since the program began in 1993 up until 2003. She works for the eMedicine division of WebMD which is a division of eMdeon corporation. Most of Janis' work is using Visual FoxPro as a middle layer development langauge for web based medical content authoring as well as for web sites that present medical information focused to medical professionals.
More articles from this author
Janis Booth, January 1, 2001
The N-tier model The term N-Tier refers to the various levels of responsibility is a system’s design. The N in N-tier can be any number from 2 on up. A very common design is the 3-Tier model. In the 3-tier model the application is divided into 3 distinct tiers of responsibility, the user ...
Janis Booth, January 1, 2001
This material was presented at GLGDW and DevCon and will be presented at Frankfurt next month. Overview What we will see Designing a framework is not a small undertaking. There are many considerations to be addressed by the design. Using an effective design can mean the difference between suc...
Janis Booth, January 1, 2001
Object oriented system development is new to many of us and being new it presents some challenges. Among those is the process of planning and managing a project. Most of us have developed projects before. On those projects we have worked with the users to discover what the system was to do and ho...
Janis Booth, January 1, 2001
User interface design is a vast and often misunderstood area of application design. Too often, in application development, there is a large amount of time spent designing the data and the application framework. There is very little time spent designing the user interface. We build forms and pu...
Janis Booth, January 1, 2001
Visual FoxPro is Object Oriented. So what does that to me as a developer? How can object orientation make my life easier? We all know there is a learning curve to climb in order to understand objects and we’ve been told there is a payoff for climbing that curve. This papern will investigate ...
Janis Booth, January 1, 2001
This session will be focused on the new OLE Drag and Drop capabilities in Visual FoxPro 6.0. Although our focus is on Drag and Drop we will spend some time discussing the user interface technique of direct manipulation in some detail in order to understand where drag and drop fits into user inter...