Cross-product web authentication systems - php

I'm about to start a human resources web app system. My idea is to have the manager system and the website work with the same database, but make three or more "products" running with the same data. All in PHP and JavaScript.
My question is how can I get an authentication system like Zoho or Google, with one account for all services, and how can i store this. In a single table? LDAP? Which one?

If they're all on the same domain, then why treat them as one app? Either have a single auth table in your db or use a seperate db called by all three apps.
As for the actual auth system, there are many ways - the one you choose will depend upon your individual requirements.
If you plan on extending the apps provided, it might be worth looking at setting up an OpenID provider for your domain and/or allowing logins from other OpenID providers (like StackOverflow does).

I would look around for "PHP Authentication frameworks"
Login Sessions might be something to checkout.
I've rolled my own code for this in the past. Creating a schema for platform objects and defining permissions for what user/group can access what applications. Below is a simple schema for this type of thing.
Table Users
UserID
...
Table Applications
ApplicationID
...
Table Permissions
PermissionID
...
Table UserApplications
UserApplicationID
UserID
ApplicationID
PermissionID
...

Related

Implement multiple databases using table prefixes in codeigniter

I have built a hosted point of sale system where you can create an account for your own store and manage your own users, etc.
To do this, I have implemented multiple databases, one 'master' to keep track of store owners and one for each of their stores.
The problem is, the hosting provided by the client who commissioned this does not allow creation of multiple databases through PHP. I figured using table prefixes will solve this. How do I go about implementing prefixes for each store's tables in Codeigniter? I would like to avoid 'hacking' the core of the framework, if possible.

CakePHP - How to setup multiple apps/portals that use same functionalities

We are building a intranet web application in PHP with CakePHP.
However we have barely experience with CakePHP
Our Intranet will have two user portals.
Employee portal
Client portal
Both portals will use the same data but have their own user interface.
Employees can see other data than clients and vice versa.
We want to build a central core for both portals. For example, a single authentication system, a contact form, a notification functionality, same footer information, etc. We want to use this central core as much as possible so we don't have to rewrite code.
We use Git to manage our code. We want to make a branch for both portals and one for the shared core.
We hope you can give us some advise about how setting this up with CakePHP.
Is building multiple app's a good idea?
Or should we just run CakePHP and our core on two web servers? (one for each portal)
Or should we use plug-ins for the core functionalities?
Or should we use single controllers with multiple views (one for employee and one for client?)
Or something totally different?
Thanks for any advice
Eventually, you'll start noticing similarities between the 2 portals, and the code-base. If they are sharing same data, why don't you have a single code-base and have permissions around what users can see based on roles? We had to do this recently when we merged 3 pages into 1. 1 page was for admin, and the other 2 was for other roles. Then users started requesting features on page 2 that page 1 already has etc etc. it became a mess and we decided to consolidate these pages into 1, and have permissions around what each users can see based on their roles. Also read more about helpers as it will come handy, so you dont make your view bloated.
In my experience a portal is typically a very thin layer on top of some CRUD framework. I think the opportunity for code sharing between these two applications is very limited. You can share the authorization and authentication .. and that's about it and I don't know if sharing this part is a good idea (probably not).
If most of your code goes into building the HTML views you'll likely end up with two completely separate views for employee and client.
As Ayo mentioned... the permissions alone will separate the two user groups and you can take advantage of CakePHP's layout or the themes feature to give a totally two different look for each user group.
You may also want to take a look at CakePHP plugins feature. It allows you to easily add new functionalists to an existing app, without messing with the existing code base.

how to implement multiple user cms?

I would like to implement a multiple user CMS website, where each user is able to execute CRUD actions on their own records. This means that security should be implemented on record-level, not on model-level.
I've come up with 2 solutions:
Have an owner_id field in each model.
Have a database per user for the models that they modify. Keep a main database for all the related records (such as users' data (name, email, username, password), models that are edited by admins, but not users, etc).
Solution 2, I was thinking of implementing with Apache's help. I would have http://user3_website.mydomain.com/ for user3, for example, where this would be a separate website to the main website at www.mydomain.com . I would symlink all the directories apart from /web/uploads and /config:
/config - I would need for the database configuration for user3
/web/uploads - I would use for their uploads.
Is there a best practice/design pattern to implement this with Symfony? I have never developed a website that can dynamically select a database based on the user (solution 2), so am wondering if this makes sense.
I have experience with Symfony 1.x , but haven't done any development on Symfony2 yet.
I would go with solution 1, have one database for all instances with an owner_id field. It's easier to maintain that way. At some point you may have to make changes to the database and having to do that on multiple databases can become a nightmare unless you automate that somehow.
There's hardly any advantage in doing it in separate databases unless you have some serious security issues to consider.

Moodle-Mahara Integration Automaticall Creating groups & assigning users to groups in Mahara

I have a functional integrated system of Moodle (2.2) and Mahara (1.4) connected with mnet.
I was wondering if below are possible:
If a course is created in Moodle, can a group be created in Mahara automatically with the same course name. (As mentioned in the road map of Mahara).
https://wiki.mahara.org/index.php/Roadmap
If a user enrolls in a course in Moodle can the user be assigned to a group automatically.
If a user completes a course in Moodle, can a protfolio on Mahara be populated automatically.
Do I need to use webservices to do the above?
This is not yet possible and might be a bit of a headache to implement with webservices. Given that you control both systems, a far simpler solution would be to write a custom script that would run via cron and read/write directly to the databases. We are not yet able to do the above, but are planning to write some code that will do so, possibly open sourcing it later.

Are there any PHP Frameworks (e.g. CodeIgniter) that support database connections on a per user account basis for use in a Multi-tenant database?

I'm looking into developing a multi-tenant SaaS application, and I found several sites that describe a solid way to separate the data using tenantIDs and updateable views. e.g. This blog post
It all hinges on the ability to have your user accounts authenticated from a master users table and then having their respective database connections use those user-specific credentials. This way, the views can pull the userid and map it to the tenantID to display that user's view. However, most PHP frameworks tend to be very static when it comes to database connections (stored in text config files). They appear to be at odds.
Does anyone know:
a) how to make CodeIgniter handle this gracefully?
b) a different PHP framework that might?
At a horrendously basic level you can do this:
http://philsturgeon.co.uk/blog/2009/06/How-to-Multi-site-CodeIgniter-Set-up
Expand it as required, or move the logic into MY_Controller for more flexibility.
There is a topic talking about this on the Code Igniter forums.
http://codeigniter.com/forums/viewthread/165227/#846845
It looks like you set up your users DB as your main database in the config file, then you generate a config array for a new connection for a user based upon information in that users DB. So, I guess you'd need to at least store the DB name in the users database.
Not sure how well this works though, as I haven't had an occasion to try it out yet.
Sorry if that's not quite what you were looking for, but it should give you an idea of a Code Igniter approach.
Zend Framework.
http://framework.zend.com/manual/en/learning.multiuser.intro.html

Categories