Can two laravel app use thesame database? - mysql

I have two laravel projects with setup as follows:
App1 - Web application portal
NB: Currently on a remote server
Allow students to submit applications and check the status of their applications online. Tables include (users, students, applications, documents, comments, faqs, answers)
App2 - Corp App
NB: On our local server
Allow to evaluate applications submitted via App1, view reports, manage selected applications, generate letters,
etc. Tables include (users, students, applications, documents, interns, attestations, supervisors, messages, etc). App2 do not share login information with App1. It mainly contains login info of corp employees while App1 only contain login info of students and site administrator. Tables common between the two dbs are students, applications, documents and via master-master replication we are able to get all applications submitted to App1 on the remote server and on App2 we can update the status of the applications which is sync back to App1 DB. Now we want both applications and db to be on thesame server and so for replication to work , that would mean installing two instances of mysql with each database on a separate instance. Would it be better to just include all the tables of the website - App1 (comments, faqs, answers, etc) on App2 DB and make both applications now use one database?

I think it would be the easiest solution with one database.
here is a link on how to use laravel and lumen together:
http://blog.enge.me/post/building-api-your-laravel-application-lumen
not excactly the same, but i think the principles can be reused for your project.
BTW, doesn't laravel 5.2 support user roles out-of-the-box?
When i think about it, you can actually do it with 2 user tables and 2 user models, each with its own login controller/middleware. Then you point the students to domain.com/student/login and the employees to domain.com/employee/login.

Related

User storage in ejabberd

I am trying to setup ejabberd as IM solution for my project, which will be mobile app + backend. I am using SQL auth (and SQL store for all modules also), using MSSQL via ODBC. I have some questions I didnt find answered in docs.
Do I understand correctly, that ejabberd is multi-tenant (since it can support multiple domains). If so, how are users assigned to particular tenant (domain)? In users table in DB, there is only username (without domain part). Can I have two different users john#jabber.myproject.com and john#jabber.myotherproject.net ?
I want to create XMPP accounts on ejabberd automatically (user doesnt need to know anything about underlaying service) - do I need to register users via API, or can I insert rows directly into DB table users and ejabberd will be OK with it?
In users table in DB, there is only username (without domain part). Can I have two different users john#jabber.myproject.com and john#jabber.myotherproject.net ?
Create a new database for each vhost, and use the host_config option in ejabberd.yml to tell which database to use for each vhost:
https://docs.ejabberd.im/admin/configuration/#database-and-ldap-configuration
Or you can enable the new SQL schema, see https://blog.process-one.net/ejabberd-18-03/
do I need to register users via API, or can I insert rows directly into DB table users and ejabberd will be OK with it?
Both are acceptable. In the second case, there are chances that some task performed at account registration is missing in your server, but I don't remember any module that performs any task at account registration. So, it looks OK.

multi tenancy structure with node and sequelize

I'm planning a multi tenancy app with nodejs and sequelize(mysql dialect). I'm gonna have a single app and multiple databases for each client. I'd need to connect to a client database after authentication (with passport.js). So there is a classic master database with clients info and db user,host and pwd, and then after the successful login the app connects to the specific client db. How could i do something like this? I was thinking to use sessions...maybe a middleware that for each request fetch the session and then passes the data to sequelize config object? Could anyone share with me how he/she manage to do something similar? I'm stuck in a logical trap ! Thank you
You're very close.
When you look up the user in your master db, in order to validate the username/password, you will also look up the connection string to the user-specific database. Then youu can create a simple express middleware function to open up the specific connection at the beginning of each request.
You will need usernames and passwords for the databases. For best security, they should not be the same as the users' usernames and passwords: If somebody cracks your web app and user table, you don't want them to have all the passwords.
But, what you propose is not classic multitenancy. Multitenancy is creating a single database, in which the various tables have columns mentioning which user they are for. Then once passport tells you the user's id, you can put it into your queries (for example, SELECT .... WHERE user_id = <<value>> AND ....
Your proposal will work tolerably well for a few dozen users. But what happens if you get tens of thousands of users? That will be a lot of separate databases.

