-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kalyan H
committed
Oct 20, 2021
0 parents
commit 15f2b6d
Showing
16 changed files
with
934 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 @@ | ||
/node_modules | ||
/storage/*.key | ||
/vendor | ||
/.idea | ||
/.vagrant | ||
.env |
This file contains 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,4 @@ | ||
language: php | ||
php: | ||
- '7.3' | ||
- '7.4' |
This file contains 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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2017 Crafted Systems <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains 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,76 @@ | ||
# Laravel WSO2 Identity API User | ||
|
||
This is a Laravel library to manage WSO2 IDP users. | ||
|
||
## Installation | ||
|
||
You can install the package via composer: | ||
|
||
``` bash | ||
composer require khbd/laravel-wso2-identity-api-user | ||
``` | ||
The package will register itself automatically. | ||
|
||
Then publish the package configuration file | ||
|
||
```bash | ||
php artisan vendor:publish --provider=Khbd\LaravelWso2IdentityApiUser\IdpServiceProvider | ||
``` | ||
or | ||
```bash | ||
php artisan vendor:publish --provider=Khbd\LaravelWso2IdentityApiUser\IdpServiceProvider --tag="idpuser" | ||
``` | ||
|
||
## Usage | ||
|
||
Check the config file of all variables required, and then | ||
|
||
```php | ||
(new IdpUser())->create(array()); | ||
``` | ||
or using Facade | ||
|
||
```php | ||
IdpUser::create(array()); | ||
``` | ||
|
||
or using helper | ||
|
||
```php | ||
IdpUser()->create(array()); | ||
``` | ||
|
||
## Adding new Gateway | ||
|
||
## .env Config | ||
|
||
Currently Default SMS Gateway is [Bangladesh SMS](http://bangladeshsms.com/) | ||
|
||
So .env config is following - | ||
```bash | ||
DEFAULT_IDP = 'wso2idp' #set default idp | ||
|
||
# add your wso2 idp information | ||
WSO2_IDP_BASE_URL = 'http://wso2.com' | ||
WSO2_IDP_USERNAME = 'admin' | ||
WSO2_IDP_PASSWORD = 'admin' | ||
|
||
IDP_ENABLED = true # true = if you want to enable functionality of idp | ||
IDP_USER_DEBUG = true # true = if you want to save log in file | ||
``` | ||
|
||
## Contributing | ||
|
||
Suggestions, pull requests , bug reporting and code improvements are all welcome. Feel free. | ||
|
||
## TODO | ||
|
||
Write Tests | ||
|
||
## Credits | ||
|
||
- [Kalyan Halder](https://github.com/kalyan312) | ||
|
||
## License | ||
|
||
The MIT License (MIT). Please see [License File](LICENSE) for more information. |
This file contains 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,36 @@ | ||
{ | ||
"name": "khbd/laravel-wso2-identity-api-user", | ||
"description": "Laravel wso2 identity api user is a Laravel Package for WSO2 IDP user", | ||
"license": "MIT", | ||
"type": "library", | ||
"require": { | ||
"php": "^7.2" | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "Kalyan Halder", | ||
"email": "[email protected]", | ||
"homepage": "https://github.com/kalyan312", | ||
"role": "Developer" | ||
} | ||
], | ||
"autoload": { | ||
"psr-4": { | ||
"Khbd\\LaravelWso2IdentityApiUser\\": "src/" | ||
}, | ||
"files": [ | ||
"src/helpers.php" | ||
] | ||
}, | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"IdpUserServiceProvider" | ||
], | ||
"aliases": { | ||
"IdpUser": "Khbd\\LaravelWso2IdentityApiUser\\Facades\\IdpUser" | ||
} | ||
} | ||
}, | ||
"minimum-stability": "dev" | ||
} |
This file contains 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,80 @@ | ||
<?php | ||
|
||
return [ | ||
|
||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Enable IDP | ||
|-------------------------------------------------------------------------- | ||
| | ||
| This value determines that should take sms record in db or not | ||
| You can switch to a different gateway at runtime. | ||
| set value true to Record Log | ||
| | ||
*/ | ||
|
||
'idp_activate' => env('IDP_ENABLED', true), | ||
|
||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Enable debug log | ||
|-------------------------------------------------------------------------- | ||
| | ||
| This value determines that should write log | ||
| set value true to Record Log | ||
| | ||
*/ | ||
|
||
'idp_log' => env('IDP_USER_DEBUG', true), | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Default idp | ||
|-------------------------------------------------------------------------- | ||
| | ||
| This value determines which of the following idp to use. | ||
| You can switch to a different idp at runtime. | ||
| | ||
*/ | ||
|
||
'default' => env('DEFAULT_IDP', 'wso2idp'), | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| List of Gateways | ||
|-------------------------------------------------------------------------- | ||
| | ||
| These are the list of ip to use for this package. | ||
| You can change the name. Then you'll have to change | ||
| it in the map array too. | ||
| | ||
*/ | ||
|
||
'idps' => [ | ||
'wso2idp' => [ | ||
'base_url' => env('WSO2_IDP_BASE_URL'), | ||
'username' => env('WSO2_IDP_USERNAME'), | ||
'password' => env('WSO2_IDP_PASSWORD') | ||
], | ||
], | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Class Maps | ||
|-------------------------------------------------------------------------- | ||
| | ||
| This is the array of Classes that maps to IDP above. | ||
| You can create your own driver if you like and add the | ||
| config in the drivers array and the class to use | ||
| here with the same name. You will have to implement | ||
| Khbd\LaravelWso2IdentityApiUser\Interfaces\IDPInterface in your IDP. | ||
| | ||
*/ | ||
|
||
'map' => [ | ||
'wso2idp' => \Khbd\LaravelWso2IdentityApiUser\Idps\Wso2idp::class | ||
|
||
], | ||
]; |
This file contains 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,51 @@ | ||
<?php | ||
|
||
namespace Khbd\LaravelWso2IdentityApiUser\Console; | ||
|
||
use Illuminate\Console\GeneratorCommand; | ||
|
||
class MakeIdpDriverCommand extends GeneratorCommand | ||
{ | ||
/** | ||
* The console command name. | ||
* | ||
* @var string | ||
*/ | ||
protected $name = 'make:idpdriver'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Create a new idp driver class for the application'; | ||
|
||
/** | ||
* The type of class being generated. | ||
* | ||
* @var string | ||
*/ | ||
protected $type = 'Idp'; | ||
|
||
/** | ||
* Get the stub file for the generator. | ||
* | ||
* @return string | ||
*/ | ||
protected function getStub() | ||
{ | ||
return __DIR__.'/stubs/gateway.stub'; | ||
} | ||
|
||
/** | ||
* Get the default namespace for the class. | ||
* | ||
* @param string $rootNamespace | ||
* | ||
* @return string | ||
*/ | ||
protected function getDefaultNamespace($rootNamespace) | ||
{ | ||
return $rootNamespace.'\Idps'; | ||
} | ||
} |
This file contains 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,108 @@ | ||
<?php | ||
|
||
namespace DummyNamespace; | ||
|
||
use Khbd\LaravelWso2IdentityApiUser\Interfaces\IDPInterface; | ||
use Illuminate\Http\Request; | ||
|
||
class DummyClass implements SMSInterface | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
protected $settings; | ||
|
||
/** | ||
* @var bool | ||
*/ | ||
protected $is_success; | ||
|
||
/** | ||
* @var mixed | ||
*/ | ||
protected $message_id; | ||
|
||
/** | ||
* @var object | ||
*/ | ||
public $data; | ||
|
||
|
||
/** | ||
* @param $settings | ||
* @throws \Exception | ||
*/ | ||
public function __construct($settings) | ||
{ | ||
// initiate settings (username, api_key, etc) | ||
|
||
$this->settings = (object)$settings; | ||
} | ||
|
||
/** | ||
* @param $recipient | ||
* @param $message | ||
* @param null $params | ||
* @return object | ||
*/ | ||
public function send(string $recipient, string $message, $params = null) | ||
{ | ||
// implement the send sms method | ||
|
||
$this->is_success = ''; // define what determines success from the response | ||
$this->message_id = ''; // reference the message id here. auto generate if not available | ||
$arr = [ | ||
'is_success' => '', | ||
'message_id' => '' | ||
// e.t.c | ||
]; // the rest of data that is returned | ||
|
||
$this->data = (object)$arr; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* initialize the is_success parameter | ||
* @return bool | ||
*/ | ||
public function is_successful(): bool | ||
{ | ||
return $this->is_success; | ||
} | ||
|
||
/** | ||
* assign the message ID as received on the response,auto generate if not available | ||
* @return mixed | ||
*/ | ||
public function getMessageID() | ||
{ | ||
return $this->message_id; | ||
} | ||
|
||
/** | ||
* auto generate if not available | ||
*/ | ||
public function getBalance(): float | ||
{ | ||
// implement the get balance method | ||
} | ||
|
||
|
||
/** | ||
* @param Request $request | ||
* @return object | ||
*/ | ||
public function getDeliveryReports(Request $request) | ||
{ | ||
// implement the processing of delivery reports here. POST/PUSH implementation encouraged | ||
|
||
$data = [ | ||
'status' => '',//delivery report status (e.g DeliveredToTerminal,Success,Failed) | ||
'message_id' => '' //the message id for purpose of matching | ||
// e.t.c | ||
]; // the rest of data that is returned | ||
|
||
return (object)$data; | ||
} | ||
} |
Oops, something went wrong.