@geogirafe/lib-geoportal 1.2.0-dev.2763713312 → 1.2.0-dev.2763717854
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"1.2.0-dev.
|
|
1
|
+
{"version":"1.2.0-dev.2763717854", "build":"2763717854", "date":"16/08/2026"}
|
|
@@ -12,15 +12,30 @@ import GMFManager from './gmfmanager.js';
|
|
|
12
12
|
* But you do not get any valid cookie for the GMF Backend.
|
|
13
13
|
*
|
|
14
14
|
* For all those reasons, we cannot use the geomapfish oAuth process
|
|
15
|
-
* Instead we
|
|
16
|
-
*
|
|
15
|
+
* Instead we delegate the login to the backend, which is a Backend-For-Frontend (BFF) pattern:
|
|
16
|
+
* the frontend only ever holds a session cookie, and never needs any OIDC-specific configuration
|
|
17
|
+
* (no clientId, no issuer url) -- the identity provider is only known to the backend.
|
|
18
|
+
*
|
|
19
|
+
* Two `gmfauth.loginMode` flavors are supported, both delegating entirely to the backend:
|
|
20
|
+
* - 'form' (default): the backend's login.html page, a standard GMF username/password login form.
|
|
21
|
+
* There is no oAuth process at all in this mode.
|
|
22
|
+
* - 'oidc': the backend's oidc/login route (c2cgeoportal_geoportal's OpenID Connect integration).
|
|
23
|
+
* The browser is redirected to oidc/login, which itself redirects to the identity provider;
|
|
24
|
+
* after the user authenticates there, the backend's oidc/callback exchanges the code for tokens
|
|
25
|
+
* (server-side, using the client_secret) and redirects back here with the auth_tkt session cookie
|
|
26
|
+
* set. This is exactly how ngeo authenticates against a GMF backend with
|
|
27
|
+
* `authentication.openid_connect` enabled: the browser never talks to the identity provider
|
|
28
|
+
* directly, and gg-viewer needs no more configuration for this mode than for 'form'.
|
|
29
|
+
*
|
|
30
|
+
* Once the redirect comes back (either flavor), everything below is identical: we only ever
|
|
31
|
+
* trust the session cookie and poll the backend's loginuser endpoint to know who is logged in.
|
|
17
32
|
*
|
|
18
33
|
* NOTE: If the geogirafe client is not running on the same domain as the GMF backend,
|
|
19
34
|
* the GMF Backend needs to be configured with :
|
|
20
35
|
* - CORS with credentials for specific domain (this can be done for example with an lua script at the in the haproxy configuration)
|
|
21
36
|
* - The frontend domain has to be allowed as referer in the vars.yaml file.
|
|
22
37
|
* - The variable AUTHTKT_SAMESITE has to be set to None, to allow authentication cookies to be sent to the backend from another domain
|
|
23
|
-
*
|
|
38
|
+
* These constraints apply identically to both loginMode flavors.
|
|
24
39
|
*/
|
|
25
40
|
export default class GMFConnectManager extends AbstractConnectManager {
|
|
26
41
|
private readonly gmfManager;
|
|
@@ -10,15 +10,30 @@ import AbstractConnectManager from './abstractconnectmanager.js';
|
|
|
10
10
|
* But you do not get any valid cookie for the GMF Backend.
|
|
11
11
|
*
|
|
12
12
|
* For all those reasons, we cannot use the geomapfish oAuth process
|
|
13
|
-
* Instead we
|
|
14
|
-
*
|
|
13
|
+
* Instead we delegate the login to the backend, which is a Backend-For-Frontend (BFF) pattern:
|
|
14
|
+
* the frontend only ever holds a session cookie, and never needs any OIDC-specific configuration
|
|
15
|
+
* (no clientId, no issuer url) -- the identity provider is only known to the backend.
|
|
16
|
+
*
|
|
17
|
+
* Two `gmfauth.loginMode` flavors are supported, both delegating entirely to the backend:
|
|
18
|
+
* - 'form' (default): the backend's login.html page, a standard GMF username/password login form.
|
|
19
|
+
* There is no oAuth process at all in this mode.
|
|
20
|
+
* - 'oidc': the backend's oidc/login route (c2cgeoportal_geoportal's OpenID Connect integration).
|
|
21
|
+
* The browser is redirected to oidc/login, which itself redirects to the identity provider;
|
|
22
|
+
* after the user authenticates there, the backend's oidc/callback exchanges the code for tokens
|
|
23
|
+
* (server-side, using the client_secret) and redirects back here with the auth_tkt session cookie
|
|
24
|
+
* set. This is exactly how ngeo authenticates against a GMF backend with
|
|
25
|
+
* `authentication.openid_connect` enabled: the browser never talks to the identity provider
|
|
26
|
+
* directly, and gg-viewer needs no more configuration for this mode than for 'form'.
|
|
27
|
+
*
|
|
28
|
+
* Once the redirect comes back (either flavor), everything below is identical: we only ever
|
|
29
|
+
* trust the session cookie and poll the backend's loginuser endpoint to know who is logged in.
|
|
15
30
|
*
|
|
16
31
|
* NOTE: If the geogirafe client is not running on the same domain as the GMF backend,
|
|
17
32
|
* the GMF Backend needs to be configured with :
|
|
18
33
|
* - CORS with credentials for specific domain (this can be done for example with an lua script at the in the haproxy configuration)
|
|
19
34
|
* - The frontend domain has to be allowed as referer in the vars.yaml file.
|
|
20
35
|
* - The variable AUTHTKT_SAMESITE has to be set to None, to allow authentication cookies to be sent to the backend from another domain
|
|
21
|
-
*
|
|
36
|
+
* These constraints apply identically to both loginMode flavors.
|
|
22
37
|
*/
|
|
23
38
|
export default class GMFConnectManager extends AbstractConnectManager {
|
|
24
39
|
gmfManager;
|
|
@@ -56,7 +71,8 @@ export default class GMFConnectManager extends AbstractConnectManager {
|
|
|
56
71
|
redirectToIssuerLogin() {
|
|
57
72
|
this.context.sessionManager.saveStateToSession();
|
|
58
73
|
this.redirectUrl = this.getLoginRedirectUrl(false);
|
|
59
|
-
const
|
|
74
|
+
const loginPath = this.authConfig.loginMode === 'oidc' ? 'oidc/login' : 'login.html';
|
|
75
|
+
const authorizationUrl = new URL(`${this.authConfig.url}${loginPath}`);
|
|
60
76
|
authorizationUrl.searchParams.set('came_from', this.redirectUrl);
|
|
61
77
|
window.open(authorizationUrl, '_self');
|
|
62
78
|
}
|
|
@@ -376,12 +376,18 @@ class GirafeConfig {
|
|
|
376
376
|
if (!config.gmfauth.audience) {
|
|
377
377
|
throw new Error(`Configuration for gmfauth.audience is required. See https://doc.geogirafe.org/docs/configuration.`);
|
|
378
378
|
}
|
|
379
|
+
if (config.gmfauth.loginMode !== undefined &&
|
|
380
|
+
config.gmfauth.loginMode !== 'form' &&
|
|
381
|
+
config.gmfauth.loginMode !== 'oidc') {
|
|
382
|
+
throw new Error(`Configuration for gmfauth.loginMode must be 'form' or 'oidc'. See https://doc.geogirafe.org/docs/configuration.`);
|
|
383
|
+
}
|
|
379
384
|
return {
|
|
380
385
|
url: gmfauthUrl,
|
|
381
386
|
audience: config.gmfauth.audience,
|
|
382
387
|
loginRequired: config.gmfauth.loginRequired ?? false,
|
|
383
388
|
checkSessionOnLoad: config.gmfauth.checkSessionOnLoad ?? true,
|
|
384
389
|
authMode: 'cookie',
|
|
390
|
+
loginMode: config.gmfauth.loginMode ?? 'form',
|
|
385
391
|
alwaysSendCookies: config.gmfauth.alwaysSendCookies ?? false,
|
|
386
392
|
refererPolicy: config.gmfauth.refererPolicy ?? 'strict-origin-when-cross-origin',
|
|
387
393
|
audienceExcludedPaths: config.gmfauth.audienceExcludedPaths ?? []
|