PHP code example of hwacom / client-sso
1. Go to this page and download the library: Download hwacom/client-sso library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
hwacom / client-sso example snippets
\Hwacom\SSO\SSOServiceProvider::class,
'sso_enable' => env('SSO_ENABLE',false),
'client_secret' => env("SSO_CLIENT_SECRET"),
'callback' => env("SSO_CLIENT_CALLBACK"),
'sso_host' => env("SSO_HOST")
SSO_ENABLE = true
SSO_HOST = http://test.eip.hwacom.com:8000
SSO_CLIENT_SECRET = ELg5TA5b5JTEJUCdDGoRo0mZIKQe1EuoF8W6ytvP
SSO_CLIENT_CALLBACK = http://test.crm.hwacom.com:8080/callback
\Hwacom\ClientSso\Middleware\SSOAuthenticated::class,
bash
php artisan vendor:publish
/**
* 登入頁面置換,需自行寫入LoginController中
* Laravel7 Function Name 改為 showLoginForm
*/
public function create()
{
if (config('sso.sso_enable') === true ) {
setcookie("callback", config('sso.callback'), 0, "/", '.hwacom.com');
return redirect(config("sso.sso_host") . "/google/auth");
}
return view('auth.login');
}
/**
* 登出用需自行寫入LoginController中
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
*/
public function destroy(Request $request)
{
if (config('sso.sso_enable') === true ) {
setcookie("token", "", time() - 3600, '/', '.hwacom.com');
}
Auth::guard('web')->logout();
$request->session()->invalidate();
$request->session()->regenerateToken();
return redirect(config("sso.sso_host"));
}