Laravel
From your Markdown files to a deployed website in few minutes.
Setup
- Install Pintar SSO Helper
composer require banjarmasinkota/pintar-sso
- Run publish vendor
php artisan vendor:publish
- Choose
Banjarmasinkota\PintarSSO\PintarSSOServiceProvider, this should add:
config/pintar_sso.php,routes/sso.php,database/migrations/2024_02_28_035830_create_pintar_accounts_table.php,app/Models/PintarAccount,app/Traits/HasPintarAccount.php, files to your project.
- Add env variable on
.envfile:
✨ Get your CLIENT_ID and CLIENT_SECRET from here https://sso.banjarmasinkota.go.id/app/project
.env
PINTAR_SSO_CLIENT_ID = "YOUR_SSO_CLIENT_ID"
PINTAR_SSO_CLIENT_SECRET = "YOUR_SSO_CLIENT_SECRET"
PINTAR_SSO_POST_LOGIN = "REDIRECT_URL_AFTER_LOGIN" // /app
PINTAR_SSO_POST_BIND = "REDIRECT_URL_AFTER_BIND_ACCOUNT" // /app/profile
Migrations
Run migration command
php artisan migrate
This will add PintarAccounts table, then add HasPintarAccount traits to User Model on app/Models/User.php
app/Models/User.php
use Banjarmasinkota\PintarSSO\Traits\HasPintarAccount; // <-- add this
class User extends Authenticatable
{
use HasPintarAccount; // <-- add this
Routes
Add routes/sso.php routes to your routes/web.php at the end of file:
routes/web.php
require __DIR__.'/sso.php';
Middlewares
Add PintarSSOMiddleware to app/Http/Kernel.php on middlewareGroups web
app/Http/Kernel.php
\Banjarmasinkota\PintarSSO\Middleware\PintarSSOMiddleware::class
Bind account
- To bind Pintar SSO account to your user, create a
buttonorlinkthat redirect to/sso/bind:
<a href="/sso/bind"> Connect to Pintar SSO </a>
Login
- To login using Pintar SSO with user that has already bind Pintar Account, create a
buttonorlinkthat redirect to/sso/login
<a href="/sso/login"> Login with Pintar SSO </a>
Table of Contents