lockerpm 0.0.1
See the version list below for details.
dotnet add package lockerpm --version 0.0.1
NuGet\Install-Package lockerpm -Version 0.0.1
<PackageReference Include="lockerpm" Version="0.0.1" />
paket add lockerpm --version 0.0.1
#r "nuget: lockerpm, 0.0.1"
// 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:
- Open the Solution Explorer.
- Right-click on a project within your solution.
- Click on Manage NuGet Packages...
- Click on the Browse tab and search for "Locker.net".
- 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
Community Q&A: https://forum.locker.io
News: https://locker.io/blog
License
Product | Versions 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. |
-
.NETCoreApp 3.1
- DotNetEnv (>= 2.5.0)
- Newtonsoft.Json (>= 12.0.3)
- System.Configuration.ConfigurationManager (>= 4.7.0)
- System.IO.FileSystem.AccessControl (>= 5.0.0)
-
.NETFramework 4.6.1
- DotNetEnv (>= 2.5.0)
- Microsoft.Bcl.AsyncInterfaces (>= 1.1.0)
- Newtonsoft.Json (>= 9.0.1)
- System.IO.FileSystem.AccessControl (>= 5.0.0)
- System.Runtime.InteropServices.RuntimeInformation (>= 4.3.0)
-
.NETStandard 2.0
- DotNetEnv (>= 2.5.0)
- Microsoft.Bcl.AsyncInterfaces (>= 1.1.0)
- Newtonsoft.Json (>= 11.0.1)
- System.Configuration.ConfigurationManager (>= 4.5.0)
- System.IO.FileSystem.AccessControl (>= 5.0.0)
-
net5.0
- DotNetEnv (>= 2.5.0)
- Newtonsoft.Json (>= 12.0.3)
- System.IO.FileSystem.AccessControl (>= 5.0.0)
-
net6.0
- DotNetEnv (>= 2.5.0)
- Newtonsoft.Json (>= 12.0.3)
- System.Configuration.ConfigurationManager (>= 6.0.0)
- System.IO.FileSystem.AccessControl (>= 5.0.0)
-
net7.0
- DotNetEnv (>= 2.5.0)
- Newtonsoft.Json (>= 12.0.3)
- System.Configuration.ConfigurationManager (>= 7.0.0)
- System.IO.FileSystem.AccessControl (>= 5.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.