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

Chore/update info #59

Merged
merged 2 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 110 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ Want to provide tangible support? Use the following platform to contribute to op
- Patreon https://s.id/hadipatreon
- Saweria https://s.id/hadisaweria

We highly appreciate you sending us a few cups of coffee to accompany us while writing code. Super thanks.
We highly appreciate you sending us a few cups of coffee to accompany us while writing code. Super, thanks.

## Use pro version

We also offer a professional version. We're excited for you to try it out, as it allows us to consistently deliver high-quality software. Don't hesitate to contact us at kanekescom@gmail.com for further information.
We also offer a professional version. We're excited for you to try it out, as it allows us to consistently deliver high-quality software. Feel free to contact us at kanekescom@gmail.com or @achmadhadikurnia (maintainer) for further information.

- Laravel SIASN Referensi Panel
- Laravel SIASN SIMPEG Panel
Expand All @@ -40,48 +40,144 @@ You can publish the config file with:
php artisan vendor:publish --tag="siasn-api-config"
```

Or, all installations can be completed with the install command:
This is the contents of the published config file:

```php
// config/siasn-api.php
<?php

return [

// Supported mode: "production", "training"
'mode' => env('SIASN_MODE', 'training'),

'apim' => [
'production' => [
'url' => 'https://apimws.bkn.go.id/oauth2/token',
'grant_type' => 'client_credentials',
'username' => env('SIASN_APIM_USERNAME'),
'password' => env('SIASN_APIM_PASSWORD'),
],

'training' => [
'url' => 'https://training-apimws.bkn.go.id/oauth2/token',
'grant_type' => 'client_credentials',
'username' => env('TRAINING_SIASN_APIM_USERNAME'),
'password' => env('TRAINING_SIASN_APIM_PASSWORD'),
],
],

'sso' => [
'production' => [
'url' => 'https://sso-siasn.bkn.go.id/auth/realms/public-siasn/protocol/openid-connect/token',
'grant_type' => 'password',
'client_id' => env('SIASN_SSO_CLIENT_ID'),
'username' => env('SIASN_SSO_USERNAME'),
'password' => env('SIASN_SSO_PASSWORD'),
],

'training' => [
'url' => 'https://iam-siasn.bkn.go.id/auth/realms/public-siasn/protocol/openid-connect/token',
'grant_type' => 'password',
'client_id' => env('TRAINING_SIASN_SSO_CLIENT_ID'),
'username' => env('TRAINING_SIASN_SSO_USERNAME'),
'password' => env('TRAINING_SIASN_SSO_PASSWORD'),
],
],

'const' => [
'instansi_id' => env('SIASN_CONST_INSTANSI_ID'),
'satuan_kerja_id' => env('SIASN_CONST_SATUAN_KERJA_ID'),
],

'token_age' => [
'apim' => (int) env('SIASN_APIM_TOKEN_AGE', 3600 - 60),
'sso' => (int) env('SIASN_SSO_TOKEN_AGE', 43200 - 60),
],

'debug' => (bool) env('SIASN_DEBUG', env('APP_DEBUG')),

'enable_ssl_verification' => (bool) env('SIASN_ENABLE_SSL_VERIFICATION', true),

'max_request_attempts' => (int) env('SIASN_REQUEST_ATTEMPTS', 3),

'max_request_wait_attempts' => (int) env('SIASN_REQUEST_WAIT_ATTEMPTS', 30),

'request_timeout' => (int) env('SIASN_REQUEST_TIMEOUT', 60),

];
```

Or, all installations can be completed with the installation command:

```bash
php artisan siasn-api:install
```

## Usage

Get APIM Token
### Token Generator

Generate an APIM Token

```bash
php artisan siasn:apim-token
```

Forget APIM Token
Generate an SSO Token

```bash
php artisan siasn:forget-token
php artisan siasn:sso-token
```

Get data from endpoint
Generate an APIM and SSO Token

```bash
php artisan siasn:get
php artisan siasn:token
```

Post data to endpoint
You can add the `--fresh` option to always request a new token

### Remove Token

Remove an APIM and SSO Token

```bash
php artisan siasn:post
php artisan siasn:forget-token
```

Get SSO Token
### Send Request

Send a GET request to endpoint of SIASN API

```bash
php artisan siasn:sso-token
php artisan siasn:get {endpoint}
```

Forget SSO Token
An example to get the referensi unor

```bash
php artisan siasn:token
php artisan siasn:get https://apimws.bkn.go.id:8243/apisiasn/1.0/referensi/ref-unor
```

Send a POST request to endpoint of SIASN API

```bash
php artisan siasn:post {endpoint}
```

### Using Class

The Siasn class uses the Http class (Illuminate\Support\Facades\Http) from Laravel. So you can use it just like you would use that class.

```php
Siasn::get($endpoint, $params)
```

We added the `withSso()` method for dual authentication purposes required by BKN. So you just need to add this method if needed, making it like the following.

```php
Siasn::withSso()->get($endpoint, $params)
```

## Testing
Expand Down
4 changes: 2 additions & 2 deletions src/Commands/GenerateApimTokenCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
class GenerateApimTokenCommand extends Command
{
protected $signature = 'siasn:apim-token
{--fresh : Always request new token}';
{--fresh : Always request a new token}';

protected $description = 'Generate APIM Token';
protected $description = 'Generate an APIM Token';

public function handle(): int
{
Expand Down
4 changes: 2 additions & 2 deletions src/Commands/GenerateSsoTokenCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
class GenerateSsoTokenCommand extends Command
{
protected $signature = 'siasn:sso-token
{--fresh : Always request new token}';
{--fresh : Always request a new token}';

protected $description = 'Generate SSO Token';
protected $description = 'Generate an SSO Token';

public function handle(): int
{
Expand Down
4 changes: 2 additions & 2 deletions src/Commands/GenerateTokenCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
class GenerateTokenCommand extends Command
{
protected $signature = 'siasn:token
{--fresh : Always request new token}';
{--fresh : Always request a new token}';

protected $description = 'Generate APIM and SSO Token';
protected $description = 'Generate an APIM and SSO Token';

public function handle(): int
{
Expand Down
4 changes: 2 additions & 2 deletions src/Commands/GetRequestEndpointCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
class GetRequestEndpointCommand extends Command
{
protected $signature = 'siasn:get
{endpoint : GET request to endpoint of SIASN API}';
{endpoint : GET a request to endpoint of SIASN API}';

protected $description = 'Send GET request to endpoint of SIASN API';
protected $description = 'Send a GET request to the endpoint of SIASN API';

public function handle(): int
{
Expand Down
4 changes: 2 additions & 2 deletions src/Commands/PostRequestEndpointCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
class PostRequestEndpointCommand extends Command
{
protected $signature = 'siasn:post
{endpoint : POST request to endpoint of SIASN API}';
{endpoint : POST a request to endpoint of SIASN API}';

protected $description = 'Send POST request to endpoint of SIASN API';
protected $description = 'Send a POST request to the endpoint of SIASN API';

public function handle(): int
{
Expand Down