473,386 Members | 1,860 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

PHP, MySQL & Limiting Access

Greetings, all!

I have a project for work, and I'm not sure how to efficiently do what I
need to do. I'm hoping someone out there can help.

Project is this: I'm creating a web-based interface where people at my
company (operators) can enter data for service calls. All data entered
is run thru one or more PHP scripts for error checking and then stored
in a MySQL database on a server here in the office.

What I'm looking to do is to limit access to certain operators so they
can only do certain functions (ex: add a service call, but not delete
one), whereas admins such as myself would have full access to
everything. Ideally, at some point in the future, we plan to roll this
interface out to our clients so they may do the same features within
their company. Obviously, they would only gain access to data related
to their company, as to protect the privacy of others.

Hierarchy would be something like this:

1. UberAdmins (such as myself)
-Have access to everything and to all commands.

2. Operators
-Have access to everything, but not all commands.

3. Our clients
-Have access to their data only, and to all commands.

4. Our clients' operators
-Have access to their data only, but not all commands.

The difficult thing is that our clients may run several businesses, so
they would have to have access to several groups. In essence, they'd
have multiple groups (their businesses) within a group (their group)
within a group (everything).

What is the easiest and most secure way to do something like this? I'm
not looking for actual code but merely suggestions. Please reply if
there is something I wasn't clear on.

TIA,
-Jay

Jul 17 '05 #1
2 3252
Jay Moore wrote:
Greetings, all!

I have a project for work, and I'm not sure how to efficiently do what I
need to do. I'm hoping someone out there can help.

Project is this: I'm creating a web-based interface where people at my
company (operators) can enter data for service calls. All data entered
is run thru one or more PHP scripts for error checking and then stored
in a MySQL database on a server here in the office.

What I'm looking to do is to limit access to certain operators so they
can only do certain functions (ex: add a service call, but not delete
one), whereas admins such as myself would have full access to
everything. Ideally, at some point in the future, we plan to roll this
interface out to our clients so they may do the same features within
their company. Obviously, they would only gain access to data related
to their company, as to protect the privacy of others.

Hierarchy would be something like this:

1. UberAdmins (such as myself)
-Have access to everything and to all commands.

2. Operators
-Have access to everything, but not all commands.

3. Our clients
-Have access to their data only, and to all commands.

4. Our clients' operators
-Have access to their data only, but not all commands.

The difficult thing is that our clients may run several businesses, so
they would have to have access to several groups. In essence, they'd
have multiple groups (their businesses) within a group (their group)
within a group (everything).

What is the easiest and most secure way to do something like this? I'm
not looking for actual code but merely suggestions. Please reply if
there is something I wasn't clear on.

TIA,
-Jay


Hi Jay,

Try not to reinvent the wheel when designing user permissions. The most
simple to understand (and, IMO, most useful/powerful) permission scheme
is that used on UNIX-like operating systems. Since you said you will
have "groups" of users, this seems like the most logical thing to do.
Make each resource (viewing data, operating on data, etc) have its own
permission set associated with it. Then assign an owner user and an
owner group to each thing. (This can all be done in your database.)
For instance, you only want administrators to be able to delete a
service entry, so make the service entry "writable" by the admin group
and an admin member user.

I used a similar system for a community managed bulletin board (many
tiers of users and groups with all kinds of different permissions) and
it worked out really well.

As an example, each user (in a user table, I'm assuming) would need this
information stored:

username, member group, [attached groups]

Then, keep a list of permissions for each database function/resource:

user permission, group permission, world permission,
user owner, group owner

If you use a little relational database design, this will allow you to
link together users/groups with resources in nearly any conceivable way.

I would suggest doing the standard "read-write-execute" bits. Even
though you probably won't use the "execute" permission on a typical
database design, it keeps you sane if you're used to working with UNIX
and it's only 3 bits of extra data. There's even a nice MySQL data type
that makes life easy:

create table some_table (
id int not null auto_increment primary key,
user_perm set('execute','write','read') not null default 'read',
group_perm set('execute','write','read') default 0,
world_perm set('execute','write','read') default 0
);

Then, get a user permission:

select user_perm+0 from some_table where id = 35;

This will return a decimal representation of the bit field (the "+0"
casts it to an integer type on return). So, if you have set 'read' and
'write' permissions for user 35, you will get a "6" returned from the
query since the bitfield is "110" (backwards from how thery are listed
since the low-order bits come first).

If you only make your permission sets three elements long, you will
always get the same numbers you would see in a UNIX filesystem. Running
a change of permission on a resource, could look like the same thing as
running "chmod" in a shell.

I would do some looking around in the manual of your DBMS to see how
sets work before diving into this scheme. If you're interested in
learning about the secure filesystem in UNIX, check the man pages (I
would start with `man chmod`).

HTH,
Zac

Jul 17 '05 #2
<snip Zac's reply>

Zac,

Thanks for the prompt reply. I appreciate the help. I had actually
kinda considered doing what you suggested, only I didn't know how to
actually DO it.

My next question would be, "How would I 'label' the data being entered
so it's associated with the proper user/group?"

I'm looking to keep the layout like so:

Admins
|
+- Operators
|
+- Our clients
|
+- Our clients' operators (1)
|
+- Our clients' operators (2)

and so forth.

I hope I'm making sense. ;)

-Jay

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Steve Farber | last post by:
I'm not especially new to databases and I have used ODBC before with other data sources, but I cannot seem to get Access 2003 to talk to MySQL 4.0.15. I have MySQL running with new tables...
4
by: MLH | last post by:
A programmer developed an AMP (Apache/MySQL/PHP) application for me. When he was done, he sent me the PHP files and the MySQL dump file. Now, when I connect to the application on my LAN using...
13
by: wideangle | last post by:
Hello there! I know it's stupid, but when creating a table in a mysql (win32) database, it won't let me create this "mytable". Here goes my ER_PARSE_ERROR. mysql> CREATE TABLE `mytable` ( ->...
0
by: bettina | last post by:
I had an Access database and I had always used in my tables (whenever possible) pop up lists to choose elements.. for example, for a column I've wrote in "Datensatzherkunft" SELECT tbl.field1 FROM...
3
by: Steven Sinfield | last post by:
Hi All, I am trying to use PHP & MySQL over SSL, my issue is that the data that I am querying also needs to be available by non-secure as well. Can someone please help me in doing this. ...
0
by: MLH | last post by:
Is an apostrophe a character of special significance to MySQL in a way that would cause "Bob's dog" to become translated into a 12-character string when typed into a MySQL memo field? If I type...
1
by: gordon.dtr | last post by:
Hi, Has anyone had this problem ? I am using MySQL ODBC 3.51 Driver, with MS Access 2003 and MySQL 4.1.11 standard log. I created my tables in MS Access, then exported them via ODBC to an...
15
by: harvey | last post by:
How do I make PHP create a database for mysql please? I can see how to make tables and I have read all the documents I can find but I don't understand how to make the database itself. All...
4
omerbutt
by: omerbutt | last post by:
hi every one I am A new Bee to php mysql and i was surfing through the net to learn about how to secure the mysql when you are working in a web environment while working with php html and javascript...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.