XDIR is acomprehensive user management system (registration, deactivation, and editing; credential recovery). This system also allows for the association of roles and organizations, as well as services within the XIMDEX Platform.
This document provides a step-by-step guide to setting up the development environment for the User and Role management and registration backend, xdir
. Follow the instructions carefully to ensure the proper configuration of the project.
PHP8.2
Before starting, make sure you have Git and Composer installed on your system. These tools are essential to clone the repository and manage the PHP dependencies of the project.
To get the project source code, run the following command in your terminal:
git clone git@github.com:XIMDEX/xdir.git
This command clones the repository into a new folder named xdir in your current directory.
Then, you need to run cd xdir
to access the directory.
To work with the latest development version, switch to the develop branch:
git checkout develop
composer install
This command reads the composer.json file, downloads the required dependencies, and installs them into the vendor directory.
Copy the .env.example file to create your .env
cp .env.example .env
And configure the environment variables, especially the database ones. For all these new settings to be loaded, you need to run the following command:
php artisan optimize
Then, we can verify the routes to make sure everything is correct:
php artisan route:list
You need to run the migration:
php artisan migrate
Now, test the /register route. You can use the following data:
{
"email": "testXdir@mydomain.com",
"password": "Test12345",
"name": "test",
"surname": "text for surname",
"birthdate": "2020-10-10"
}
In the response, you will receive a token that will allow you not to have to register a real email (Remember to have the app in debug mode, in the env, to get this response).
php artisan key:generate
You also need to generate the keys for passport
php artisan passport:keys
And ensure they have the correct permissions:
sudo chown www-data:www-data storage/oauth-public.key storage/oauth-private.key
We would need to generate the key:
php artisan passport:client --personal.
In the end, you will receive two variables that must be stored in the .env file along with the assigned name:
PASSPORT_PERSONAL_ACCESS_CLIENT_ID="your_client_id"
PASSPORT_SECRET="your_client_secret"
PASSPORT_TOKEN_NAME="client_name"
And finish with a php artisan optimize.
Verify the email: To simulate email verification, access the /email/verify/{token} route, where {token} is the verification token you previously obtained.
Test login: Once the email is verified, you can proceed to test login through the /login route using tools like Postman or cURL, providing the user credentials (email and password).