Skip to content

Commit

Permalink
[GSIP-164] Promote geofence modules from Community to Extension
Browse files Browse the repository at this point in the history
  • Loading branch information
Alessio Fabiani committed Aug 16, 2018
1 parent 7e8e746 commit 01bc4f4
Show file tree
Hide file tree
Showing 47 changed files with 542 additions and 498 deletions.
4 changes: 2 additions & 2 deletions doc/en/user/source/community/geofence/cache.rst
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Requests
-------- --------


``/geofence/ruleCache/info`` ``/geofence/ruleCache/info``
~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Retrieve information about the geofence cache status. Retrieve information about the geofence cache status.


Expand All @@ -28,7 +28,7 @@ Retrieve information about the geofence cache status.




``/geofence/ruleCache/invalidate`` ``/geofence/ruleCache/invalidate``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Invalidate the geofence cache. Invalidate the geofence cache.


Expand Down
76 changes: 76 additions & 0 deletions doc/en/user/source/community/geofence/configuration.rst
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Configure the following settings here:


- GeoServer services URL: this is how geoserver knows how to connect to the external geofence server. When using an internal geofence server, this is not configurable. For example "http://localhost:9191/geofence/remoting/RuleReader" for an external geofence server on localhost. - GeoServer services URL: this is how geoserver knows how to connect to the external geofence server. When using an internal geofence server, this is not configurable. For example "http://localhost:9191/geofence/remoting/RuleReader" for an external geofence server on localhost.



Options Options
------- -------


Expand All @@ -29,6 +30,7 @@ Configure the following settings here:


- Comma delimited list of mutually exclusive roles for authorization - Comma delimited list of mutually exclusive roles for authorization



Cache Cache
----- -----


Expand All @@ -41,3 +43,77 @@ Configure the following settings here:
- Cache expire interval (ms) - Cache expire interval (ms)


Collected data about the cache can be retrieved here. Per cache (rules, admin rules and users) we retrieve the cache size, hits, misses, load successes, load failures, load times and evictions. The cache can be manually invalidated (cleared). Collected data about the cache can be retrieved here. Per cache (rules, admin rules and users) we retrieve the cache size, hits, misses, load successes, load failures, load times and evictions. The cache can be manually invalidated (cleared).

Basic GeoServer configuration
-----------------------------

- Login with the default administrative credentials ``admin / geoserver`` (or whatever you have configured before).

.. figure:: images/basic_001.png
:align: center

- In the security panel you'll find the GeoFence link to the GeoFence security admin page

.. figure:: images/basic_002.png
:align: center

- Open the GeoFence admin page; you'll get to this page:

You can notice here the information that allow the GeoFence probe inside GeoServer to communicate with the GeoFence engine:

- the URL that the probe shall use to communicate with GeoFence;
- the name (default is `default-gs`) this instance will use to identify itself to GeoFence. This instance name should be equal to the one we set into GeoFence.

- Testing connection to GeoFence.

We altready performed a connection test from GeoFence to GeoServer. Using the button **Test connection** we can also test that GeoServer can communicate to GeoFence. If everything is ok, you'll get this message:

.. figure:: images/basic_003.png
:align: center

- Open the **Authentication** page under the **Security** settings:

.. figure:: images/basic_004.png
:align: center

- Add the GeoFence authenticator and **put it as the first in the list** otherwise you will not be able to login as ``admin/admin``:

.. figure:: images/basic_005.png
:align: center

- Now that we added GeoFence as authentication provider, we'll be able to log into GeoServer using the credentials we added in GeoFence (user ``admin`` and user `tiger`). Try and log in using user ``tiger``.

Testing authorization
---------------------

- Logging into GeoServer as admin you will be able to see all the defined layers:

.. figure:: images/basic_006.png
:align: center

- Logging into GeoServer as a non-admin user, the defined rules will be examined; since we defined no rules yet, the default behaviour is to deny access to all resources:

.. figure:: images/basic_007.png
:align: center

- Get back to GeoFence, and add a rule which allows all layers in workspace tiger for user ``tiger``; create a rule defining:

