Skip to content

Commit 242c73b

Browse files
fxprunayrePascalLike
authored andcommitted
GN5 / Add sign in/out support
Currently, when deploying GeoNetwork 5 with GeoNetwork 4 sign in operation are managed by version 5. This adds the possibility to sign in from GeoNetwork 4 directly. Configuration steps for GN4 are: * start with `-Dgeonetwork.security.type=gn5` * In `config-security.properties`, configure the URLs for login and logout to point to GN5 (this could maybe be avoided with X-Forwarded headers?): ```properties logout.success.url=http://localhost:7979/geonetwork/srv/eng/catalog.search loginForm=http://localhost:7979/geonetwork/srv/eng/catalog.signin loginErrorForm=http://localhost:7979/geonetwork/srv/eng/catalog.signin?failure=true ``` * In UI configuration, enable the authentication and set the signin/signout URLs to use the GN5 URLs: ```json "authentication": { "enabled": true, "signinUrl": "../../{{node}}/{{lang}}/catalog.signin", "signinAPI": "../../api/user/signin", "signoutUrl": "../../api/user/signout" ```
1 parent 36160ae commit 242c73b

File tree

6 files changed

+17
-8
lines changed

6 files changed

+17
-8
lines changed

core/src/main/java/org/fao/geonet/util/XslUtil.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,9 @@ public static boolean isAuthenticated() throws Exception {
563563
public static boolean isDisableLoginForm() {
564564
SecurityProviderConfiguration securityProviderConfiguration = SecurityProviderConfiguration.get();
565565

566+
if ("gn5".equals(System.getProperty("geonetwork.security.type"))) {
567+
return false;
568+
}
566569
if (securityProviderConfiguration != null) {
567570
// No login form if providing a link or autologin
568571
return securityProviderConfiguration.getLoginType().equals(SecurityProviderConfiguration.LoginType.AUTOLOGIN.toString().toLowerCase())

web-ui/src/main/resources/catalog/components/toolbar/partials/menu-signin.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
data-ng-if="!authenticated && service !== 'catalog.signin' && service !== 'new.account' && isShowLoginAsLink"
7171
>
7272
<a
73-
href="{{signInFormAction}}?_csrf={{csrf}}&redirectUrl={{redirectUrlAfterSign}}"
73+
href="{{gnCfg.mods.authentication.signinUrl}}?_csrf={{csrf}}&redirectUrl={{redirectUrlAfterSign}}"
7474
title="{{'signIn'|translate}}"
7575
class="gn-menuheader-xs"
7676
data-ng-keypress="$event"
@@ -86,7 +86,7 @@
8686
data-ng-if="!authenticated && service !== 'catalog.signin' && service !== 'new.account' && !isShowLoginAsLink && !isDisableLoginForm"
8787
>
8888
<a
89-
href="{{gnCfg.mods.authentication.signinUrl | signInLink}}"
89+
href="{{signInFormLinkWithHash}}"
9090
title="{{'signIn'|translate}}"
9191
class="dropdown-toggle gn-menuheader-xs"
9292
data-ng-keypress="$event"
@@ -102,7 +102,7 @@
102102
<form
103103
name="gnSigninForm"
104104
class="navbar-form"
105-
action="{{signInFormAction}}"
105+
action="{{signInFormActionWithHash}}"
106106
method="post"
107107
role="form"
108108
>

web-ui/src/main/resources/catalog/js/CatController.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,11 @@
12981298
authentication: {
12991299
enabled: true,
13001300
signinUrl: "../../{{node}}/{{lang}}/catalog.signin",
1301+
signinAPI: "../../signin",
13011302
signoutUrl: "../../signout"
1303+
// GN5 configuration
1304+
// signinAPI: "../../api/user/signin",
1305+
// signoutUrl: "../../api/user/signout"
13021306
},
13031307
page: {
13041308
enabled: true,
@@ -1871,8 +1875,11 @@
18711875
}
18721876
});
18731877

1874-
// login url for inline signin form in top toolbar
1875-
$scope.signInFormAction = "../../signin#" + $location.url();
1878+
// login url and form action with hash reference to the current page
1879+
$scope.signInFormLinkWithHash =
1880+
$scope.gnCfg.mods.authentication.signinUrl + "#" + $location.url();
1881+
$scope.signInFormActionWithHash =
1882+
$scope.gnCfg.mods.authentication.signinAPI + "#" + $location.url();
18761883

18771884
// when the login input have focus, do not close the dropdown/popup
18781885
$scope.focusLoginPopup = function () {

web-ui/src/main/resources/catalog/js/LoginController.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
$q,
6868
gnLangs
6969
) {
70-
$scope.formAction = "../../signin#" + $location.url();
7170
$scope.registrationStatus = null;
7271
$scope.sendPassword = false;
7372
$scope.password = null;

web-ui/src/main/resources/catalog/templates/signin.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ <h1 data-translate="">loginTitle</h1>
4040
<form
4141
class="form-horizontal"
4242
name="gnSigninForm"
43-
action="{{formAction}}"
43+
action="{{signInFormActionWithHash}}"
4444
method="post"
4545
role="form"
4646
data-ng-if="::user"

web-ui/src/main/resources/catalog/views/default/templates/recordView/recordView.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
<span
4646
data-ng-hide="user"
4747
data-translate=""
48-
data-translate-values="{signInFormAction: '{{signInFormAction}}', csrf: '{{csrf}}', redirectUrlAfterSign: '{{redirectUrlAfterSign}}'}"
48+
data-translate-values="{signInFormAction: '{{signInFormLinkWithHash | signInLink}}}', csrf: '{{csrf}}', redirectUrlAfterSign: '{{redirectUrlAfterSign}}'}"
4949
>
5050
trySignIn
5151
</span>

0 commit comments

Comments
 (0)