bitwarden/sdk 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

bitwarden/sdk

Composer 安装命令:

composer require bitwarden/sdk

包简介

PHP bindings for interacting with the Bitwarden Secrets Manager. This is a beta release and might be missing some functionality.

README 文档

README

PHP bindings for interacting with the Bitwarden Secrets Manager. This is a beta release and might be missing some functionality. Supported are CRUD operations on project and secret entities.

Installation

Requirements:

  • PHP >= 8.0
  • Composer
  • Bitwarden C libraries which you can generate using BitwardenSDK and following instructions in its readme (requires Rust). https://github.com/bitwarden/sdk If you are not using the standalone version of this library, file will be placed in target/debug folder if you are using from BitwardenSDK repository.
  • Access token for the Bitwarden account

Usage

To interact with the client first you need to obtain the access token from Bitwarden. You can initialize ClientSettings and its setting before passing it to the BitwardenClient.

$client_settings = new \Bitwarden\Sdk\Schemas\ClientSettings()
$client_settings->apiUrl = getenv('API_URL') ?: 'https://api.bitwarden.com';
$client_settings->identityUrl = getenv('IDENTITY_URL') ?: 'https://identity.bitwarden.com';
$client_settings->userAgent = getenv('USER_AGENT') ?: 'SDK';
$client_settings->deviceType = getenv('DEVICE_TYPE') ?: 'SDK';

Authorization can be performed using access token like so:

$access_token = '<you access token here>';
$bitwarden_sdk = new \Bitwarden\Sdk\BitwardenClient($client_settings);
$result = $bitwarden_sdk->authorize($access_token);

After successful authorization you can interact with client to manage your projects and secrets.

// get project
$res = $bitwarden_sdk->client->get("00056058-cc70-4cd2-baea-b0810134a729");
// list projects
$res = $bitwarden_sdk->client->list('5688da1f-cc25-41d7-bb9f-b0740144ef1d');
// create project
$res = $bitwarden_sdk->client->create('php project', '5688da1f-cc25-41d7-bb9f-b0740144ef1d');
// update project
$res = $bitwarden_sdk->client->put('920fe206-ab3b-429d-a4b7-b0ac00e17acf', 'php project awesome', '5688da1f-cc25-41d7-bb9f-b0740144ef1d');
// delete project
$res = $bitwarden_sdk->client->delete(['920fe206-ab3b-429d-a4b7-b0ac00e17acf']);

Similarly, you interact with secrets:

// get secret
$res = $bitwarden_sdk->secrets->get("75d3a7ff-30ed-433a-91aa-b099016e4833");
// list secrets
$res = $bitwarden_sdk->secrets->list("5688da1f-cc25-41d7-bb9f-b0740144ef1d");
// create secret
$res = $bitwarden_sdk->secrets->create("New Key", "hello world", "5688da1f-cc25-41d7-bb9f-b0740144ef1d", ["b23818dd-827b-4a22-b97a-b07e010ae9d4"], "123");
// update secret
$res = $bitwarden_sdk->secrets->update("901d102d-af7d-46a1-99f5-b0a6017e2f07", "hello world 2", "hello", "5688da1f-cc25-41d7-bb9f-b0740144ef1d", ["b23818dd-827b-4a22-b97a-b07e010ae9d4"], "123");
// delete secret
$res = $bitwarden_sdk->secrets->delete(["380b5c30-d8fc-472d-a514-b0ac00f17071"]);

统计信息

  • 总下载量: 182
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2023-11-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固