Call cPanel API's to grant access to a remote MySQL user from Kotlin - mysql

I want to call cPanel API's to grant access for a remote MySQL user, from Kotlin.
It is for a Register User functionality.
Basically I want from my Kotlin code to call cPanel API's to:
create that user on a remote MySQL database hosted on a VPS
set a password for that user
grant access to the database from everywhere
How can I please do that? I read cPanel documentation but is not very clear, for example I have:
https://api.docs.cpanel.net/openapi/cpanel/operation/Mysql-create_user/
https://hostname.example.com:2083/cpsess##########/execute/Mysql/create_user?name=dbuser&password=12345luggage
But calling this API result in a NULL response because I don't know where to specify credentials to login to the cPanel himself.
A working code sample is greatly appreciated.
Many thankx!

Related

AWS Codestart Permissions to create a Project

I have an IAM account from my work organization. When I try to create a project in CodeStar, I get a permissions denied error.
Could somebody please let me know what all permissions should the account owner / root give to an IAM user / group so that they can create a project in CodeStar
I think this link helps
https://docs.aws.amazon.com/codestar/latest/userguide/setting-up.html
Configure Permissions for IAM Users Complete these steps to set up IAM
user permissions.
To perform this step, sign in to the IAM console as a root user, an
IAM administrator user in the account, or an IAM user or federated
user with the associated AdministratorAccess managed policy or
equivalent. Attach the AWSCodeStarFullAccess managed policy to the IAM
user that is used to create the project.

Azure MySQL Azure Active Directory Access Token

I got MySql Server on Azure and is configured with Azure Directory Admin.
Example
MySql Servername: mysqlserver and
MySql AD Admin Account: admin#organistionname.com.au (this organisation domain account)
Can see above account from MySql Server under User Accounts.
I stood-up Azure Web App for phpMyadmin and configured to pointed to above MySql db.
When an logging into phpMyAdmin with above Active Directory Admin Account is getting validated against AD, but getting error
mysqli::real_connect(): (HY000/9013): An error occurred while validating the access token. Please acquire a new token and retry.
I need to get a Ad token which need to passed to MySql server.
How to achieve this in Azure Web App?
This documentation should help you: https://learn.microsoft.com/en-gb/azure/mysql/howto-configure-sign-in-azure-ad-authentication#connecting-to-azure-database-for-mysql-using-azure-ad.
You need to acquire an access token in your code for your user against the resource: https://ossrdbms-aad.database.windows.net or against the scope (if using v2): https://ossrdbms-aad.database.windows.net/.default.
Acquiring access tokens with AAD is a whole another topic and the exact way depends on your app.
This answer might help for that: https://stackoverflow.com/a/33512913/1658906
I have the same set up (except phpmyadmin running in a container in AKS).
I believe phpmyadmin can't connect to mysql with azure ad enabled (at least with an AD user/group) because the token (password) is required to be sent in cleartext, and phpmyadmin hashes it before sending it.
I think that's why I get the An error occurred while validating the access token. Please acquire a new token and retry. error.
That's also why in the docs, they set the --enable-cleartext-plugin flag on their example mysql cli commands.
Also in the docs, they state that it's only tested with myqsl cli and mysqladmin.
I'm currently planning on ditching phpmyadmin for azure bastion and a VM running mysqlworkbench for this reason.

Flask MySQL hosted database connection: Access denied for user

EDIT
I managed to resolve the issue. I needed to add my home IP address to the list of "Allowable Hosts" on my site's management portal. I can now connect to my remote database with my app locally.
I have a flask app that can connect to a hosted database and I wanted to start managing the code through a git repository. I have the application working locally, however the app can no longer connect to the hosted database. I'm sure the issue has something to do with my router, but the specific error I get is:
OperationalError: (1045, "Access denied for user 'username'#'ip-address-of-my-router' (using password: YES)")
The host address I pass in is mysql.mywebsite.com, however when my app attempts to establish a connection, it's trying to connect to ip-address-of-my-router instead of my hosted database.
Does anyone know what I need to do to prevent this swap from occurring? Temporarily I can create a local database and populate it with sample data, but I'd really like to be able to connect to the actual database while developing the app instead of working with sample data.
I added a comment to my post, but if you end up down here:
I managed to resolve the issue. I needed to add my home IP address to the list of "Allowable Hosts" on my site's management portal. I can now connect to my remote database with my app locally.

Using mysql database table authenticated multiple site user / SSO

I have implement SOS concept between two php application. it application it available different domain.
I have required following condition.
1.When user is login any appplication to login this user with check user name and password into mysql database table
2.When user is login another application not reenter password direct login with this system.
3.When user logout at time both application can be logout.
-->my first application can be created Yii framework and another is moodle
please give idea to implement this concept in my both application
You can use external database authentication for Moodle -
https://docs.moodle.org/27/en/External_database_authentication
Log into Moodle as an admin then go to site admin -> plugins -> authentication -> manage authentication.
Enable the "external database plugin" and then update the settings to use the external database and map the fields for username, password, email etc.

JustHost Cpanel - MySQL username/password access remotely

Not sure if this is the right forum for me to ask this question.
But I'm wondering does anyone having difficult using JustHost as web hosting provider in establishing remote access to their mysql database server environment?
What happened recently was that I'm trying to use mySQL ODBC driver connector via MS access to access their mysql database.
Originally I know what my username/password is and JustHost(well.. at least that's what I think they normally do) is set this similar setup for all other CPanel access such as your FTP, email, billing info, etc, etc.
Thus I tried using my username/password to logon into the mysql database via MS ACCESS's odbc connector. But I kept on being rejected to log in.
I started whether the password I used to log on my CPanel services would be different that the one used to access mysql via PHPAdmin window. Thus with that in mind, I forwarded the query to Justhost helpdeskteam.
Unfortunately they don't have a clue about this.
Thus that's what brought me here in this forum, begging this question - does anybody know what's the appropriate approach in remotely connecting mysql database environment via a web hosting provider such as Justhost.com?
Sorry for the elongated story.
Thought it would help to state the meaningfulness of my supposedly-trivial problem.
Log in to your JustHost account and scroll down to Remote MySQL. You need to add the IP address(es) of the remote server(s) to the list of Access Hosts.