Skip to content

Commit

Permalink
docs: improve root README a bit more
Browse files Browse the repository at this point in the history
  • Loading branch information
jahow committed Sep 26, 2024
1 parent 0f4306d commit 4c45974
Showing 1 changed file with 9 additions and 104 deletions.
113 changes: 9 additions & 104 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,15 @@

# GeoNetwork UI

GeoNetwork UI suite of applications provide a modern look for your GeoNetwork catalog.
GeoNetwork-UI provides several applications to improve the user experience of your GeoNetwork catalog.

It also provides Web Components to embed various parts of your data catalog in third party websites.

End users are [invited](https://discourse.osgeo.org/t/about-the-geonetwork-ui-category/59280) to join us on the [geonetwork-ui](https://discourse.osgeo.org/c/geonetwork/ui/59) forum.
End users are [invited](https://discourse.osgeo.org/t/about-the-geonetwork-ui-category/59280) to join us on the GeoNetwork-UI forum on OsGeo Discourse: https://discourse.osgeo.org/c/geonetwork/ui

Developers should check out the [discussions](https://github.com/geonetwork/geonetwork-ui/discussions).
Developers should check out the [GitHub discussions](https://github.com/geonetwork/geonetwork-ui/discussions).

## Documentation

To check out docs, visit [geonetwork-ui website](https://geonetwork.github.io/geonetwork-ui/main/docs/)

## Requirements

- GeoNetwork version 4.2.2
- ElasticSearch version 7.11+

:warning: A bug currently in GeoNetwork 4.2.2 prevents the organizations of showing up correctly in the Datahub application.

As a temporary workaround, the following change is necessary in GeoNetwork data directory:

```diff
diff --git a/web/src/main/webResources/WEB-INF/data/config/index/records.json b/web/src/main/webResources/WEB-INF/data/config/index/records.json
index 1d7e499af7..78e682e3db 100644
--- a/web/src/main/webResources/WEB-INF/data/config/index/records.json
+++ b/web/src/main/webResources/WEB-INF/data/config/index/records.json
@@ -1317,7 +1317,7 @@
"mapping": {
"type": "nested",
"properties": {
- "org": {
+ "organisation": {
"type": "keyword"
},
"role": {
```
To learn more about the project, visit the [GeoNetwork-UI website](https://geonetwork.github.io/geonetwork-ui/main/docs/)

## Getting started

Expand Down Expand Up @@ -103,67 +76,6 @@ npx nx build (app_name)

The build artifacts will be stored in the `dist/` directory. Note: this always produces a production build.

### A word on authentication

GeoNetwork-UI applications rely on the GeoNetwork authentication mechanism. This means that if the user is authenticated in GeoNetwork, they will have access to authenticated features in the corresponding GeoNetwork-UI apps.

There are a few caveats, depending on the deployment scenario:

#### 1. GeoNetwork and GeoNetwork-UI are deployed on the same host, e.g. https://my.host/geonetwork and https://my.host/datahub

In this scenario, requests from the GeoNetwork-UI app to GeoNetwork are _not_ [cross-origin requests](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#what_requests_use_cors), so CORS rules do not apply.

GeoNetwork has an XSRF protection by default, which _will_ make authenticated requests fail unless the following is done:

- either make sure that the XSRF cookies sent by GeoNetwork have a `path` value of `/`; this is typically done like so in GeoNetwork:

```diff
--- a/web/src/main/webapp/WEB-INF/config-security/config-security-core.xml
+++ b/web/src/main/webapp/WEB-INF/config-security/config-security-core.xml
@@ -361,6 +361,7 @@
<bean class="org.fao.geonet.security.web.csrf.CookieCsrfTokenRepository"
id="csrfTokenRepository">
<property name="cookieHttpOnly" value="false"/>
+ <property name="cookiePath" value="/"/>
</bean>
```

Also make sure that the GeoNetwork API URL used by the application is _not_ an absolute URL; a relative URL should be enough in that scenario:

```diff
--- a/conf/default.toml
+++ b/conf/default.toml
@@ -5,7 +5,7 @@
[global]
-geonetwork4_api_url = "https://my.host/geonetwork/srv/api"
+geonetwork4_api_url = "/geonetwork/srv/api"
```

- or disable the XSRF protection selectively for non-critical endpoints of GeoNetwork, e.g. https://my.host/geonetwork/srv/api/userSelections for marking records as favorites; this is typically done like so in GeoNetwork:

```diff
--- a/web/src/main/webapp/WEB-INF/config-security/config-security-core.xml
+++ b/web/src/main/webapp/WEB-INF/config-security/config-security-core.xml
@@ -374,6 +374,9 @@
<value>/[a-zA-Z0-9_\-]+/[a-z]{2,3}/csw!?.*</value>
<value>/[a-zA-Z0-9_\-]+/api/search/.*</value>
<value>/[a-zA-Z0-9_\-]+/api/site</value>
+ <value>/[a-zA-Z0-9_\-]+/api/userselections.*</value>
</set>
</constructor-arg>
</bean>
```

:warning: Please do this responsibly as this could have security implications! :warning:

#### 2. GeoNetwork and GeoNetwork-UI are _not_ deployed on the same host, e.g. https://my.host/geonetwork and https://another.org/datahub

In this scenario, even if CORS settings are correctly set up on GeoNetwork side, most authenticated request will probably fail because by default they are not sent with the [`withCredentials: true`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials) option.

As such, **authenticated requests are not yet supported in GeoNetwork-UI in the case of a cross-origin deployment**; non-authenticated requests (e.g. public search) should still work provided CORS settings were correctly set up on the GeoNetwork side (see [CORS resonse headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#the_http_response_headers)).

Lastly, even if authenticated requests were cleared regarding CORS rules, it would still be needed to disable the XSRF mechanism for the endpoints that GeoNetwork-UI relies on; XSRF protections works by making the client read the content of an HTTP cookie, and that is forbidden in a cross-origin context

### Tests

#### Unit tests
Expand All @@ -187,31 +99,24 @@ npx nx test --test-match=/data/dev/gn/ui/libs/common/src/lib/services/bootstrap.

#### End-to-end-tests

You can test the datahub app by page :

- home page
- search page
- organisations page
- dataset pages

##### To run the tests with the interface :
##### To run the tests with the interface:

Start docker from 'support-services', and then in the 'geonetwork-ui' folder :
Start docker from 'support-services', and then in the project root folder :

```shell script
npx nx e2e appname --watch
npx nx e2e (app_name) --watch
```

Then select the file(s) you want to test in the interface.

##### To run the tests without interface :

Start docker from 'support-services', and then in the 'geonetwork-ui' folder :
Start docker from 'support-services', and then in the project root folder :

--> ALl tests :

```shell script
npx nx e2e appname
npx nx e2e (app_name)
```

## Project structure
Expand Down

0 comments on commit 4c45974

Please sign in to comment.