Permalink
Browse files

Minor touchup on pgpass work

  • Loading branch information...
roji committed Jul 25, 2017
1 parent 7282bbc commit d6a7960ba463132bce084f0e43966c4447fb1b2c
@@ -4,14 +4,14 @@ Parameter keywords are case-insensitive.
## Basic Connection
| Parameter | Description | Default |
|-----------|-------------------------------------------------------------------------|------------------|
| Host | Specifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for the Unix-domain socket (specifying a `Port` is still required). | *Required* |
| Port | The TCP port of the PostgreSQL server. | 5432 |
| Database | The PostgreSQL database to connect to. | Same as Username |
| Username | The username to connect with. Not required if using IntegratedSecurity. | |
| Password | The password to connect with. Not required if using IntegratedSecurity. | |
| PgPassFile | Path to a PostgreSQL Password File (PGPASSFILE), from which the password would be taken. | ||
| Parameter | Description | Default |
|--------------|------------------------------------------------------------------------------------|------------------|
| Host | Specifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for the Unix-domain socket (specifying a `Port` is still required). | *Required* |
| Port | The TCP port of the PostgreSQL server. | 5432 |
| Database | The PostgreSQL database to connect to. | Same as Username |
| Username | The username to connect with. Not required if using IntegratedSecurity. | |
| Password | The password to connect with. Not required if using IntegratedSecurity. | |
| Passfile | Path to a PostgreSQL password file (PGPASSFILE), from which the password is taken. | |
## Security and Encryption
View
@@ -4,7 +4,7 @@
The simplest way to log into PostgreSQL is by specifying a `Username` and a `Password` in your connection string. Depending on how your PostgreSQL is configured (in the `pg_hba.conf` file), Npgsql will send the password in MD5 or in cleartext (not recommended).
If only a `Password` is not specified, Npgsql will look for the [Password file](https://www.postgresql.org/docs/current/static/libpq-pgpass.html) under the path you provided by specifying `PgPassFile` in your connection string. If both `Password` and `PgPassFile` of the connection string are not specified, Npgsql will look under the path taken from `PGPASSFILE` environment variable of your machine. If Npgsql can not find environment variable with name `PGPASSFILE`, then it will look under the password file's system-dependent default directory which is `$HOME/.pgpass` for Unix and `%APPDATA%\postgresql\pgpass.conf` for Windows.
If a `Password` is not specified and your PostgreSQL is configured to request a password (plain or MD5), Npgsql will look for a [standard PostgreSQL password file](https://www.postgresql.org/docs/current/static/libpq-pgpass.html). If you specify the `Passfile` connection string parameter, the file it specifies will be used. If that parameter isn't defined, Npgsql will look under the path taken from `PGPASSFILE` environment variable. If the environment variable isn't defined, Npgsql will fall back to the system-dependent default directory which is `$HOME/.pgpass` for Unix and `%APPDATA%\postgresql\pgpass.conf` for Windows.
For documentation about all auth methods supported by PostgreSQL, [see this page](http://www.postgresql.org/docs/current/static/auth-methods.html). Note that Npgsql supports Unix-domain sockets (auth method `local`), simply set your `Host` parameter to the absolute path of your PostgreSQL socket directory, as configred in your `postgresql.conf`.
@@ -383,24 +383,24 @@ public string Password
string _password;
/// <summary>
/// Path to a PostgreSQL Password File (PGPASSFILE), from which the password would be taken.
/// Path to a PostgreSQL password file (PGPASSFILE), from which the password would be taken.
/// </summary>
[Category("Connection")]
[Description("Path to a PostgreSQL Password File (PGPASSFILE), from which the password would be taken.")]
[DisplayName("PG Pass File")]
[Description("Path to a PostgreSQL password file (PGPASSFILE), from which the password would be taken.")]
[DisplayName("Passfile")]
[NpgsqlConnectionStringProperty]
[CanBeNull]
public string PgPassFile
public string Passfile
{
get => _pgPassFile;
get => _passfile;
set
{
_pgPassFile = value;
SetValue(nameof(PgPassFile), value);
_passfile = value;
SetValue(nameof(Passfile), value);
}
}
string _pgPassFile;
string _passfile;
/// <summary>
/// The optional application name parameter to be sent to the backend during connection initiation.
View
@@ -27,13 +27,13 @@ class PgPassFile
/// Initializes a new instance of the <see cref="PgPassFile"/> class
/// </summary>
/// <param name="fileName"></param>
private PgPassFile(string fileName)
PgPassFile(string fileName)
{
FileName = fileName;
}
[CanBeNull]
internal static PgPassFile Load(string pgPassFile)
internal static PgPassFile Load([CanBeNull] string pgPassFile)
{
var path = pgPassFile ?? GetSystemPgPassFilePath();
return path == null || !File.Exists(path) ? null : new PgPassFile(path);

0 comments on commit d6a7960

Please sign in to comment.