- user ``tiger``
- instance ``default-gs``
- workspace ``tiger`` (you will get a dropdown menu containing all the workspaces available in the selected instance)
- grant type: ``allow`` You'll get a line like this one:

.. figure:: images/basic_008.png
:align: center

- Verify the new authorizations.

Since the probe caches the GeoFence responses, you may need to login again as administrator (or you may keep an admin session open in another browser) and clear the probe cache. You can do it by pressing the "Invalidate" button in the bottom of the GeoFence admin page:

.. figure:: images/basic_009.png
:align: center

- Login again in GeoServer as user tiger and you will see in **layer preview** all the layers in the ``tiger`` workspace:

.. figure:: images/basic_010.png
:align: center
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* This code is licensed under the GPL 2.0 license, available at the root * This code is licensed under the GPL 2.0 license, available at the root
* application directory. * application directory.
*/ */

package org.geoserver.geofence.internal; package org.geoserver.geofence.internal;


import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* This code is licensed under the GPL 2.0 license, available at the root * This code is licensed under the GPL 2.0 license, available at the root
* application directory. * application directory.
*/ */

package org.geoserver.geofence.internal; package org.geoserver.geofence.internal;


import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public void testMarshal() throws Exception {
public void testUnmarshal() throws Exception { public void testUnmarshal() throws Exception {
GML3MockData.setGML(GML.getInstance()); GML3MockData.setGML(GML.getInstance());
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
;
Element allowedArea = Element allowedArea =
GML3MockData.element(new QName(null, "allowedArea"), document, document); GML3MockData.element(new QName(null, "allowedArea"), document, document);
Element multiGeometry = Element multiGeometry =
Expand Down
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,53 @@
/* (c) 2018 Open Source Geospatial Foundation - all rights reserved
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
*/
package org.geoserver.geofence.web;

import static org.junit.Assert.assertEquals;

import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.util.tester.FormTester;
import org.geoserver.data.test.SystemTestData;
import org.geoserver.geofence.config.GeoFencePropertyPlaceholderConfigurer;
import org.geoserver.geofence.services.dto.ShortAdminRule;
import org.geoserver.web.GeoServerWicketTestSupport;
import org.geoserver.web.wicket.GeoServerTablePanel;
import org.junit.Before;
import org.junit.Test;

public class GeofenceServerAdminPageTest extends GeoServerWicketTestSupport {

static GeoFencePropertyPlaceholderConfigurer configurer;

@Override
protected void onSetUp(SystemTestData testData) throws Exception {
super.onSetUp(testData);
}

@Before
public void before() {
login();
tester.startPage(GeofenceServerAdminPage.class);
}

@Test
public void testAddNewRuleLink() {
tester.assertRenderedPage(GeofenceServerAdminPage.class);
tester.assertComponent("addNew", AjaxLink.class);
tester.clickLink("addNew");
tester.assertRenderedPage(GeofenceAdminRulePage.class);

// submit a new rule
FormTester form = tester.newFormTester("form");
form.submit("save");

tester.assertRenderedPage(GeofenceServerAdminPage.class);

// check the rules model
GeoServerTablePanel<ShortAdminRule> rulesPanel =
(GeoServerTablePanel<ShortAdminRule>)
tester.getComponentFromLastRenderedPage("rulesPanel");
assertEquals(1, rulesPanel.getDataProvider().size());
}
}
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,53 @@
/* (c) 2018 Open Source Geospatial Foundation - all rights reserved
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
*/
package org.geoserver.geofence.web;

import static org.junit.Assert.assertEquals;

import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.util.tester.FormTester;
import org.geoserver.data.test.SystemTestData;
import org.geoserver.geofence.config.GeoFencePropertyPlaceholderConfigurer;
import org.geoserver.geofence.services.dto.ShortAdminRule;
import org.geoserver.web.GeoServerWicketTestSupport;
import org.geoserver.web.wicket.GeoServerTablePanel;
import org.junit.Before;
import org.junit.Test;

public class GeofenceServerPageTest extends GeoServerWicketTestSupport {

static GeoFencePropertyPlaceholderConfigurer configurer;

@Override
protected void onSetUp(SystemTestData testData) throws Exception {
super.onSetUp(testData);
}

@Before
public void before() {
login();
tester.startPage(GeofenceServerPage.class);
}

@Test
public void testAddNewRuleLink() {
tester.assertRenderedPage(GeofenceServerPage.class);
tester.assertComponent("addNew", AjaxLink.class);
tester.clickLink("addNew");
tester.assertRenderedPage(GeofenceRulePage.class);

// submit a new rule
FormTester form = tester.newFormTester("form");
form.submit("save");

tester.assertRenderedPage(GeofenceServerPage.class);

// check the rules model
GeoServerTablePanel<ShortAdminRule> rulesPanel =
(GeoServerTablePanel<ShortAdminRule>)
tester.getComponentFromLastRenderedPage("rulesPanel");
assertEquals(1, rulesPanel.getDataProvider().size());
}
}
Original file line number Original file line Diff line number Diff line change
@@ -1,21 +1,6 @@
/* /* (c) 2018 Open Source Geospatial Foundation - all rights reserved
* Copyright (C) 2007 - 2017 GeoSolutions S.A.S. * This code is licensed under the GPL 2.0 license, available at the root
* http://www.geo-solutions.it * application directory.
*
* GPLv3 + Classpath exception
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.geoserver.geofence; package org.geoserver.geofence;


Expand Down
Original file line number Original file line Diff line number Diff line change
@@ -1,23 +1,7 @@
/* /* (c) 2018 Open Source Geospatial Foundation - all rights reserved
* Copyright (C) 2007 - 2014 GeoSolutions S.A.S. * This code is licensed under the GPL 2.0 license, available at the root
* http://www.geo-solutions.it * application directory.
*
* GPLv3 + Classpath exception
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */

package org.geoserver.geofence.cache; package org.geoserver.geofence.cache;


import com.google.common.base.Ticker; import com.google.common.base.Ticker;
Expand Down
Original file line number Original file line Diff line number Diff line change
@@ -1,21 +1,6 @@
/* /* (c) 2018 Open Source Geospatial Foundation - all rights reserved
* Copyright (C) 2007 - 2015 GeoSolutions S.A.S. * This code is licensed under the GPL 2.0 license, available at the root
* http://www.geo-solutions.it * application directory.
*
* GPLv3 + Classpath exception
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.geoserver.geofence.cache; package org.geoserver.geofence.cache;


Expand Down
Original file line number Original file line Diff line number Diff line change
@@ -1,21 +1,6 @@
/* /* (c) 2018 Open Source Geospatial Foundation - all rights reserved
* Copyright (C) 2007 - 2014 GeoSolutions S.A.S. * This code is licensed under the GPL 2.0 license, available at the root
* http://www.geo-solutions.it * application directory.
*
* GPLv3 + Classpath exception
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.geoserver.geofence.config; package org.geoserver.geofence.config;


Expand Down
Original file line number Original file line Diff line number Diff line change
@@ -1,23 +1,7 @@
/* /* (c) 2018 Open Source Geospatial Foundation - all rights reserved
* Copyright (C) 2014 GeoSolutions S.A.S. * This code is licensed under the GPL 2.0 license, available at the root
* http://www.geo-solutions.it * application directory.
*
* GPLv3 + Classpath exception
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */

package org.geoserver.geofence.config; package org.geoserver.geofence.config;


import java.io.IOException; import java.io.IOException;
Expand Down
Original file line number Original file line Diff line number Diff line change
@@ -1,23 +1,7 @@
/* /* (c) 2018 Open Source Geospatial Foundation - all rights reserved
* Copyright (C) 2014 GeoSolutions S.A.S. * This code is licensed under the GPL 2.0 license, available at the root
* http://www.geo-solutions.it * application directory.
*
* GPLv3 + Classpath exception
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */

package org.geoserver.geofence.config; package org.geoserver.geofence.config;


import java.io.BufferedWriter; import java.io.BufferedWriter;
Expand Down

0 comments on commit 01bc4f4

Please sign in to comment.