Wiki source code of Anonymisation des Urls

Last modified by Aurelie Bertrand on 2026/06/22 15:41

Hide last authors
Manon Julien-Kuentz 56.1 1 This document describes how to authenticate automatically within the various DigDash Enterprise modules (dashboards, configuration pages) without using the **‘pass’** parameter.
jhurst 1.1 2
Aurelie Bertrand 21.2 3 (% class="wikigeneratedid" id="HAuthentificationviaunjetonAuthToken" %)
Manon Julien-Kuentz 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.
jhurst 1.1 7
abertrand 14.1 8 (% class="box infomessage" %)
9 (((
Manon Julien-Kuentz 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.
abertrand 14.1 11 )))
abertrand 13.1 12
Manon Julien-Kuentz 56.1 13 = Requesting an AuthToken =
Aurelie Bertrand 21.2 14
Manon Julien-Kuentz 56.1 15 There are three different ways to authenticate when requesting a token.
Aurelie Bertrand 23.1 16
Manon Julien-Kuentz 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:
Aurelie Bertrand 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]]
Aurelie Bertrand 22.1 20
21 (% class="box warningmessage" %)
22 (((
Manon Julien-Kuentz 56.1 23 ❗The password must be correctly encoded for the URL to work.
Aurelie Bertrand 22.1 24 )))
25
Manon Julien-Kuentz 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.
Aurelie Bertrand 42.1 28
29 {{code}}
30 curl -u <user> http://localhost:8080/ddenterpriseapi/DDEnterpriseServlet?method=newAuthToken
31 {{/code}}
32
Manon Julien-Kuentz 56.1 33 By specifying the header yourself: the request takes the following form:
Aurelie Bertrand 42.1 34
35 {{code}}
36 curl -H 'Authorization: Basic <base64(user:pass)>' http://localhost:8080/ddenterpriseapi/DDEnterpriseServlet?method=newAuthToken
37 {{/code}}
38 )))
39
Manon Julien-Kuentz 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):
Aurelie Bertrand 22.1 44
45 {{code language="C"}}
46 curl -H "Authorization: Bearer <JWT>" "http://localhost:8080/ddenterpriseapi/DDEnterpriseServlet?method=newAuthToken"
47 {{/code}}
48
Manon Julien-Kuentz 56.1 49 where //**<JWT>**// should be replaced with the JWT token obtained previously.
Aurelie Bertrand 21.2 50 )))
51 * (((
Manon Julien-Kuentz 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):
Aurelie Bertrand 21.2 56
Aurelie Bertrand 22.1 57 {{code language="C"}}
58 curl -H "X-API-KEY: <apikey>" "http://localhost:8080/ddenterpriseapi/DDEnterpriseServlet?method=newAuthToken"
59 {{/code}}
Aurelie Bertrand 23.1 60
Manon Julien-Kuentz 56.1 61 where //**<apikey>**// should be replaced with the API key obtained previously.
Aurelie Bertrand 24.1 62 )))
Aurelie Bertrand 23.1 63
Manon Julien-Kuentz 56.1 64 The**method=newAuthToken **parameter**allows **the URL or request response to retrieve the new AuthToken generated in this way.
Aurelie Bertrand 23.1 65
Manon Julien-Kuentz 56.1 66 = Using the AuthToken in a URL =
Aurelie Bertrand 21.2 67
Manon Julien-Kuentz 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.
Aurelie Bertrand 24.1 69
Manon Julien-Kuentz 56.1 70 For example, for a dashboard, it would be used as follows:
Aurelie Bertrand 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]]
Manon Julien-Kuentz 56.1 72 The **authToken **parameter **must **be set to the token retrieved in the previous step.
Aurelie Bertrand 24.1 73
Manon Julien-Kuentz 56.1 74 = Advanced: Identity borrowing =
jhurst 1.1 75
Manon Julien-Kuentz 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.
fperrier 12.1 77
Manon Julien-Kuentz 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.
fperrier 12.1 79
Manon Julien-Kuentz 56.1 80 The following prerequisites are required to use this method:
fperrier 12.1 81
Manon Julien-Kuentz 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.
fperrier 12.1 84
Manon Julien-Kuentz 56.1 85 Once these prerequisites have been met, proceed as follows depending on the authentication method used:
fperrier 12.1 86
Manon Julien-Kuentz 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:
Aurelie Bertrand 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]]
Aurelie Bertrand 44.1 90
Manon Julien-Kuentz 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.
Aurelie Bertrand 44.1 93
94 {{code}}
Aurelie Bertrand 47.1 95 curl -u <user> http://localhost:8080/ddenterpriseapi/DDEnterpriseServlet?method=newAuthTokenAs&userId=utilisateurCible
96
Aurelie Bertrand 44.1 97 {{/code}}
98
Manon Julien-Kuentz 56.1 99 By specifying the header yourself: the request takes the following form (example using a curl request):
Aurelie Bertrand 44.1 100
Aurelie Bertrand 54.1 101 {{code language="C"}}
102 curl -H "Authorization: Bearer <JWT>" "http://localhost:8080/ddenterpriseapi/DDEnterpriseServlet?method=newAuthTokenAs&userId=utilisateurCible"
Aurelie Bertrand 47.1 103
Aurelie Bertrand 44.1 104 {{/code}}
105 )))
Manon Julien-Kuentz 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):
Aurelie Bertrand 32.1 109
Aurelie Bertrand 54.1 110 {{code language="C"}}
111 curl -H "Authorization: Bearer <JWT>" "http://localhost:8080/ddenterpriseapi/DDEnterpriseServlet?method=newAuthTokenAs&userId=utilisateurCible"
Aurelie Bertrand 32.1 112 {{/code}}
Aurelie Bertrand 52.1 113
Manon Julien-Kuentz 56.1 114 where//**<JWT>**//should be replaced with the JWT token obtained previously.
Aurelie Bertrand 32.1 115 )))
Aurelie Bertrand 31.1 116 * (((
Manon Julien-Kuentz 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):
Aurelie Bertrand 31.1 120
Aurelie Bertrand 33.1 121 {{code language="C"}}
Aurelie Bertrand 54.1 122 curl -H "X-API-KEY: <apikey>" "http://localhost:8080/ddenterpriseapi/DDEnterpriseServlet?method=newAuthTokenAs&userId=utilisateurCible"
123
Aurelie Bertrand 33.1 124 {{/code}}
Aurelie Bertrand 53.1 125
Manon Julien-Kuentz 56.1 126 where//**<apikey>**//should be replaced with the API key obtained previously.
Aurelie Bertrand 17.2 127 )))
128
Manon Julien-Kuentz 56.1 129 The**method=newAuthTokenAs **parameter**allows **the URL or request response to retrieve the new AuthToken generated in this way.
Aurelie Bertrand 18.2 130
Manon Julien-Kuentz 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:
Aurelie Bertrand 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]]
Manon Julien-Kuentz 56.1 134 The ` **authToken **` parameter **must **be set to the token retrieved in the previous step.