Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP SDK implementation #316

Merged
merged 17 commits into from
Dec 1, 2023
Merged

PHP SDK implementation #316

merged 17 commits into from
Dec 1, 2023

Conversation

milost77
Copy link
Contributor

Type of change

Implemented PHP library that wraps native C library and exposed its commands through BitwardenClient class.

- [ ] Bug fix
- [ x] New feature development
- [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc)
- [ ] Build/deploy pipeline (DevOps)
- [ ] Other

Objective

To provide PHP interface for bitwarden c library files by which you can use PHP code to work with Bitwarden API. It implements CRUD requests for projects and secrets.

Code changes

TODO: Updating package repository - will hosted on Packagist.

@milost77 milost77 requested a review from a team as a code owner October 31, 2023 21:47
@bitwarden-bot
Copy link

bitwarden-bot commented Oct 31, 2023

Logo
Checkmarx One – Scan Summary & Details6f2fb8ae-60da-439b-b260-81aa708f8b02

No New Or Fixed Issues Found

.github/workflows/publish-php.yml Outdated Show resolved Hide resolved
* workflow update
languages/php/src/BitwardenSDK.php Outdated Show resolved Hide resolved
languages/php/src/BitwardenSDK.php Outdated Show resolved Hide resolved
languages/php/src/BitwardenSDK.php Outdated Show resolved Hide resolved
languages/php/example.php Outdated Show resolved Hide resolved
languages/php/src/BitwardenSDK.php Outdated Show resolved Hide resolved
languages/php/src/CommandRunner.php Outdated Show resolved Hide resolved
languages/php/src/BitwardenSDK.php Outdated Show resolved Hide resolved
dani-garcia
dani-garcia previously approved these changes Nov 22, 2023
Copy link
Member

@dani-garcia dani-garcia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code changes LGTM

done

- name: Publish version
run: curl -XPOST -H'content-type:application/json' 'https://packagist.org/api/update-package?username=malirobot&apiToken=${{secrets.PACKAGIST_KEY}}' -d'{"repository":{"url":"https://packagist.org/packages/bitwarden/sdk"}}'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mimartin12 Should this be updated with some Bitwarden managed credentials, or do we leave that for after the merge?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What we can do is that I can add someone from Bitwarden as a collaborator on packagist, then the access to the key won't be a problem (it is used in action secrets). The other scenario is to make a completely new package, the only potential problem, one that I haven't thought about before, is that the name of the package is reserved to "bitwarden/sdk", so it would need to be named differently.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can add someone from bitwarden as maintainer and they can afterwards take ownership and remove the old account. That would preserve the package name.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What @Hinton is suggesting sounds like a good way to go about it, especially since you will want to preserve the package name. I am not familiar with Packagist, but it looks like their API tokens are scoped to the user account. That means ${{secrets.PACKAGIST_KEY}} will need to be updated when you do the switch.
image

Copy link
Member

@Hinton Hinton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nits.

.gitignore Outdated Show resolved Hide resolved
languages/php/README.md Outdated Show resolved Hide resolved
languages/php/src/schemas/ApiKeyLoginRequest.php Outdated Show resolved Hide resolved
languages/php/src/schemas/FingerprintRequest.php Outdated Show resolved Hide resolved
languages/php/src/schemas/Kdf.php Outdated Show resolved Hide resolved
languages/php/src/schemas/KdfArgon2id.php Outdated Show resolved Hide resolved
languages/php/src/schemas/KdfPBKDF2.php Outdated Show resolved Hide resolved
languages/php/src/schemas/PasswordLoginRequest.php Outdated Show resolved Hide resolved
languages/php/src/schemas/SyncRequest.php Outdated Show resolved Hide resolved
languages/php/src/schemas/TwoFactorRequest.php Outdated Show resolved Hide resolved
languages/php/src/BitwardenSettings.php Outdated Show resolved Hide resolved
languages/php/src/BitwardenSettings.php Outdated Show resolved Hide resolved
languages/php/src/BitwardenClient.php Show resolved Hide resolved
languages/php/README.md Outdated Show resolved Hide resolved
languages/php/README.md Outdated Show resolved Hide resolved
languages/php/src/BitwardenSettings.php Outdated Show resolved Hide resolved
dani-garcia
dani-garcia previously approved these changes Nov 29, 2023
Hinton
Hinton previously approved these changes Nov 30, 2023
Copy link
Member

@Hinton Hinton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dani-garcia dani-garcia dismissed stale reviews from Hinton and themself via 6e34383 November 30, 2023 18:37
Copy link
Contributor

@mimartin12 mimartin12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Workflow LGTM.

done

- name: Publish version
run: curl -XPOST -H'content-type:application/json' 'https://packagist.org/api/update-package?username=malirobot&apiToken=${{secrets.PACKAGIST_KEY}}' -d'{"repository":{"url":"https://packagist.org/packages/bitwarden/sdk"}}'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What @Hinton is suggesting sounds like a good way to go about it, especially since you will want to preserve the package name. I am not familiar with Packagist, but it looks like their API tokens are scoped to the user account. That means ${{secrets.PACKAGIST_KEY}} will need to be updated when you do the switch.
image

@dani-garcia dani-garcia merged commit e219efa into bitwarden:master Dec 1, 2023
60 of 63 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants