lockerpm 0.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package lockerpm --version 0.0.1                
NuGet\Install-Package lockerpm -Version 0.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="lockerpm" Version="0.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add lockerpm --version 0.0.1                
#r "nuget: lockerpm, 0.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install lockerpm as a Cake Addin
#addin nuget:?package=lockerpm&version=0.0.1

// Install lockerpm as a Cake Tool
#tool nuget:?package=lockerpm&version=0.0.1                

Locker Secret .NET SDK


The Locker Secret .Net SDK provides convenient access to the Locker Secret API from applications written in the C# language. It includes a pre-defined set of classes for API resources that initialize themselves dynamically from API responses which makes it compatible with a wide range of versions of the Locker Secret API.

The Developer - CyStack

The Locker Secret .NET SDK is developed by CyStack, one of the leading cybersecurity companies in Vietnam. CyStack is a member of Vietnam Information Security Association (VNISA) and Vietnam Association of CyberSecurity Product Development. CyStack is a partner providing security solutions and services for many large domestic and international enterprises.

CyStack’s research has been featured at the world’s top security events such as BlackHat USA (USA), BlackHat Asia (Singapore), T2Fi (Finland), XCon - XFocus (China)... CyStack experts have been honored by global corporations such as Microsoft, Dell, Deloitte, D-link...

Documentation

The documentation will be updated later.

Requirements

  • .NET > 3.+

Installation

Using the [.NET Core command-line interface (CLI) tools][dotnet-core-cli-tools]:

dotnet add package lockerpm

Using the [NuGet Command Line Interface (CLI)][nuget-cli]:

nuget install lockerpm

Using the [Package Manager Console][package-manager-console]:

Install-Package lockerpm

From within Visual Studio:

  1. Open the Solution Explorer.
  2. Right-click on a project within your solution.
  3. Click on Manage NuGet Packages...
  4. Click on the Browse tab and search for "Locker.net".
  5. Click on the Locker package, select the appropriate version in the right-tab and click Install.

Usages

Set up access key

The SDK needs to be configured with your access key which is available in your Locker Secret Dashboard. Initialize the access_key_id and access_key_secret to its value. You also need to set api_base value (default is https://secrets-core.locker.io).

If you need to set your custom headers, you also need to set headers value in the options param:

using Locker;


string accessKeyId = "YOUR_ACCESS_KEY_ID";
string accessKeySecret = "YOUR_ACCESS_KEY_SECRET";
string apiBase = "YOUR_API_BASE";
Dictionary<string, string> headers = new Dictionary<string, string>()
{
    { "CF-Access-Client-Id", "YOUR_CF_ACCESS_CLIENT_ID" },
    { "CF-Access-Client-Secret", "YOUR_CF_ACCESS_CLIENT_SECRET" }
};
LockerConfiguration.Instance.Init(
    accessKeyId: accessKeyId,
    accessKeySecret: accessKeySecret,
    apiBase: apiBase,
    headers: headers
);

// setting by .env file
LockerConfiguration.Instance.Init(
    envPath: "YOUR_ENV_FILE_PATH"
);

Per-request configuration

All of the service methods accept an optional RequestOptions object. This is used if you want to pass the access key, headers on each method, or you want set type of return value (default type is string, if you want type of object use IsJson=true)

var requestOptions = new RequestOptions();
requestOptions.AccessKeyId = "ACCESS KEY ID";
requestOptions.AccessKeySecret = "ACCESS KEY SECRET";
requestOptions.ApiBase = "API BASE";
requestOptions.IsJson = true;

Now, you can use SDK to get or set values:

List secrets

var service = new SecretService();
var secrets = service.List();

Get a secret value by secret key

// Get a secret value by secret key.
// If they Key does not exist, SDK will return the defaultValue
var secretValue = service.GetSecret(
    name: "REDIS_CONNECTION",
    defaultValue: "Default Value"
    )
Console.WriteLine(secretValue);

// Get a secret value by secret key and specific environment name.
// If the Key does not exist, SDK will return the defaultValue
secretValue = service.GetSecret(
    name: "REDIS_CONNECTION",
    environmentName: "staging",
    defaultValue: "Default Value"
    )
Console.WriteLine(secretValue);

// Get a secret value by secret key.
// If they Key does not exist, SDK will throw exception
var options = new SecretRetrieveOptions();
var requestOptions = new RequestOptions();
var secretValue = service.Get(
    name: "REDIS_CONNECTION",
    retrieveOptions: options,
    requestOptions:requestOptions
    )
Console.WriteLine(secretValue);

// Get a secret value by secret key and specific environment name.
// If the Key does not exist, SDK will throw exception
var options = new SecretRetrieveOptions();
var requestOptions = new RequestOptions();
var secretValue = service.Get(
    name: "REDIS_CONNECTION",
    environmentName: "staging",
    retrieveOptions: options,
    requestOptions:requestOptions
    )
Console.WriteLine(secretValue);

Create new secret


var service = new SecretService();
var option = new SecretCreateOptions
   {
       Key = "YOUR_NEW_SECRET_KEY",
       Value = "YOUR_NEW_SECRET_VALUE",
   };
var newSecret = service.Create(option);

Update secret


var service = new SecretService();
var option = new SecretUpdateOptions
   {
       Key = "YOUR_UPDATE_SECRET_KEY",
       Value = "YOUR_UPDATED_SECRET_VALUE",
   };

// Update a secret value by secret key
var updated_secret = service.Modify(
    name: "YOUR_SECRET_KEY",
    updateOptions:option
    );

// Update a secret value by secret key and a specific environment name
var updated_secret = service.Modify(
    name: "YOUR_SECRET_KEY",
    environmentName: "YOUR_ENV_NAME",
    updateOptions:option
    );

List environments

var service = new EnvironmentService();
var environments = service.List();

Get an environment object by name


var service = new EnvironmentService();
var environment = Service.Get(name: "YOUR_ENV_NAME");
Console.WriteLine(environment);

Create new environment


var service = new EnvironmentService();
var option = new EnvironmentCreateOptions()
   {
       Name = "YOUR_NEW_ENV_NAME",
       ExternalUrl = "YOUR_NEW_ENV_EXTERTAL_URL",
       Description = "YOUR_NEW_ENV_DESCRIPTION"
   };
var newEnv = service.Create(option);

Update an environment by name

var service = new EnvironmentService();
var option = new EnvironmentUpdateOptions()
   {
       Name = "YOUR_UPDATE_ENV_NAME",
       ExternalUrl = "YOUR_UPDATE_EXTERNAL_URL"
   };
var updatedEnv = service.Modify(
    name: "YOUR_ENV_NAME,
    updateOptions:opton
    );

Examples

See the examples' folder.

Development

Run all tests from the src/LockerTests directory:

dotnet test

Run some tests, filtering by name:

dotnet test --filter FullyQualifiedName~SecretServiceTest

The library uses [dotnet-format][dotnet-format] for code formatting. Code must be formatted before PRs are submitted, otherwise CI will fail. Run the formatter with:

dotnet format src/Locker.sln

Reporting security issues

We take the security and our users' trust very seriously. If you found a security issue in Locker SDK .NET, please report the issue by contacting us at contact@locker.io. Do not file an issue on the tracker.

Contributing

Please check CONTRIBUTING before making a contribution.

Help and media

License

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 is compatible. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.0.6 119 5/10/2024
0.0.5 844 3/26/2024
0.0.4 1,605 1/30/2024
0.0.3 1,507 1/23/2024
0.0.2 2,631 12/4/2023
0.0.1 2,527 9/22/2023