|
| 1 | +.. _run-application: |
| 2 | + |
| 3 | +How to Run the Application |
| 4 | +=========================== |
| 5 | + |
| 6 | +This section provides an example of how to run the Federated Code application. |
| 7 | + |
| 8 | + |
| 9 | +Step 1: Create a Superuser |
| 10 | +--------------------------- |
| 11 | +Run the following command to create a superuser: |
| 12 | + |
| 13 | +.. code-block:: bash |
| 14 | +
|
| 15 | + python manage.py createsuperuser |
| 16 | +
|
| 17 | +
|
| 18 | +Step 2: Create a Service Account |
| 19 | +--------------------------------- |
| 20 | +Only superusers can create a Service account (e.g., VCIO or SCIO). |
| 21 | + |
| 22 | +1. Access the Django admin panel. |
| 23 | +http://127.0.0.1:8000/admin/ |
| 24 | + |
| 25 | +2. Create a new user through the admin interface. |
| 26 | +http://127.0.0.1:8000/admin/auth/user/add/ |
| 27 | + |
| 28 | +3. Assign the newly created user as a Service account. |
| 29 | +http://127.0.0.1:8000/admin/fedcode/service/ |
| 30 | + |
| 31 | + |
| 32 | +Step 3: Service Login and Git Repository Creation |
| 33 | +-------------------------------------------------- |
| 34 | +Now you have a Service login ex `VCIO` use this credential to create a Git Repository |
| 35 | +https://github.com/aboutcode-org/vulnerablecode-data |
| 36 | + |
| 37 | +Visit http://127.0.0.1:8000/create-repo |
| 38 | + |
| 39 | +Step 4: |
| 40 | +-------- |
| 41 | +To initiate a sync of the master branch, you can either click on the sync request |
| 42 | +button in the app or send an HTTP request directly to the endpoint using the auth service. |
| 43 | +The endpoint is: `repository/<uuid:repository_id>/sync-repo/` |
| 44 | + |
| 45 | +Visit http://127.0.0.1:8000/repo-list. |
| 46 | + |
| 47 | + |
| 48 | +Alternatively, you can integrate this action with GitHub Actions or any other |
| 49 | +CI tool to trigger the sync automatically whenever new data is pushed to the |
| 50 | +master branch. |
| 51 | + |
| 52 | +Here’s an example of how to send the request manually using curl: |
| 53 | +ex: |
| 54 | + |
| 55 | +.. code-block:: bash |
| 56 | +
|
| 57 | + curl -v -X POST \ |
| 58 | + -H "Authorization: Token your-auth-token" \ |
| 59 | + http://127.0.0.1:8000/repository/<uuid:repository_id>/sync-repo/ |
| 60 | +
|
| 61 | +
|
| 62 | +**Note:** You can retrieve the service token after authenticating via the endpoint |
| 63 | +`api/v0/users/@<str:username>`. |
| 64 | + |
| 65 | +Step 5: |
| 66 | +-------- |
| 67 | +The admin should regularly run the following commands, either manually or in a loop: |
| 68 | + |
| 69 | +.. code-block:: bash |
| 70 | +
|
| 71 | + python manage.py sync && python manage.py federate |
| 72 | +
|
| 73 | +Users can now log in or sign up, create and review metadata, and vote for packages. |
| 74 | + |
| 75 | +Happy Federation, everyone! |
0 commit comments