Download the PHP package tigusigalpa/yandex-lockbox-php without Composer
On this page you can find all versions of the php package tigusigalpa/yandex-lockbox-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tigusigalpa/yandex-lockbox-php
More information about tigusigalpa/yandex-lockbox-php
Files in tigusigalpa/yandex-lockbox-php
Package yandex-lockbox-php
Short Description PHP/Laravel client library for Yandex Lockbox (secrets storage) API.
License MIT
Homepage https://github.com/tigusigalpa/yandex-lockbox-php
Informations about the package yandex-lockbox-php
Yandex Lockbox PHP SDK
π·πΊ Π ΡΡΡΠΊΠ°Ρ Π²Π΅ΡΡΠΈΡ Π΄ΠΎΠΊΡΠΌΠ΅Π½ΡΠ°ΡΠΈΠΈ
PHP/Laravel client library for Yandex Lockbox β a secure secrets storage service in Yandex Cloud.
Note: This package uses yandex-cloud-client-php for Yandex Cloud infrastructure management (authentication, organizations, clouds, folders).
π Documentation
- Yandex Lockbox Docs
- Quickstart Guide
- API Reference
- OAuth Token Guide
- API Endpoint:
https://lockbox.api.cloud.yandex.net/lockbox/v1
β¨ Features
- β Full Yandex Lockbox API support
- β Automatic IAM token generation from OAuth token
- β Cloud infrastructure management via yandex-cloud-client-php
- β Async operation handling (wait for operations to complete)
- β Folder permissions management (list/assign access bindings)
- β PHP 8.0+ with strict types
- β Laravel 8-12 integration (service provider, facade, config)
- β Extensible token provider interface
- β Typed exceptions for better error handling
- β PSR-3 logger support
- β Comprehensive test coverage
π¦ Installation
Development (path repository)
For mono-repo development, add to your root composer.json:
Then run:
βοΈ Configuration (Laravel)
Publish the configuration file:
Add environment variables to your .env:
π Authorization & API Connection Guide
Step 1: Getting OAuth Token
Documentation: OAuth Token Guide
Get token via OAuth request:
- Open the URL above in your browser
- Authorize the application
- Copy the OAuth token from the response URL (format:
y0_...,y1_...,y2_...,y3_...) - Add token to
.env(Laravel):
Or pass directly to OAuthTokenProvider:
Step 2: Getting IAM Token (Optional)
Documentation: How to get IAM token
IAM token is generated automatically from OAuth token. But you can get it manually:
Alternative - using Yandex CLI:
β οΈ Note: IAM tokens expire after 12 hours
Step 3: Getting Cloud ID
Documentation: Retrieves the list of Cloud resources
List all clouds:
Or get first cloud directly:
Step 4: Getting Folder ID
Documentation: Retrieves the list of Folder resources in the specified cloud
List all folders in cloud:
Or get first folder directly:
Step 5: Add permissions to a folder
Documentation: Access management in Yandex Lockbox
You need to get Subject ID (user account ID that you want to assign permissions to) first
Documentation: Subjects that roles are assigned to
Documentation: Retrieves the list of Yandex Passport user accounts
Documentation: lockbox.editor
Documentation: Setting up folder access permissions
Step 6: Working with Yandex Lockbox API
Documentation: Lockbox API, REST: Secret
Now you can use the folder ID to work with secrets:
Handling Asynchronous Operations
Some Yandex Cloud operations (like assignRoleToFolder) are asynchronous and return an operation object with
done=false. You have two options:
Option 1: Wait for completion automatically
Option 2: Poll operation status manually
Managing Folder Permissions
List and manage access bindings (permissions) for folders:
Response structure:
Laravel Facade
Laravel Artisan Commands
π Exception Handling
The library provides specific exceptions for different error types:
π§ͺ Testing
Artisan Commands
lockbox:test - Comprehensive Testing
Runs complete test suite with 8 tests:
Output:
lockbox:list - List Secrets
lockbox:show - Show Secret Details
lockbox:create - Create Secret
lockbox:add-version - Add Version
JSON file format:
lockbox:delete - Delete Secret
Common Testing Scenarios
Scenario 1: First Run
Scenario 2: Create New Secret
Scenario 3: Update Secret
PHPUnit Tests
π API Reference
OAuthTokenManager Methods
Authentication & Token Management
getIamToken(): string- Get IAM token (cached automatically)listClouds(): array- List all cloudsgetFirstCloud(): array- Get first cloudgetFirstCloudId(): string- Get first cloud ID
Folder Management
listFolders(string $cloudId): array- List folders in cloudgetFolder(string $folderId): array- Get folder detailsgetFirstFolder(string $cloudId): array- Get first foldergetFirstFolderId(string $cloudId): string- Get first folder IDgetFirstFolderIdFromFirstCloud(): string- Get first folder ID from first cloudcreateFolder(string $iamToken, string $cloudId, string $name, ?string $description = null): array- Create folder
Access Control (Permissions)
-
assignRoleToFolder(string $iamToken, string $folderId, string $subjectId, string $role = 'lockbox.editor', string $subjectType = 'userAccount', bool $waitForCompletion = false, int $maxWaitSeconds = 60): array -
Assign role to folder
listFolderAccessBindings(string $iamToken, string $folderId, int $pageSize = 100, ?string $pageToken = null): array -
List folder access bindings (paginated)
getAllFolderAccessBindings(string $iamToken, string $folderId): array- Get all folder access bindings ( auto-pagination)
User Management
getUserByLogin(string $login): array- Get full user info by Yandex logingetUserIdByLogin(string $login): string- Get user ID (Subject ID) by Yandex login
Async Operations
-
waitForOperation(string $iamToken, string $operationId, int $maxWaitSeconds = 60, int $pollIntervalSeconds = 2): array -
Wait for operation to complete
getOperation(string $iamToken, string $operationId): array- Get operation status
Client Methods
Secret Management
listSecrets(string $folderId): array- List secrets in foldergetSecret(string $secretId): array- Get secret metadatacreateSecret(array $data): array- Create new secretupdateSecret(string $secretId, array $data): array- Update secretdeleteSecret(string $secretId): void- Delete secret
Version Management
addVersion(string $secretId, array $data): array- Add new version to secretgetPayload(string $secretId, ?string $versionId = null): array- Get secret payload
π Requirements
- PHP 8.0 or higher
- Laravel 8.x - 12.x (optional, for Laravel integration)
- Guzzle HTTP client 7.x or 8.x
π€ Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
π License
This package is open-sourced software licensed under the MIT license.
π€ Author
Igor Sazonov
- GitHub: @tigusigalpa
- Email: [email protected]
π Links
All versions of yandex-lockbox-php with dependencies
guzzlehttp/guzzle Version ^7.0 | ^8.0
psr/log Version ^1.0 | ^2.0 | ^3.0
tigusigalpa/yandex-cloud-client-php Version ^1.0