We are using Java + H2 Database in server mode, because we do not want users from accessing database file.
All database users created by admin are regular users (not admin). Is there any other possibilities for those regular users to get the database content? I have tried SCRIPT and BACKUP command, and failed because they require admin privilege. That's nice :)
Is making users not admin is enough to protect users from dumping database content?
More, is making application user = database user, a good security practise? Previously, for authentication, we use custom 'users' table in the database, not the database user.
Thank you.
Is there any other possibilities for those regular users to get the database content?
No. That's the point of database users and rights, so that a user can only access the data he is allowed to.
Is making users not admin is enough to protect users from dumping database content?
Yes.
is making application user = database user, a good security practise?
Yes, if the client application has access to the database (over TCP/IP).
Previously, for authentication, we use custom 'users' table in the database, not the database user.
This is a common solution for web applications and other 3-tier systems (where the user doesn't have access to the database).
Related
I have a central SQL server which can be INSERTED INTO and SELECTED from via PHP. However I have built a Java application which I hope to be able to Insert and select stuff in the SQL table with that I have hosted on a web server.
How would I go about doing this? I don't really want to have the root password with JDBC in the source code as even if it is obfuscating it can easily be deobfuscated and then the user has direct access to the database.
Someone said to me that I should use an API but I don't see how I will be able to interact with the database by doing this.
If you already have a PHP application running server side that handles database interaction; I recommend letting that handle if for you.
Write an API in PHP that handles all of the database interactions and send requests to that API from your java application. (I'd probably have the users create an authorization token to pass along to the API as well so you can track who is using your API and limit access).
Your application can then send HTTP(s) POST/GET/etc requests to your PHP that will then handle the database interactions and return the results. Your database username and password will be kept on your server and your application will not need to know them.
If you don't want to rely on a backend service and want your client application to interact directly with the database... You'll probably have to include a username and password in the code. BUT I'd create a separate user in the database with limited accessibility that could be removed anytime you suspect abuse.
I'm very new at programming. I want to make an app where,
1. User1 will make an order (log in as user_profile_1)
2. User2 will work with that order (log in as user_profile_2)
One user shouldn't have access to other's data.
Will SQLite allow me to do that? Seems, database must not run on user's device. And database will always get new records, so we need to update it all the time.
For this case, you have to create a server to store data, I think you should do these things:
Use PHP, NodeJS or some languages server like this to create APIs.
Use a MySQL database or some other database to store data on your server.
Then, different users can log in on their device and you will call your APIs to show what you want.
If you use a SQLite database, the db will be local in the device. The records in the database do not share with other devices.
If you want to access the database from different devices the database will need to exist in a remote server.
You can do differents things:
You can use a database MySql in a remote server with allowed remote access.
You can create a rest api in a LAMP server. You can do this for example with PHP and MySql. You create a GET/POST web page, them pass the data, and the php save the information in the database. You can get the information from the database in the same way, but you should ask to the db in a periodicly time
I am working on an application where users go on and offline. I want the data entered by users to be synced with central db.
The application is in Swing and using web services to update data in central DB.
I am thinking SQLite as a solution but I am concerned about security. The concern in each client system will have more than one user and every user will have his specific data.
Does SQLite support this?
Are there any other alternatives for SQLite in this scenario?
I have Oracle 10g as my Central DB. The role of SQLite is a local DB that stores data till user goes online
EDIT:: I am here concerned about the security of SQLite file. Through my initial analysis I found there are no features like authentication while accessing sqlite file.
Hope I am clear now.
SQLite does not support per-user authentication (you can use a password, but it's the same for the whole database file). Per-user authentication wouldn't be efficient anyway, because a user who has read-access to the database file could just read the file directly. You could encrypt the data, but you would have to store the decryption key and algorithm in the executable, where the user can access it.
When you want to protect the local data of each user, I would thus recommend to delegate this responsibility to the operating system. Just store an individual database file for each user in the private user directory of the current user (%appdata% on windows, ~/ on unix). As long as users do not have admin/root rights, the operating system should prevent them from accessing data in each others user directories.
This, of course, only works when each user of your application also has an individual account on the operating system. When that's not the case, you could still use individual databases for each user stored in a public location, but encrypt each database file with a key which is derived from the password of each user.
I made a java program in which users would be automatically inserted/selected lines into/from one mysql database, but could not modify any existing lines, tables, db, or privilages. I got myself a website and hosted it in 1and1.com, but sadly I found out that its a pain(impossible) to have multiple users for one database and to remotly connect to a database.
I was wondering what are my options here?
I suppose the first one would be to get another host that allows me to do this.
The only other option I can think of is that somehow I manage to send from java the information to my website, and then the website to connect to the database. (not an expert in php, html, or what ever i ahve to do (be by embbedding a browser on my GUI or by doing it under the hood).
This is my first attempt to create a program that connects to an online database, so please be nice.
Note: program worked in localhost.
1&1 support useless.
Almost all (web)applications that use a database, connect to the database with one database user for the whole application. Having a different database user for each user of the application is an uncommon design.
So, you should configure one database user, which the application uses to read from or write to the database; this database user is independent of the users of your application and is shared by all users of your application. There should not be a one-to-one mapping from application users to database users.
There are different reasons for this. One of them is scalability. Most databases cannot handle thousands of connections at the same time. If you have a web app that allows thousands of concurrent users, you don't want to have a database connection with a unique username for each of those users. Instead you want to use a connection pool with a limited number of database connections; the connections in the pool are reused whenever one of the web app users needs to perform an action that accesses the database.
i am writing an application in java and i want to enable it to access a mysql remote server.
my problem is that if the application have the user name and password someone can take them and use my db with a different software.
is there a way of preventing it ?
UPDATE
i found this workaround for connecting to a remote MySQL database from an android device.
you put a service in the middle. like a php page that code the data in JSON format which the android app gets via http.
here is the example i found :
Connecting to MySQL database
Having the username and password is designed specifically to grant access to the database. That's the whole point.
You could go to some extra lengths like restricting database connectivity to specific hosts, so at least your paying customers get access to the database and no else can access it, but your customers might choose to use different software to access the database. There's no way around it except licensing terms.
What you could do is run an intermediary program on your own hardware that connects to the database and restrict access to the database to software that is under your direct administrative control. Your program would validate all requests from software under control of your customers and allow the queries that you want to allow and refuse (and log) the queries you do not have to allow. (You do not need to send raw SQL data back and forth -- you can do any amount of processing on the data and queries.)
You can setup JDBC Data Source on your application server. Here you can see example for Oracle Glassfish.
So, your credential won't be used in your code/resources.
If you are saying that you have an application trying to access a MySQL remotely (not in the same box), then i think you need not worry, as the connection that will be established by your application codes will not expose the username and password when it is trying to authenticate and authorize itself to the MySQL server.
You can limit the access to the MySQL-server so that only certain IP-addresses or IP-ranges have access to it.
As a side note, make sure that the user you use in your application only has the needed permissions to the database. For example, the user might not need to be able to create or delete tables. You can even specify permissions for the user on table and column level.