How to use woocommerce with an API instead Wordpress DB

I like the features of Woocommerce and the extensibility that you won with this plugin. I saw that Woocommerce actually has a REST API, but is there another way to make the things more seamlessly and simple. I would like to have these features but with the data of my API or Backend-Database, not the other way, because actually others Apps consume my current API.
This is an overview of the architecture of my app (I exclude other stuff like Load Balancers, cache servers, CDN, etc... for making things simple).
SERVER ONE (front-end -- public ip)
E-commerce Website (Wordpress with Woocommerce)
SERVER TWO (front-end DB -- private ip)
MySQL Database for SERVER ONE
SERVER THREE (Back-end -- private ip)
E-commerce App (Rails)
SERVER FOUR (Back-end -- private ip)
Oracle Database for SERVER THREE
SERVER FIVE (Back-end -- private ip)
API based on SERVER THREE E-commerce App
So, in general, I would like to know if there is a way to still use Woocommerce in my E-commerce Wordpress site either with the API of SERVER FIVE or a direct access to the Oracle Database of SERVER FOUR.
We have integrated Woocommerce and Oracle. We don't use rest or the api, we talk directly from Oracle to the Woocommerce MySQL database. We have setup an Oracle database link using ODBC to the MySQL database and we read and write from Oracle to MySQL. We also have customised Woocommerce and talk directly from Woo to Oracle. As Woo is PHP there is no problem connecting to the Oracle database.
So for example we create(register) clients records from Oracle in WooCommerce and we pull orders out of Woocommerce and process them in Oracle with the ERP system.
Google database links Oracle and MySQL on how to set it up. One other hint, you will need the "SQLPASSTHROUGH" call if you need to do sql statements which require for example a mysql function. You also need to be aware that object names can be only a maximum of 29 characters in Oracle. So if you access a table in MySQL which has a long name you need to define a view with a shorter name for that table.

Is it possible to integrated RSA Archer with multiple Active directory?

Is it possible to integrated RSA Archer with multiple Active directory ?
Everything is possible, it just a matter how much effort you are willing to apply :)
Option 1 (recommended): RSA Archer v5.x support multiple LDAP sync configurations. So you can have more than one AD server you can sync users against.
Side Effects: [a] If AD1 and AD2 both have user with the same name, then you will have two users created in Archer in different domains. With manual login users will need to supply different domains.[b] Not sure how it will work with SingleSignOn enabled. I think that SSO will work only for the primary domain, but I'm not sure - you may want to test this.
Option 2 (AD work around): I have little knowledge of Active Directory technology, but I believe that you can establish trust relationships between multiple AD's in a such a way that some group from AD2 can reside within another group in AD1 (and they will autosync as well). This way you can sync only against one AD with Archer, but have users from both AD's.
Option 3 (database back end work around): In the database you can find tables where the LDAP configuration, users, and users to groups mapping is stored. You can introduce a trigger that will make a copy of users table and usergroup tables after each LDAP sync. So after you run two LDAP syncs, you will have two back up copies. Then with your SQL trigger you can merge them and override the original table. With this approach you can sync users within same "archer domain" against multiple LDAP sources.
Side Effects:[a] You have to write and maintain custom SQL code.
[b] Users can expect not to have proper access to the environment until all of your LDAP syncs are executed one by one and processed by the triggered code.
Good luck!

Should I use multiple databases in this situation (Ruby on Rails)

Through my companies website, our users can make artwork requests. Currently they are just being emailed to a single person.
I have been developing a separate application we'll call it "artwork manager", that will queue these artwork requests for our in house artists, and they will be passed out accordingly.
Our company website database contains the art_request table that this other application needs access to.
The "artwork manager" application only has an artists, art_doc, and awards, tables.
Should I just add these tables to our company website, and connect to that database? Or would it be best to use a separate database for each application? They are both being hosted on the same server.
Don't separate your databases, it will create a lot of confusion on development later. I strongly suggest merge it to one application.