Skip to content

Latest commit

Β 

History

37 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

JeppeStaerk.OnePasswordConnect

Production-ready .NET SDK for 1Password Connect API

NuGet .NET License: MIT

Strongly-typed β€’ Fully asynchronous β€’ Built for dependency injection


Why This SDK?

Stop fighting with REST APIs. This SDK transforms the 1Password Connect API into idiomatic, type-safe C# that feels natural in modern .NET applications.

Built for Production

  • πŸ›‘οΈ Resilient by Default - Automatic retries, circuit breakers, and configurable timeouts keep your app running when networks fail
  • πŸ”’ Security First - Never logs secrets, supports HTTPS, integrates with your existing security infrastructure
  • πŸ“Š Observable - Structured logging with Microsoft.Extensions.Logging shows exactly what's happening
  • βœ… Type-Safe - Full IntelliSense support with strongly-typed models matching the 1Password API
  • ⚑ Performance-Focused - Async/await throughout, stream-based file downloads, efficient memory usage

Developer Experience

// One line to configure
builder.Services.AddOnePasswordConnect(
    baseUrl: "http://localhost:8080",
    apiToken: builder.Configuration["OnePassword:ApiToken"]!
);

// Inject and use anywhere
public class MyService
{
    public MyService(OnePasswordConnectClient client) => _client = client;

    public async Task<string> GetDatabasePassword()
    {
        var item = await _client.Items.GetVaultItemByIdAsync("vault-id", "item-id");
        return item.Fields?.First(f => f.Purpose == FieldPurpose.PASSWORD)?.Value ?? "";
    }
}

Quick Start

Installation

dotnet add package JeppeStaerk.OnePasswordConnect.Sdk

Basic Setup

using JeppeStaerk.OnePasswordConnect.Sdk.Extensions;

// In Program.cs
builder.Services.AddOnePasswordConnect(options =>
{
    options.BaseUrl = "http://localhost:8080";
    options.ApiToken = builder.Configuration["OnePassword:ApiToken"]!;

    // Optional: Fine-tune resilience
    options.RetryCount = 3;
    options.CircuitBreakerFailureThreshold = 5;
    options.TimeoutSeconds = 30;
});

Use It Anywhere

public class SecretService
{
    private readonly OnePasswordConnectClient _client;

    public SecretService(OnePasswordConnectClient client) => _client = client;

    public async Task<string> GetApiKey(string vaultId, string itemId)
    {
        var item = await _client.Items.GetVaultItemByIdAsync(vaultId, itemId);
        var apiKeyField = item.Fields?.FirstOrDefault(f => f.Label == "api_key");
        return apiKeyField?.Value ?? throw new Exception("API key not found");
    }
}

What's Included?

Feature Status
Vaults - List, filter, retrieve βœ…
Items - Full CRUD + JSON Patch βœ…
Files - Download (bytes & streams) βœ…
Activity Logs - Audit API usage βœ…
Health Checks - Monitor server status βœ…
Resilience - Retry + Circuit Breaker βœ…
Logging - Structured Microsoft.Extensions.Logging βœ…
Security - No secrets in logs, HTTPS support βœ…

Documentation

Get Started:

Production Deployment:

Reference:

Requirements

  • .NET Standard 2.1 or .NET 10.0+
    • Works with .NET Core 3.0+, .NET 5+, .NET 6+, .NET 7+, .NET 8+, .NET 9+, .NET 10+
    • Also compatible with .NET Framework 4.6.2+ (via .NET Standard 2.1)
  • 1Password Connect Server (v1.8.1)
  • Microsoft.Extensions.DependencyInjection (built-in with ASP.NET Core)

Features at a Glance

🎯 Strongly Typed Everything

Work with real C# types, not magic strings:

var newItem = new FullItem
{
    Category = ItemCategory.LOGIN,
    Fields = new List<Field>
    {
        new Field
        {
            Type = FieldType.CONCEALED,
            Purpose = FieldPurpose.PASSWORD,
            Value = "secure-password"
        }
    }
};

πŸ”„ Automatic Resilience

The SDK automatically handles transient failures:

  • Retries with exponential backoff (2s, 4s, 8s)
  • Circuit breaker protects failing servers
  • Configurable timeouts prevent hung requests
  • All configurable to match your needs

πŸ“ Built-in Logging

See exactly what's happening:

dbug: GET /v1/vaults/abc123 β†’ 200 OK
warn: Retry attempt 1/3 after 2s (timeout)
fail: Circuit breaker opened for 30s (5 consecutive failures)
info: Circuit breaker reset - connection restored

πŸ” Security by Design

  • βœ… Never logs request/response bodies
  • βœ… Never logs authorization headers
  • βœ… HTTPS recommended for production
  • βœ… Integrates with secure configuration (Azure Key Vault, etc.)

Version Compatibility

This SDK targets 1Password Connect version:

  • API Version: 1.8.1

Contributing

Contributions are welcome! Please feel free to:

License

MIT License - see LICENSE for details

Resources


Made with ❀️ for the .NET community

About

Strongly-typed .NET SDK for 1Password Connect API. Built-in retries, circuit breakers, and comprehensive logging.

Topics

Resources

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages