[Geoserver-users] How to parameterize password of a datastore ?

Hi all,

Is there a way to parameterize the password field of a datastore as with others fields as shown in the doc (https://docs.geoserver.org/latest/en/user/datadirectory/configtemplate.html)

We have several environments which doesn’t necessarily have the same password.

I tried to set something like this without any success in the properties file:

database.passwd=crypt1:xxxxxxx

Thanks in advance

Regards,

I have Geoserver set up in 4 environments, each one deployed into a Tomcat container on 4 separate servers. I have used JNDI in Tomcat to create the database connections as this does not need to be changed when Geoserver is updated.

Having done this then, each Geoserver instance has the same configuration.

···

Graham Humphries | Acting Manager Spatial Capability

Department of State Growth

4 Salamanca Place, Hobart TAS 7000 | GPO Box 536, Hobart TAS 7001

P: (03) 6166 3155

www.stategrowth.tas.gov.au

Courage to make a difference through

TEAMWORK | INTEGRITY | RESPECT | EXCELLENCE

In recognition of the deep history and culture of this island, I acknowledge and pay my respects to all Tasmanian Aboriginal people; the past, and present custodians of the Land.

From: christophe.garault.ext@anonymised.com553… christophe.garault.ext@anonymised.com
Sent: Tuesday, February 20, 2024 2:27 AM
To: geoserver-users@lists.sourceforge.net
Subject: [Geoserver-users] How to parameterize password of a datastore ?

Hi all,

Is there a way to parameterize the password field of a datastore as with others fields as shown in the doc (https://docs.geoserver.org/latest/en/user/datadirectory/configtemplate.html)

We have several environments which doesn’t necessarily have the same password.

I tried to set something like this without any success in the properties file:

database.passwd=crypt1:xxxxxxx

Thanks in advance

Regards,


Christophe GARAULT

____________________________________________________________________________________________________________
Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc
pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce message par erreur, veuillez le signaler
a l'expediteur et le detruire ainsi que les pieces jointes. Les messages electroniques etant susceptibles d'alteration,
Orange decline toute responsabilite si ce message a ete altere, deforme ou falsifie. Merci.

This message and its attachments may contain confidential or privileged information that may be protected by law;
they should not be distributed, used or copied without authorisation.
If you have received this email in error, please notify the sender and delete this message and its attachments.
As emails may be altered, Orange is not liable for messages that have been modified, changed or falsified.
Thank you.

I would recommend JNDI, define the database in tomcat by name and reference it in geoserver config.

···


Jody Garnett

Thanks Jody and Graham, it works fine and it’s well documented. That is exactly what I was looking for.

Now I need to figure out how to move all the already published layers from the old postgis datastore to the new JNDI one since it’s the same database. I guess moving the content of the directory will not be sufficient. Maybe changing the datastore Id in each layer would do the job ?

Regards,


Christophe GARAULT

De : Jody Garnett jody.garnett@anonymised.com
Envoyé : mardi 20 février 2024 03:53
À : GARAULT Christophe Ext DTSI/DTR christophe.garault.ext@anonymised.com
Cc : geoserver-users@lists.sourceforge.net
Objet : Re: [Geoserver-users] How to parameterize password of a datastore ?

I would recommend JNDI, define the database in tomcat by name and reference it in geoserver config.

Jody Garnett

On Mon, Feb 19, 2024 at 7:46 AM <christophe.garault.ext@anonymised.com> wrote:

Hi all,

Is there a way to parameterize the password field of a datastore as with others fields as shown in the doc (https://docs.geoserver.org/latest/en/user/datadirectory/configtemplate.html)

We have several environments which doesn’t necessarily have the same password.

I tried to set something like this without any success in the properties file:

database.passwd=crypt1:xxxxxxx

Thanks in advance

Regards,


Christophe GARAULT

____________________________________________________________________________________________________________
Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc
pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce message par erreur, veuillez le signaler
a l'expediteur et le detruire ainsi que les pieces jointes. Les messages electroniques etant susceptibles d'alteration,
Orange decline toute responsabilite si ce message a ete altere, deforme ou falsifie. Merci.

This message and its attachments may contain confidential or privileged information that may be protected by law;
they should not be distributed, used or copied without authorisation.
If you have received this email in error, please notify the sender and delete this message and its attachments.
As emails may be altered, Orange is not liable for messages that have been modified, changed or falsified.
Thank you.

Geoserver-users mailing list

Please make sure you read the following two resources before posting to this list:

If you want to request a feature or an improvement, also see this: https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer

Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Hello Christophe,

You can copy your files to the folder matching your new datastore and you have to change the technical IDs of the datastore in your files indeed.

Regards
Alexandre

···

Alexandre Gacon

Hi Christophe

Here’s a quick hack to convert from PostGIS to PostGIS (JNDI), if you want to try it. It works for me.

Assumption: you have read/write server access to the configuration directory GEOSERVER_DATA_DIR

cd GEOSERVER_DATA_DIR/workspaces//
edit the file datastore.xml
change line 5 from
PostGIS

PostGIS (JNDI)
add a new line within :

java:comp/env/jdbc/jndi (replacing jndi with the correct string)

restart GeoServer and verify the new datastore in the GUI

hth

···

Peter

GeoServer PSC
AWS Solutions Architect
https://github.com/petersmythe

That’s a clever trick Peter, thanks a lot.

As I don’t need the old datastore anymore I’ll just replace the Id of the newly created one with the old one after moving all the published layers to the right place.

Regards,


Christophe GARAULT

De : Peter Smythe gs@anonymised.com
Envoyé : mardi 20 février 2024 17:33
À : GARAULT Christophe Ext DTSI/DTR christophe.garault.ext@anonymised.com
Cc : Jody Garnett jody.garnett@anonymised.com; geoserver-users@lists.sourceforge.net
Objet : Re: [Geoserver-users] How to parameterize password of a datastore ?

Image supprimée par l'expéditeur.

Hi Christophe

Here’s a quick hack to convert from PostGIS to PostGIS (JNDI), if you want to try it. It works for me.

Assumption: you have read/write server access to the configuration directory GEOSERVER_DATA_DIR

cd GEOSERVER_DATA_DIR/workspaces//

edit the file datastore.xml

change line 5 from

PostGIS

PostGIS (JNDI)

add a new line within :

java:comp/env/jdbc/jndi (replacing jndi with the correct string)

restart GeoServer and verify the new datastore in the GUI

hth

Peter

GeoServer PSC
AWS Solutions Architect
https://github.com/petersmythe

On Tue, 20 Feb 2024 at 16:16, <christophe.garault.ext@anonymised.com> wrote:

Thanks Jody and Graham, it works fine and it’s well documented. That is exactly what I was looking for.

Now I need to figure out how to move all the already published layers from the old postgis datastore to the new JNDI one since it’s the same database. I guess moving the content of the directory will not be sufficient. Maybe changing the datastore Id in each layer would do the job ?

Regards,


Christophe GARAULT

De : Jody Garnett <jody.garnett@anonymised.com>
Envoyé : mardi 20 février 2024 03:53
À : GARAULT Christophe Ext DTSI/DTR <christophe.garault.ext@anonymised.com>
Cc : geoserver-users@lists.sourceforge.net
Objet : Re: [Geoserver-users] How to parameterize password of a datastore ?

I would recommend JNDI, define the database in tomcat by name and reference it in geoserver config.

Jody Garnett

On Mon, Feb 19, 2024 at 7:46 AM <christophe.garault.ext@anonymised.com> wrote:

Hi all,

Is there a way to parameterize the password field of a datastore as with others fields as shown in the doc (https://docs.geoserver.org/latest/en/user/datadirectory/configtemplate.html)

We have several environments which doesn’t necessarily have the same password.

I tried to set something like this without any success in the properties file:

database.passwd=crypt1:xxxxxxx

Thanks in advance

Regards,


Christophe GARAULT

____________________________________________________________________________________________________________
Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc
pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce message par erreur, veuillez le signaler
a l'expediteur et le detruire ainsi que les pieces jointes. Les messages electroniques etant susceptibles d'alteration,
Orange decline toute responsabilite si ce message a ete altere, deforme ou falsifie. Merci.
 
This message and its attachments may contain confidential or privileged information that may be protected by law;
they should not be distributed, used or copied without authorisation.
If you have received this email in error, please notify the sender and delete this message and its attachments.
As emails may be altered, Orange is not liable for messages that have been modified, changed or falsified.
Thank you.

Geoserver-users mailing list

Please make sure you read the following two resources before posting to this list:

If you want to request a feature or an improvement, also see this: https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer

Geoserver-users@anonymised.comforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users


Geoserver-users mailing list

Please make sure you read the following two resources before posting to this list:

If you want to request a feature or an improvement, also see this: https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer

Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users