If I understand correctly your question, so you have just a single pair or few pairs of users/passwords that you want to save as a part of the configuration of your web service.
From my experience on a number of projects, and some of them for institutional clients who really care about the security, the solution, from a developer point of view, is simple:
- Save the password in a configuration file as an open text
Now you may ask: "Where the heck is the security?" The answer to a software developer is "None of your business". It will be a business of the system administrator who is setting up the application on the production server. This administrator will make sure that:
- the file contains correct users/passwords required to connect to the production systems that possibly contain sensitive data
- the file is accessible only locally and only to the user under that runs the web service
- the file is saved on an encrypted disk so that it will not be readable by someone else if he unplugs the disk and connects it to a different system
(well, I've never worked as such an administrator so I may have omitted something...)
An example of configuration files setup in a particular project that I worked at:
- In SVN there is a
config.properties
that contains users/passwords for a testing environment that does not hold any sensitive data, so we don't care that any user of the repository can read these passwords
- Before loading the
config.properties
the system looks whether there is present a file called config.properties.local
and loads that one instead of the config.properties
if present. This local file is ignored by the SVN and not committed.
- So with this
config.properties.local
, the developer can override the users/passwords from the config.properties
with his values in the development environment and in the same way the administrator deploying the app uses this config.properties.local
to provide the production users/passwords and ensure the security of the file as described above.
EDIT: Eventually in fact, above I advised saving into a plain text file protected by appropriate access rights and filesystem encryption.
While what this is still a common solution that I often see when installing applications, so probably you should try to use a support that is built-in into the operating system for this purpose.
For example in Ubuntu, that I use, there is Gnome Keyring. Kind of a password manager that can safely store encrypted passwords and decrypt them when needed again by an application. It is unlocked automatically when the user logs in, so it is convenient to use. GUI is called Seahorse (preinstalled in Ubuntu). For CLI install apt package libsecret-tools (utility secret-tool) or search for an API for your programming language.