-
Notifications
You must be signed in to change notification settings - Fork 12
Improving README and adding workflow to test the library #31
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
Merged
Merged
Changes from 14 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
3e17dc2
Updated version for fusionauth-php-client to 1.47.0
robotdan 5ab73df
Updated version for fusionauth-php-client to 1.47.1
robotdan 8204af8
Updated version for fusionauth-php-client to 1.48.0
robotdan 1044d28
Updated version for fusionauth-php-client to 1.48.0-EAP.20231021
robotdan 22016f5
Updated version for fusionauth-php-client to 1.48.0
robotdan b757fc1
Updated version for fusionauth-php-client to 1.48.1
robotdan 6e7e951
Updated version for fusionauth-php-client to 1.48.0
robotdan e94512a
Updated version for fusionauth-php-client to 1.48.1
robotdan 28ed0da
Updated version for fusionauth-php-client to 1.48.2
robotdan 92f047b
Updated version for fusionauth-php-client to 1.49.0
robotdan b15684e
:sparkles: Standardizing README and creating a GitHub Action to test …
vcampitelli b2afc66
:green_heart: refs #31 Setting up FusionAuth instance in the workflow
vcampitelli 9e6a74d
:green_heart: refs #31 Trying to fix CI
vcampitelli 57be161
:green_heart: refs #31 Waiting for the docker container to spin up
vcampitelli 045738e
Apply suggestions from code review
vcampitelli e5be6e3
:memo: refs #31 Several changes to the README file
vcampitelli 4a4943e
:twisted_rightwards_arrows: refs #31 Merging master
vcampitelli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
DATABASE_USERNAME=fusionauth | ||
DATABASE_PASSWORD=hkaLBM3RVnyYeYeqE3WI1w2e4Avpy0Wd5O3s3 | ||
FUSIONAUTH_APP_MEMORY=256M | ||
FUSIONAUTH_APP_RUNTIME_MODE=development | ||
POSTGRES_USER=postgres | ||
POSTGRES_PASSWORD=postgres |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
version: '3' | ||
|
||
services: | ||
db: | ||
vcampitelli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
image: postgres:16.0-alpine | ||
environment: | ||
PGDATA: /var/lib/postgresql/data/pgdata | ||
POSTGRES_USER: ${POSTGRES_USER} | ||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} | ||
healthcheck: | ||
test: [ "CMD-SHELL", "pg_isready -U postgres" ] | ||
interval: 5s | ||
timeout: 5s | ||
retries: 5 | ||
networks: | ||
- db_net | ||
restart: unless-stopped | ||
volumes: | ||
- db_data:/var/lib/postgresql/data | ||
|
||
fusionauth: | ||
image: fusionauth/fusionauth-app:latest | ||
depends_on: | ||
db: | ||
condition: service_healthy | ||
environment: | ||
DATABASE_URL: jdbc:postgresql://db:5432/fusionauth | ||
DATABASE_ROOT_USERNAME: ${POSTGRES_USER} | ||
DATABASE_ROOT_PASSWORD: ${POSTGRES_PASSWORD} | ||
DATABASE_USERNAME: ${DATABASE_USERNAME} | ||
DATABASE_PASSWORD: ${DATABASE_PASSWORD} | ||
FUSIONAUTH_APP_MEMORY: ${FUSIONAUTH_APP_MEMORY} | ||
FUSIONAUTH_APP_RUNTIME_MODE: ${FUSIONAUTH_APP_RUNTIME_MODE} | ||
FUSIONAUTH_APP_SILENT_MODE: true | ||
FUSIONAUTH_APP_URL: http://fusionauth:9011 | ||
FUSIONAUTH_APP_KICKSTART_FILE: /usr/local/fusionauth/kickstart.json | ||
SEARCH_TYPE: database | ||
networks: | ||
- db_net | ||
restart: unless-stopped | ||
ports: | ||
- 9011:9011 | ||
volumes: | ||
- fusionauth_config:/usr/local/fusionauth/config | ||
- ./kickstart.json:/usr/local/fusionauth/kickstart.json | ||
|
||
networks: | ||
db_net: | ||
driver: bridge | ||
|
||
volumes: | ||
db_data: | ||
fusionauth_config: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"variables": { | ||
"applicationid": "e9fdb985-9173-4e01-9d73-ac2d60d1dc8e", | ||
"apiKey": "72a8c464b86c3c9098c33da73f471b8a0352f6e14087ddc3", | ||
"asymmetricKeyId": "#{UUID()}", | ||
"defaultTenantId": "d7d09513-a3f5-401c-9685-34ab6c552453", | ||
"adminEmail": "[email protected]", | ||
"adminPassword": "password" | ||
}, | ||
"apiKeys": [ | ||
{ | ||
"key": "#{apiKey}", | ||
"description": "Unrestricted API key" | ||
} | ||
], | ||
"requests": [ | ||
{ | ||
"method": "POST", | ||
"url": "/api/key/generate/#{asymmetricKeyId}", | ||
"tenantId": "#{defaultTenantId}", | ||
"body": { | ||
"key": { | ||
"algorithm": "RS256", | ||
"name": "For GitHub Actions", | ||
"length": 2048 | ||
} | ||
} | ||
}, | ||
{ | ||
"method": "POST", | ||
"url": "/api/user/registration", | ||
"body": { | ||
"user": { | ||
"email": "#{adminEmail}", | ||
"password": "#{adminPassword}" | ||
}, | ||
"registration": { | ||
"applicationId": "#{FUSIONAUTH_APPLICATION_ID}", | ||
"roles": [ | ||
"admin" | ||
] | ||
} | ||
} | ||
} | ||
] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Test Library | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
pull_request: | ||
branches: [ "master" ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up FusionAuth | ||
working-directory: .github/fusionauth | ||
run: docker compose up -d | ||
|
||
- name: Validate composer.json and composer.lock | ||
run: composer validate | ||
|
||
- name: Cache Composer packages | ||
id: composer-cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: vendor | ||
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-php- | ||
|
||
- name: Install dependencies | ||
run: composer install --prefer-dist --no-progress | ||
|
||
- name: Waiting for FusionAuth App | ||
run: timeout 30 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:9011)" != "200" ]]; do sleep 5; done' || false | ||
|
||
- name: Run test suite | ||
run: composer run test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,140 @@ | ||
## FusionAuth PHP Client  | ||
If you're integrating FusionAuth with a PHP application, this library will speed up your development time. | ||
# FusionAuth PHP Client  | ||
|
||
For additional information and documentation on FusionAuth refer to [https://fusionauth.io](https://fusionauth.io). | ||
|
||
### Example Usage | ||
## Intro | ||
|
||
#### Install the Code | ||
If you're integrating FusionAuth with a PHP application, this library will speed up your development time. Please also make sure to check our [SDK Usage Suggestions page](https://fusionauth.io/docs/sdks/#usage-suggestions). | ||
|
||
To use the client library on your project simply copy the PHP source files from the `src` directory to your project or the following | ||
Composer package. | ||
For additional information and documentation on FusionAuth refer to [https://fusionauth.io](https://fusionauth.io). | ||
|
||
Packagist | ||
## Install | ||
|
||
* https://packagist.org/packages/fusionauth/fusionauth-client | ||
The most preferred way to use the client library is to install the [`fusionauth/fusionauth-client`](https://packagist.org/packages/fusionauth/fusionauth-client) package via Composer by running the command below at your project root folder. | ||
|
||
```bash | ||
composer require fusionauth/fusionauth-client | ||
``` | ||
|
||
Include composer autoloader | ||
Then, include the autoloader in your PHP files. | ||
vcampitelli marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
```PHP | ||
```php | ||
require __DIR__ . '/vendor/autoload.php'; | ||
``` | ||
|
||
#### Create the Client | ||
## Questions and support | ||
|
||
If you have a question or support issue regarding this client library, we'd love to hear from you. | ||
|
||
If you have a paid edition with support included, please [open a ticket in your account portal](https://account.fusionauth.io/account/support/). Learn more about [paid editions here](https://fusionauth.io/pricing). | ||
vcampitelli marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
Otherwise, please [post your question in the community forum](https://fusionauth.io/community/forum/). | ||
vcampitelli marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
## Examples | ||
vcampitelli marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
```PHP | ||
### Create the Client | ||
|
||
```php | ||
$apiKey = "5a826da2-1e3a-49df-85ba-cd88575e4e9d"; | ||
vcampitelli marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
$client = new FusionAuth\FusionAuthClient($apiKey, "http://localhost:9011"); | ||
vcampitelli marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
``` | ||
|
||
#### Login a user | ||
### Create an Application | ||
|
||
```php | ||
$result = $client->createApplication( | ||
applicationId: null, // Leave this empty to automatically generate the UUID | ||
request: [ | ||
'application' => [ | ||
'name' => 'ChangeBank', | ||
], | ||
], | ||
); | ||
if (!$result->wasSuccessful()) { | ||
// Check HTTP Code at $result->status | ||
// and error message at $result->errorResponse | ||
} | ||
|
||
// Hooray! Success | ||
var_dump($result->successResponse->application); | ||
``` | ||
|
||
```PHP | ||
$applicationId = "68364852-7a38-4e15-8c48-394eceafa601"; | ||
### Adding Roles to an Existing Application | ||
|
||
```php | ||
$result = $client->createApplicationRole( | ||
applicationId: 'd564255e-f767-466b-860d-6dcb63afe4cc', // Existing Application Id | ||
roleId: null, // Leave this empty to automatically generate the UUID | ||
request: [ | ||
'role' => [ | ||
'name' => 'customer', | ||
'description' => 'Default role for regular customers', | ||
'isDefault' => true, | ||
], | ||
], | ||
); | ||
|
||
$request = array(); | ||
$request["applicationId"] = $applicationId; | ||
$request["loginId"] = "[email protected]"; | ||
$request["password"] = "abc123"; | ||
$result = $client->login($request); | ||
if (!$result->wasSuccessful()) { | ||
// Error | ||
// Check HTTP Code at $result->status | ||
vcampitelli marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
// and error message at $result->errorResponse | ||
} | ||
|
||
// Hooray! Success | ||
var_dump($result->successResponse->role); | ||
``` | ||
|
||
## Questions and support | ||
### Retrieve Application Details | ||
|
||
If you have a question or support issue regarding this client library, we'd love to hear from you. | ||
```php | ||
$result = $client->retrieveApplication( | ||
applicationId: 'd564255e-f767-466b-860d-6dcb63afe4cc', | ||
); | ||
|
||
If you have a paid edition with support included, please [open a ticket in your account portal](https://account.fusionauth.io/account/support/). Learn more about [paid editions here](https://fusionauth.io/pricing). | ||
if (!$result->wasSuccessful()) { | ||
// Check HTTP Code at $result->status | ||
// and error message at $result->errorResponse | ||
} | ||
|
||
Otherwise, please [post your question in the community forum](https://fusionauth.io/community/forum/). | ||
// Hooray! Success | ||
var_dump($result->successResponse->application); | ||
``` | ||
|
||
### Delete an Application | ||
|
||
```php | ||
$result = $client->deleteApplication( | ||
applicationId: 'd564255e-f767-466b-860d-6dcb63afe4cc', | ||
); | ||
|
||
if (!$result->wasSuccessful()) { | ||
// Check HTTP Code at $result->status | ||
// and error message at $result->errorResponse | ||
} | ||
|
||
// Hooray! Success | ||
// Note that $result->successResponse will be empty | ||
``` | ||
|
||
### Lock a User | ||
|
||
```php | ||
$result = $client->deactivateUser( | ||
'fa0bc822-793e-45ee-a7f4-04bfb6a28199', | ||
); | ||
|
||
if (!$result->wasSuccessful()) { | ||
// Check HTTP Code at $result->status | ||
// and error message at $result->errorResponse | ||
} | ||
|
||
// Hooray! Success | ||
``` | ||
vcampitelli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
vcampitelli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
## Contributing | ||
|
||
Bug reports and pull requests are welcome on GitHub at https://github.com/FusionAuth/fusionauth-php-client. | ||
|
||
Note: if you want to change the `FusionAuthClient` class, you have to do it on the [FusionAuth Client Builder repository](https://github.com/FusionAuth/fusionauth-client-builder/blob/master/src/main/client/php.client.ftl), which is responsible for generating all client libraries we support. | ||
|
||
## License | ||
|
||
This code is available as open source under the terms of the [Apache v2.0 License](https://opensource.org/licenses/Apache-2.0). | ||
This code is available as open source under the terms of the [Apache v2.0 License](https://opensource.org/blog/license/apache-2-0). | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.