Relational databases facilitate searching and report generation. A relational database generally contains multiple tables of data that are related to one another in various ways. Various security restrictions may be imposed on various data in a database. The restrictions may be that certain data is read-only, both readable and writeable, etc. The restrictions may be imposed based on, for example, users or roles. For example, only personnel in the accounting department may have access to the company's accounting data, and thus accounting data in the company's database may be accessible only to users assigned an accounting role.
One example of security that can be applied to a relational database involves the use of an access control list (ACL). An ACL comprises a list of permissions attached to an object represented by a database record. An ACL specifies, for example, which users or roles are granted access to certain objects, as well as what operations are allowed for given objects.
Sometimes, there may be a desire to retrieve from a database a list of objects of a certain type to which a specific user or role is granted certain permissions. One approach to identify such objects is to query a database to return all objects of the specific type with their corresponding ACLs, and then programmatically determine to which subset of objects from the database the specific user or role has been granted the specific permission. Such systems require multiple queries, involve retrieving all records from the database containing the target subset of data, and then analyzing the permissions assigned to each record. Such queries can be undesirably time-consuming, particularly for large databases.
For a detailed description of various examples, reference will now be made to the accompanying drawings in which:
The non-transitory storage device 104 may comprise any suitable type of storage device such as one or more of random access memory (RAM), hard disk drive, Flash storage, etc. The non-transitory storage device 104 may comprise a single storage device or a collection of storage devices of the same or different type. The non-transitory storage device 104 includes a database 120 and database query instructions 122. The database query instructions 122 comprise software that is executable by the CPU 102 to impart the system 100 with some or all of the functionality described herein.
The database 120 may be implemented as a relational database that stores any desired type of data. An example of data contained in the database 120 is illustrated with regard to
The CPU 102 executes the database query instructions 122 to perform a query of the database 120 in accordance with a request from a user. The query request may be provided by the user via the input device 106 and/or via the network interface 110. The query request causes the CPU 102, upon execution of database query instructions 122, to process the database 120 as described below. The schema design of the various objects and relationships between objects in the database 120 facilitates efficient queries to be performed. For example, a single query with multiple join operations of objects in the database that have certain permission settings for certain users or roles can be performed efficiently and quickly. The schema design of the database facilitates a multi-join, single query to be performed in accordance with various embodiments. Such queries are explained in greater detail below.
The various dashed lines in
As noted above, the various tables 152-164 have primary keys (PK) and foreign keys (FK). Various primary and foreign keys map to one another to define the relationships between the various tables in the database. For example, the foreign key FK3 (domainModelID) in the Cloud Resource table 154 matches a primary key (PK) ID in the Domain-Model table 164 thereby mapping a particular cloud resource record to a record in the Domain-Model table 164. A primary key uniquely identifies each instance of the domain object type defined by the corresponding table. A foreign key is an attribute of a domain object whose value matches a primary key of a related super-class domain object. In the example of
The ERD 150 of
The security tables 170 implement access control lists (ACLs). Each domain object may be assigned its own ACL. As specified in tables 170, each ACL contains the permissions pertaining to the associated domain object. The security tables 170 in the example of
The ACL_SID table 178 (“SID” refers to Security Identity) uniquely identifies all principals and Granted Authorities in the system. A principal is a user. A Granted Authority is a role that can be assigned to a user. The ACL_SID table 178 contains three columns in some implementations—one column for the ID, another column for the textual representation of the SID, and a third column for a flag to indicate whether the textual representation refers to a principal (i.e., a user) or a Granted Authority (i.e., a role). This table includes a row for each unique principal or Granted Authority.
The ACL_Class table 176 uniquely identifies domain objects (type/model) in the system. In some implementations, ACL_Class table 176 includes a column for ID and a column for the class name, and one row for each unique class for whose object (instances) permissions are to be provided.
The ACL_Object_Identity table 172 stores information for each unique domain object in the system. The ACL_Object_Identity table 172 may include columns for ID, a foreign key to the ACL_Class table 176, a unique identifier to identify the corresponding ACL_Class, a foreign key to the ACL_SID table 178 to represent the owner of the domain objet instance, and whether ACL entries are allowed to inherit from any parent ACL. Table 176 includes a record for every domain object for which ACL permissions are stored.
The ACL_Entry table 174 stores individual permissions assigned to each SID. Columns of the ACL_Entry table 174 may include a foreign key to the ACL_Object_Identity table 172, the SID (e.g., a foreign key to the ACL_SID table 178), whether auditing is permitted or not, and an integer bit mask that represents the actual permission being granted or denied. A row is provided in table 174 for each combination of SID and domain object whereas the SID receives a permission to work with that domain object.
Normally, due to the separation between domain objects of modern software systems and implementation of ACL frameworks such as Spring Security ACL, retrieval of a complete set of domain objects unfortunately and inefficiently is performed first to loading a list of objects in memory, before such objects then can be checked one-by-one against ACLs for permission attributes. In such systems, ACL_ENTRY records are queried and loaded one-by-one for the determination of permission in-memory. In the implementations disclosed herein, a single query may be used to identify domain objects of the desired permissions.
Referring still to
A join operation combines records from two or more tables in a database. A join operation combines fields from multiple tables using values common to each table. A join operation creates a data set that can be saved as table itself or used as is. Multiple types of join operations are possible. The example provided below uses an “inner join” operation. An inner join operation combines column values from multiple tables based upon a join-predicate. For example, performing an inner join on tables A and B entails comparing each row of table A with each row of table B to find all pairs of rows which satisfy the join-predicate. When the join-predicate is satisfied, column values for each matched pair of rows of tables A and B are combined into a result row.
The following illustrates an example of the application of method 200 to a database whose schema is reflected by the ERD 150 of
SELECT c.* FROM cloudResource c
INNER JOIN domainModel d ON c.domainModelId=d.id
INNER JOIN ACL_ENTRY n ON d.aclObjecIdentityId=n.aclObjectIdentityId
INNER JOIN role r ON n.aclSidId=r.aclSidId
WHERE r.id=18 AND (n.permission & 2=2)
The SELECT c.* FROM cloudResource c command selects all records from the Cloud Resource table 154. The Cloud Resource table is referred to by the letter “c.”
The first inner join command (INNER JOIN domainModel d ON c.domainModelId=d.id) performs an inner join operation on the Cloud Resource domain table 154 and the Domain-Model table 164 (referred to by the letter “d”). The join-predicate on which the first inner join is performed is the ID primary key field of the Domain-Model table 164. That is, the first inner join determines all records in the Cloud Resource table 154 that have a domainModelID foreign key that matches the ID primary key of a record in the Domain-Model table 164. The matching rows are found and placed in a resulting table referred to as the first joined table (220,
In the second join command above (INNER JOIN ACL_ENTRY n ON d.aclObjecIdentityId=n.aclObjectIdentityId), the result of the first join operation command above is then joined with the ACL_Entry table 174 based on a join-predicate of aclObjectIdentityId. This second join command finds each pair of records in the first joined table (resulting from the first join command) and in the ACL_Entry table 174 that have the same aclObjectIdentityId. Each such matching pair of records are joined together to produce a second joined table 222 (join operation 206 from
In the third join command above (INNER JOIN role r ON n.aclSidId=r.aclSidId), the result of the second join operation command is then joined with the Role table 158 based on a join-predicate of aclSidId. This third join command finds each pair of rows in the second joined table (resulting from the second join command) and in the Role table 158 that have the same aclSidId. Each such matching pair of rows are joined together to produce a third joined table 224 (join operation 208 from
The last command above (WHERE r.id=18 AND (n.permission & 2=2)) causes the third joined table to be filtered based on a filtering parameter that the Role is 18 and permission is 2. The Role number (18 in this example) is whichever particular role in which the user performing the search is interested. For example Role 18 may correspond to Accounting. Permission 2 also corresponds to whichever permission in which the user is interested (the read permission in this example). As a result, all cloud resource records are retrieved on which a specific role having ID 18 has a read permission.
The above discussion is meant to be illustrative of the principles and various embodiments of the present invention. Numerous variations and modifications will become apparent to those skilled in the art once the above disclosure is fully appreciated. It is intended that the following claims be interpreted to embrace all such variations and modifications.