Skip to content

Commit

Permalink
Add About page, Integration via API page (#156)
Browse files Browse the repository at this point in the history
* Improve About

* Add API

* Add links to API and links
  • Loading branch information
jmartinkova authored Aug 1, 2024
1 parent b60957b commit ba9fd18
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 2 deletions.
15 changes: 15 additions & 0 deletions docs/application/profile/about.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.. _about:

About
*****

By selecting the :guilabel:`About` option from the :doc:`./index` menu, users are directed to the About page. This page offers detailed information about the current versions and build timestamps of the tool's components. This level of transparency helps ensure that both users and developers are fully informed about the specific versions and build statuses of the components they are working with.

The :guilabel:`API URL` link provides access to the server's API endpoints, which can be used for integrating the Data Stewardship Wizard with other systems and automating tasks.

The :guilabel:`API Documentation` link directs to the API documentation presented in Swagger UI that provides detailed descriptions of available operations and parameters.

.. figure:: about/modal.png
:width: 500

Modal window with versions of the tool's components.
Binary file added docs/application/profile/about/modal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/application/profile/index.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. _profile:

Profile
*******

Expand All @@ -24,4 +26,5 @@ Moreover, there are also options to :guilabel:`Log out`, see basic information a

Edit Profile<edit/index>
Change Language<language>
About<about>

39 changes: 39 additions & 0 deletions docs/more/development/api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
*******************
Integration via API
*******************

An Application Programming Interface (API) allows machines, such as other systems and tools, to perform actions and transfer data based on agreed-upon methods.

By selecting the :guilabel:`About` option from the :ref:`Profile<profile>` menu, users are directed to the :ref:`About<about>` page where the :guilabel:`API URL` and :guilabel:`API Docs` are provided. Each instance includes SwaggerUI API Documentation, which allows you to explore all operations and data transfer and also you to directly try out the API calls, with example responses provided for guidance.

Authentication and Authorization
================================

DSW utilizes JSON Web Tokens (JWT) for both authentication and authorization, ensuring secure access and control over API interactions. To obtain a token, you must have a user account, and there are multiple methods to acquire one:

* **Credentials** (Email + Password): Send a POST request to /tokens with your email and password. If your credentials are correct and your account is active, you will receive a token along with its expiration time in the response.
* **OpenID Identity Provider** (for our client only): This method involves a more complex OpenID/OAuth flow, utilizing redirects with the ``/auth/{id}/`` endpoints to authenticate.
* **API Keys**: You can generate an API key in your user profile, which remains valid until its specified expiration date.

While several public endpoints are accessible without authentication, most endpoints require it. The system will check if you are authorized to perform specific operations based on your :ref:`roles<user-roles>` and their permissions. These roles are defined globally and can also be specific to projects. This ensures that only authorized users can access and manipulate with sensitive resources.

Example
=======

After obtaining your authentication token and reviewing the API documentation, you can start making API calls to execute actions and transfer data, easily integrating them into your projects. Here's a simple example using the `Requests library in Python <https://requests.readthedocs.io/en/latest/>`__:

.. code-block::
import requests
API_URL = '...'
API_KEY = '...'
response = requests.get(
url=f'{API_URL}/users/current',
headers={'Authorization': f'Bearer {API_KEY}'},
)
response.raise_for_status()
user = response.json()
print(f'This API Key belongs to {user["email"]}')
4 changes: 2 additions & 2 deletions docs/more/development/document-templates/tdk.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ Environment variables and .env file

You can use environment variables to authenticate:

* ``DSW_API_URL`` = URL of |project_name| API with which you want to communicate. Hover mouse over your profile name to find the About section where URL is specified.
* ``DSW_API_KEY`` = your API Key. Hover mouse over your profile name, click on :guilabel:`Edit Profile` and then navigate to :guilabel:`API Keys` From there, you can generate a new API Key for the authentication.
* ``DSW_API_URL`` = URL of |project_name| API with which you want to communicate. Hover mouse over your profile name to find the :ref:`About<about>` section where URL is specified.
* ``DSW_API_KEY`` = your :ref:`API Key<api-keys>`. Hover mouse over your profile name, click on :guilabel:`Edit Profile` and then navigate to :guilabel:`API Keys` From there, you can generate a new API Key for the authentication.

To make this even easier, you can store those in ``.env`` file in the project root and it will be loaded automatically. Or you can specify the path to a ``.env`` file:

Expand Down
1 change: 1 addition & 0 deletions docs/more/development/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ This section provides information on how to develop custom content for |project_
integration-questions/index
Project Importers<importers>
submission-service
Integration via API<api>
contributing
vulnerabilities

0 comments on commit ba9fd18

Please sign in to comment.