Class OnePassword
Wraps the 1Password CLI.
Namespace: Neon.Deployment
Assembly: Neon.Deployment.dll
Syntax
public static class OnePassword
Properties
CliConfigRequired
Returns true if the 1Password CLI needs to be configured by
setting the OP_DEVICE environment variable.
note
The CLI requires OP_DEVICE to be set when the 1Password application is not installed on the current machine.
Declaration
public static bool CliConfigRequired { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Signedin
Returns true if the class is signed-in.
Declaration
public static bool Signedin { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Methods
CheckInstallation()
This class requires that a op.exe v1 client be installed and if the 1Password app is installed that it be version 8.0 or greater.
Declaration
public static void CheckInstallation()
Exceptions
| Type | Condition |
|---|---|
| NotSupportedException | Thrown when any of the checks failed. |
Configure(string, string, string, string, string)
Configures and signs into 1Password for the first time on a machine. This must be called once before Signin(string, string, string) will work.
Declaration
public static void Configure(string signinAddress, string account, string secretKey, string masterPassword, string defaultVault)
Parameters
| Type | Name | Description |
|---|---|---|
| string | signinAddress | Specifies the 1Password signin address. |
| string | account | Specifies the 1Password shorthand name to use for the account (e.g. "sally@neonforge.com"). |
| string | secretKey | The 1Password secret key for the account. |
| string | masterPassword | Specified the master 1Password. |
| string | defaultVault | Specifies the default 1Password vault. |
Remarks
Typically, you'll first call Configure(string, string, string, string, string) once for a workstation to configure the signin address and 1Password secret key during manual configuration. The account shorthand name used for that operation can then be used thereafter for calls to Signin(string, string, string) which don't require the additional information.
This two-stage process enhances security because both the master password and secret key are required to authenticate and the only time the secret key will need to be presented for the full login which will typically done manually once. 1Password securely stores the secret key on the workstation and it will never need to be present as plaintext again on the machine.
GetSecretPassword(string, string)
Returns a named password from the current user's standard 1Password vault like user-sally by default or a custom named vault.
Declaration
public static string GetSecretPassword(string name, string vault = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The password name with optional property. |
| string | vault | Optionally specifies a specific vault. |
Returns
| Type | Description |
|---|---|
| string | The requested password (from the password's [password] field). |
Remarks
The name parameter may optionally specify the desired
1Password property to override the default "password" for this
method. Properties are specified like:
Exceptions
| Type | Condition |
|---|---|
| OnePasswordException | Thrown when the requested secret or proerty doesn't exist or for other 1Password related problems. |
GetSecretValue(string, string)
Returns a named value from the current user's standard 1Password vault like user-sally by default or a custom named vault.
Declaration
public static string GetSecretValue(string name, string vault = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The password name with optional property. |
| string | vault | Optionally specifies a specific vault. |
Returns
| Type | Description |
|---|---|
| string | The requested value (from the password's value field). |
Remarks
The name parameter may optionally specify the desired
1Password property to override the default "value" for this
method. Properties are specified like:
Exceptions
| Type | Condition |
|---|---|
| OnePasswordException | Thrown when the requested secret or proerty doesn't exist or for other 1Password related problems. |
Signin(string, string, string)
Signs into 1Password using just the account, master password, and default vault. You'll typically call this rather than Configure(string, string, string, string, string) which also requires the signin address as well as the secret key.
Declaration
public static void Signin(string account, string masterPassword, string defaultVault)
Parameters
| Type | Name | Description |
|---|---|---|
| string | account | The account's shorthand name (e.g. (e.g. "sally@neonforge.com"). |
| string | masterPassword | The master password. |
| string | defaultVault | The default vault. |
Remarks
Typically, you'll first call Configure(string, string, string, string, string) once for a workstation to configure the signin address and 1Password secret key during manual configuration. The account shorthand name used for that operation can then be used thereafter for calls to this method which don't require the additional information.
This two-stage process enhances security because both the master password and secret key are required to authenticate and the only time the secret key will need to be presented for the full login which will typically done manually once. 1Password securely stores the secret key on the workstation and it will never need to be present as plaintext again on the machine.
Signout()
Signs out.
Declaration
public static void Signout()