Wiki source code of Anonymisation des Urls
Last modified by Aurelie Bertrand on 2026/06/22 15:41
Hide last authors
| author | version | line-number | content |
|---|---|---|---|
| |
56.1 | 1 | This document describes how to authenticate automatically within the various DigDash Enterprise modules (dashboards, configuration pages) without using the **‘pass’** parameter. |
| |
1.1 | 2 | |
| |
21.2 | 3 | (% class="wikigeneratedid" id="HAuthentificationviaunjetonAuthToken" %) |
| |
56.1 | 4 | The principle is that, once authenticated, a token is requested which, when used, allows a new session to be created **based on the one requested by the current session**. |
| 5 | This token allows an automatic session to be created without having to specify the user’s password. | ||
| 6 | This token is single-use; the same token cannot be used to create more than one session. To create multiple sessions, multiple tokens are required. | ||
| |
1.1 | 7 | |
| |
14.1 | 8 | (% class="box infomessage" %) |
| 9 | ((( | ||
| |
56.1 | 10 | ℹ The token is single-use but has no expiry time. As long as the initial session has not expired, the token can be used. |
| |
14.1 | 11 | ))) |
| |
13.1 | 12 | |
| |
56.1 | 13 | = Requesting an AuthToken = |
| |
21.2 | 14 | |
| |
56.1 | 15 | There are three different ways to authenticate when requesting a token. |
| |
23.1 | 16 | |
| |
56.1 | 17 | * **Logged in with username and password: ** |
| 18 | The token request is made via a web service with a URL in the following format: | ||
| |
28.1 | 19 | [[http:~~/~~/localhost:8080/ddenterpriseapi/DDEnterpriseServlet?user=admin&pass=admin&method=newAuthToken>>http://localhost:8080/ddenterpriseapi/DDEnterpriseServlet?user=admin&pass=admin&method=newAuthToken]] |
| |
22.1 | 20 | |
| 21 | (% class="box warningmessage" %) | ||
| 22 | ((( | ||
| |
56.1 | 23 | ❗The password must be correctly encoded for the URL to work. |
| |
22.1 | 24 | ))) |
| 25 | |||
| |
56.1 | 26 | * **Using basic authentication:**((( |
| 27 | Using curl with the -u option: you will be prompted for the password after the request is executed. | ||
| |
42.1 | 28 | |
| 29 | {{code}} | ||
| 30 | curl -u <user> http://localhost:8080/ddenterpriseapi/DDEnterpriseServlet?method=newAuthToken | ||
| 31 | {{/code}} | ||
| 32 | |||
| |
56.1 | 33 | By specifying the header yourself: the request takes the following form: |
| |
42.1 | 34 | |
| 35 | {{code}} | ||
| 36 | curl -H 'Authorization: Basic <base64(user:pass)>' http://localhost:8080/ddenterpriseapi/DDEnterpriseServlet?method=newAuthToken | ||
| 37 | {{/code}} | ||
| 38 | ))) | ||
| 39 | |||
| |
56.1 | 40 | * **Using a JWT token:**((( |
| 41 | The token is requested via a request. The JWT (JSON Web Token) is specified in the HTTP header for authentication. | ||
| 42 | This JWT is generated via the DigDash REST API without a defined target user (targetUser). See the section [[Creating a JWT token>>doc:Digdash.API.DD_API.WebHome||anchor="JWT"]] for further details. | ||
| 43 | The request takes the following form (example using a curl request): | ||
| |
22.1 | 44 | |
| 45 | {{code language="C"}} | ||
| 46 | curl -H "Authorization: Bearer <JWT>" "http://localhost:8080/ddenterpriseapi/DDEnterpriseServlet?method=newAuthToken" | ||
| 47 | {{/code}} | ||
| 48 | |||
| |
56.1 | 49 | where //**<JWT>**// should be replaced with the JWT token obtained previously. |
| |
21.2 | 50 | ))) |
| 51 | * ((( | ||
| |
56.1 | 52 | **Using an API key:** |
| 53 | The API key is requested via a request. The API key is specified in the HTTP header for authentication. | ||
| 54 | This API key is generated via the DigDash REST API without a defined target user (targetUser). See the section [[Creating an API key>>doc:Digdash.API.DD_API.WebHome||anchor="API"]] for further details. | ||
| 55 | The request takes the following form (example using a curl request): | ||
| |
21.2 | 56 | |
| |
22.1 | 57 | {{code language="C"}} |
| 58 | curl -H "X-API-KEY: <apikey>" "http://localhost:8080/ddenterpriseapi/DDEnterpriseServlet?method=newAuthToken" | ||
| 59 | {{/code}} | ||
| |
23.1 | 60 | |
| |
56.1 | 61 | where //**<apikey>**// should be replaced with the API key obtained previously. |
| |
24.1 | 62 | ))) |
| |
23.1 | 63 | |
| |
56.1 | 64 | The**method=newAuthToken **parameter**allows **the URL or request response to retrieve the new AuthToken generated in this way. |
| |
23.1 | 65 | |
| |
56.1 | 66 | = Using the AuthToken in a URL = |
| |
21.2 | 67 | |
| |
56.1 | 68 | Once you have retrieved the AuthToken, you can use it in a URL to create an automatic session without entering any authentication details. |
| |
24.1 | 69 | |
| |
56.1 | 70 | For example, for a dashboard, it would be used as follows: |
| |
28.1 | 71 | [[http:~~/~~/localhost:8080/digdash_dashboard/index.html?user=admin&authToken=token>>http://localhost:8080/digdash_dashboard/index.html?user=admin&authToken=token]] |
| |
56.1 | 72 | The **authToken **parameter **must **be set to the token retrieved in the previous step. |
| |
24.1 | 73 | |
| |
56.1 | 74 | = Advanced: Identity borrowing = |
| |
1.1 | 75 | |
| |
56.1 | 76 | **The API’s newAuthToken **method returns a token for the current session and the current user. You must therefore have a session for that user in order to call this method and use its result in a URL. |
| |
12.1 | 77 | |
| |
56.1 | 78 | In some cases, this is a constraint, and it is useful to be able to open a session for another (target) user, using a source user. There is a ` **newAuthTokenAs **` method **which **takes an additional **`userId**` parameter. |
| |
12.1 | 79 | |
| |
56.1 | 80 | The following prerequisites are required to use this method: |
| |
12.1 | 81 | |
| |
56.1 | 82 | * The system must have the property **PROP_NEWAUTHTOKENAS = **true in **system.xml** |
| 83 | * The source user must have the **Admin > Allow impersonate** authorisation. | ||
| |
12.1 | 84 | |
| |
56.1 | 85 | Once these prerequisites have been met, proceed as follows depending on the authentication method used: |
| |
12.1 | 86 | |
| |
56.1 | 87 | * **Logged in with username and password: ** |
| 88 | The target user must be specified in the URL when requesting the token in the following format: | ||
| |
45.1 | 89 | [[http:~~/~~/localhost:8080/ddenterpriseapi/DDEnterpriseServlet?user=admin&pass=admin&method=newAuthTokenAs&userId=utilisateurCible>>http://http//localhost:8080/ddenterpriseapi/DDEnterpriseServlet?user=admin&pass=admin&method=newAuthTokenAs&userId=userCible]] |
| |
44.1 | 90 | |
| |
56.1 | 91 | * **Via basic authorisation:**((( |
| 92 | Using curl with the -u option: you will be prompted for the password after the request has been executed. | ||
| |
44.1 | 93 | |
| 94 | {{code}} | ||
| |
47.1 | 95 | curl -u <user> http://localhost:8080/ddenterpriseapi/DDEnterpriseServlet?method=newAuthTokenAs&userId=utilisateurCible |
| 96 | |||
| |
44.1 | 97 | {{/code}} |
| 98 | |||
| |
56.1 | 99 | By specifying the header yourself: the request takes the following form (example using a curl request): |
| |
44.1 | 100 | |
| |
54.1 | 101 | {{code language="C"}} |
| 102 | curl -H "Authorization: Bearer <JWT>" "http://localhost:8080/ddenterpriseapi/DDEnterpriseServlet?method=newAuthTokenAs&userId=utilisateurCible" | ||
| |
47.1 | 103 | |
| |
44.1 | 104 | {{/code}} |
| 105 | ))) | ||
| |
56.1 | 106 | * **Via a JWT token:** |
| 107 | This JWT token is generated via the DigDash REST API without a defined target user (targetUser). See the section [[Creating a JWT token>>doc:Digdash.API.DD_API.WebHome||anchor="JWT"]] for further details.((( | ||
| 108 | The request takes the following form (example using a curl request): | ||
| |
32.1 | 109 | |
| |
54.1 | 110 | {{code language="C"}} |
| 111 | curl -H "Authorization: Bearer <JWT>" "http://localhost:8080/ddenterpriseapi/DDEnterpriseServlet?method=newAuthTokenAs&userId=utilisateurCible" | ||
| |
32.1 | 112 | {{/code}} |
| |
52.1 | 113 | |
| |
56.1 | 114 | where//**<JWT>**//should be replaced with the JWT token obtained previously. |
| |
32.1 | 115 | ))) |
| |
31.1 | 116 | * ((( |
| |
56.1 | 117 | **Using an API key:** |
| 118 | This API key is generated via the DigDash REST API without a defined target user (targetUser). See the section [[Create an API key>>doc:Digdash.API.DD_API.WebHome||anchor="API"]] for further details. | ||
| 119 | The request takes the following form (example using a curl request): | ||
| |
31.1 | 120 | |
| |
33.1 | 121 | {{code language="C"}} |
| |
54.1 | 122 | curl -H "X-API-KEY: <apikey>" "http://localhost:8080/ddenterpriseapi/DDEnterpriseServlet?method=newAuthTokenAs&userId=utilisateurCible" |
| 123 | |||
| |
33.1 | 124 | {{/code}} |
| |
53.1 | 125 | |
| |
56.1 | 126 | where//**<apikey>**//should be replaced with the API key obtained previously. |
| |
17.2 | 127 | ))) |
| 128 | |||
| |
56.1 | 129 | The**method=newAuthTokenAs **parameter**allows **the URL or request response to retrieve the new AuthToken generated in this way. |
| |
18.2 | 130 | |
| |
56.1 | 131 | You can then use the token in a URL to create an automatic session without authentication details. |
| 132 | For example, for a dashboard, in the following format: | ||
| |
34.1 | 133 | [[http:~~/~~/localhost:8080/digdash_dashboard/index.html?user=utilisateurCible&authToken=token>>http://localhost:8080/digdash_dashboard/index.html?user=userCible&authToken=token]] |
| |
56.1 | 134 | The ` **authToken **` parameter **must **be set to the token retrieved in the previous step. |