Laravel WSO2 Identity API User
This is a Laravel library to manage WSO2 IDP users.
Installation
You can install the package via composer:
composer require khbd/laravel-wso2-identity-api-user
The package will register itself automatically.
Then publish the package configuration file
php artisan vendor:publish --provider=Khbd\LaravelWso2IdentityApiUser\IdpServiceProvider
or
php artisan vendor:publish --provider=Khbd\LaravelWso2IdentityApiUser\IdpServiceProvider --tag="idpuser"
Usage
Check the config file of all variables required, and then
(new IdpUser())->create(array());
or using Facade
IdpUser::create(array());
or using helper
IdpUser()->create(array());
Create you SDK
Run this command to create your own sdk class.
php artisan make:idpdriver YourSDKName
Now add the class in config idpUser.php config file.
API references
Here all covered API references
- Get Wso2 IDP User by ID
IdpUser()->setPayload('userID')->userInfo()->get();
or to get only response body
IdpUser()
->use('wso2idp')
->setPayload('userID')
->userInfo()
->onlyBody()
->get();
Here -
use('yourSDK')
optional
set your custom SDK.
onlyBody()
optional
return only response from IDP server/end API
get()
return response as array
asObject()
return response as object
asJson()
return response as json
- Create IDP user and get created user info
$response = IdpUser()->setPayload([
'first_name' => 'Kalyan',
'last_name' => 'Kalyan',
'username' => 'Kalyan4',
'email' => '[email protected]',
'mobile' => '01945602071',
'user_type' => '2',
'active' => true,
'department' => 'Kalyan',
])->create()->get();
- Update User By User ID
you can provide single field or multiple field at the same time
$response = IdpUser()->setPayload([
'id' =>'UserID',
'username' => 'Kalyan3',
'account_status' => 1,
'mobile' => '01945602071'
])->update()->get();
here id
and username
is mendatory. You can provide following field to update & create -
Key | Details |
---|---|
first_name | Update givenName |
last_name | [Update familyName |
Update emails |
|
mobile | Update phoneNumbers |
user_type | Update userType |
account_status | Update accountStatus |
department | Update department |
organization | Update organization |
country | Update country |
password | Update password |
- Delete single/bulk IDP User
$userID = 'ID';
$response = IdpUser()
->use('wso2idp')
->setPayload($userID)
->delete()
->get();
here - $userID
can be single user ID or array of user ID.
Adding new Gateway
.env Config
Currently Default SMS Gateway is Bangladesh SMS
So .env config is following -
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
License
The MIT License (MIT). Please see License File for more information.