Wiki source code of Anonymisation des Urls

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

Show last authors
1 This document describes how to authenticate automatically within the various DigDash Enterprise modules (dashboards, configuration pages) without using the **‘pass’** parameter.
2
3 (% class="wikigeneratedid" id="HAuthentificationviaunjetonAuthToken" %)
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.
7
8 (% class="box infomessage" %)
9 (((
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.
11 )))
12
13 = Requesting an AuthToken =
14
15 There are three different ways to authenticate when requesting a token.
16
17 * **Logged in with username and password: **
18 The token request is made via a web service with a URL in the following format:
19 [[http:~~/~~/localhost:8080/ddenterpriseapi/DDEnterpriseServlet?user=admin&pass=admin&method=newAuthToken>>http://localhost:8080/ddenterpriseapi/DDEnterpriseServlet?user=admin&pass=admin&method=newAuthToken]]
20
21 (% class="box warningmessage" %)
22 (((
23 ❗The password must be correctly encoded for the URL to work.
24 )))
25
26 * **Using basic authentication:**(((
27 Using curl with the -u option: you will be prompted for the password after the request is executed.
28
29 {{code}}
30 curl -u <user> http://localhost:8080/ddenterpriseapi/DDEnterpriseServlet?method=newAuthToken
31 {{/code}}
32
33 By specifying the header yourself: the request takes the following form:
34
35 {{code}}
36 curl -H 'Authorization: Basic <base64(user:pass)>' http://localhost:8080/ddenterpriseapi/DDEnterpriseServlet?method=newAuthToken
37 {{/code}}
38 )))
39
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):
44
45 {{code language="C"}}
46 curl -H "Authorization: Bearer <JWT>" "http://localhost:8080/ddenterpriseapi/DDEnterpriseServlet?method=newAuthToken"
47 {{/code}}
48
49 where //**<JWT>**// should be replaced with the JWT token obtained previously.
50 )))
51 * (((
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):
56
57 {{code language="C"}}
58 curl -H "X-API-KEY: <apikey>" "http://localhost:8080/ddenterpriseapi/DDEnterpriseServlet?method=newAuthToken"
59 {{/code}}
60
61 where //**<apikey>**// should be replaced with the API key obtained previously.
62 )))
63
64 The**method=newAuthToken **parameter**allows **the URL or request response to retrieve the new AuthToken generated in this way.
65
66 = Using the AuthToken in a URL =
67
68 Once you have retrieved the AuthToken, you can use it in a URL to create an automatic session without entering any authentication details.
69
70 For example, for a dashboard, it would be used as follows:
71 [[http:~~/~~/localhost:8080/digdash_dashboard/index.html?user=admin&authToken=token>>http://localhost:8080/digdash_dashboard/index.html?user=admin&authToken=token]]
72 The **authToken **parameter **must **be set to the token retrieved in the previous step.
73
74 = Advanced: Identity borrowing =
75
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.
77
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.
79
80 The following prerequisites are required to use this method:
81
82 * The system must have the property **PROP_NEWAUTHTOKENAS = **true in **system.xml**
83 * The source user must have the **Admin > Allow impersonate** authorisation.
84
85 Once these prerequisites have been met, proceed as follows depending on the authentication method used:
86
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:
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]]
90
91 * **Via basic authorisation:**(((
92 Using curl with the -u option: you will be prompted for the password after the request has been executed.
93
94 {{code}}
95 curl -u <user> http://localhost:8080/ddenterpriseapi/DDEnterpriseServlet?method=newAuthTokenAs&userId=utilisateurCible
96
97 {{/code}}
98
99 By specifying the header yourself: the request takes the following form (example using a curl request):
100
101 {{code language="C"}}
102 curl -H "Authorization: Bearer <JWT>" "http://localhost:8080/ddenterpriseapi/DDEnterpriseServlet?method=newAuthTokenAs&userId=utilisateurCible"
103
104 {{/code}}
105 )))
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):
109
110 {{code language="C"}}
111 curl -H "Authorization: Bearer <JWT>" "http://localhost:8080/ddenterpriseapi/DDEnterpriseServlet?method=newAuthTokenAs&userId=utilisateurCible"
112 {{/code}}
113
114 where//**<JWT>**//should be replaced with the JWT token obtained previously.
115 )))
116 * (((
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):
120
121 {{code language="C"}}
122 curl -H "X-API-KEY: <apikey>" "http://localhost:8080/ddenterpriseapi/DDEnterpriseServlet?method=newAuthTokenAs&userId=utilisateurCible"
123
124 {{/code}}
125
126 where//**<apikey>**//should be replaced with the API key obtained previously.
127 )))
128
129 The**method=newAuthTokenAs **parameter**allows **the URL or request response to retrieve the new AuthToken generated in this way.
130
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:
133 [[http:~~/~~/localhost:8080/digdash_dashboard/index.html?user=utilisateurCible&authToken=token>>http://localhost:8080/digdash_dashboard/index.html?user=userCible&authToken=token]]
134 The ` **authToken **` parameter **must **be set to the token retrieved in the previous step.