Download the PHP package putheakhem/fsa-sso without Composer

On this page you can find all versions of the php package putheakhem/fsa-sso. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package fsa-sso

Laravel FSA SSO Package

[![Latest Stable Version](https://img.shields.io/packagist/v/putheakhem/fsa-sso.svg?style=flat-square)](https://packagist.org/packages/putheakhem/fsa-sso) [![Total Downloads](https://img.shields.io/packagist/dt/putheakhem/fsa-sso.svg?style=flat-square)](https://packagist.org/packages/putheakhem/fsa-sso)

โš ๏ธ DISCLAIMER: This is an unofficial community package and is not affiliated with, endorsed by, or supported by the official FSA SSO Platform or the Non-Bank Financial Services Authority (FSA). This package is maintained independently. For official support, please contact the FSA SSO Platform directly.

A Laravel package for FSA SSO authentication with support for JWT verification via JWKS, user provisioning, and optional web login flow.


๐Ÿ“‹ What This Package Does


โš™๏ธ Requirements


๐Ÿ“ฆ Installation

The service provider is auto-discovered via Laravel's package discovery.

Publish Config and Migrations

If your app has many packages and tag-based publish does not detect resources, use provider-scoped commands:

The package also registers conventional config and migrations tags for compatibility.


๐Ÿš€ Choose Your Integration Path

This package supports two main integration styles. Start with the one you actually need:

Option A โ€” Web Login for Browser Users

Use this when users click a "Sign in with FSA SSO" button in your Laravel web app and should end up logged into your local web guard session.

You need:

Typical outcome:

Jump to:

Option B โ€” API Authentication for Incoming Bearer Tokens

Use this when another FSA-connected system calls your Laravel API with an existing FSA SSO bearer token and your routes should authenticate with auth:fsa-sso-api.

You need:

Typical outcome:

Jump to:

Optional Add-On โ€” Shared Token Storage

Enable this only if your app needs to store the verified FSA token for later trusted downstream calls.

If you do not need downstream token reuse, leave token storage disabled.


๐ŸŒ .env Configuration

Add these to your .env file:

โœ… FSA_SSO_CLIENT_CODE must exactly match the client code registered in the FSA SSO admin portal.

โœ… Use single backslashes for FSA_SSO_USER_MODEL in .env (example: App\Models\User).


๐Ÿงญ Web Login Quick Start

Minimum setup for browser-based login:

  1. Install the package.
  2. Publish config and migrations.
  3. Set these env values:

  4. Register the exact callback URL in FSA admin:
  1. Add a login link or button to the package route:

That is enough for the package-managed web flow. The package will redirect to FSA, verify the callback token, provision the user, log them into the configured web guard, and redirect them to your intended route.

๐Ÿ”Œ API Auth Quick Start

Minimum setup for protecting API routes that receive FSA SSO bearer tokens:

  1. Install the package.
  2. Publish config and migrations.
  3. Set these env values:

  4. Protect routes with the package guard:

  5. Add optional client-code restriction when needed:

That is enough for the package to validate incoming bearer tokens and resolve a local user for your API routes.


๐Ÿ—„๏ธ User Model โ€” Fillable & Migration

The published migration adds these columns to your users table:

Column Type Notes
sso_id string, unique, nullable Stable FSA sub identifier
sso_provider string, nullable e.g. camdigikey
kyc_level string, nullable e.g. kyc_verified
camdigikey_id string, unique, nullable
nbfs_id string, unique, nullable

Add these columns to your User model's $fillable:

If you enable shared token storage, publish the latest package migration and migrate so the default storage columns are available:

The default migration adds:

Column Type Notes
fsa_sso_access_token text, nullable Raw FSA token, encrypted by the package when enabled
fsa_sso_token_expires_at timestamp, nullable Derived from JWT exp
fsa_sso_token_client_code string, nullable Client code from verified claims
fsa_sso_token_last_used_at timestamp, nullable Updated when the host app marks token usage

If you want different column names, create your own migration and set the token_storage.*_column config values to match.

Migration Ownership Note

This package auto-loads package migrations until matching published copies exist in the host application's database/migrations directory.

Design A: Shared FSA token for trusted downstream resource access

This package now supports an optional Design A integration pattern where a portal such as DPS stores the verified FSA SSO token and later reuses that same token when calling another trusted resource server such as Compendium.

How it works

  1. User authenticates with FSA SSO and the package verifies the returned JWT via JWKS.
  2. The package keeps user identity mapping based on sub, exactly as before.
  3. If token_storage.enabled is true, the package stores the raw token plus metadata on the user record.
  4. Later, the host app can retrieve the stored token and attach it to an outbound request to a trusted downstream portal or service.

Retrieving the stored token

You can retrieve the current authenticated user token:

Or retrieve it for a specific user model:

Token storage config

When encrypted is true, the package uses Laravel encryption before persisting the token. That keeps storage secure even if your User model does not define an encrypted cast for the token column.

API Bearer Authentication

FSA SSO authenticates the user's identity. The consuming Laravel application still owns authorization, roles, policies, and permissions.

The package only owns the fsa-sso-api guard and related middleware. It does not replace or modify a host application's api guard, Laravel Passport configuration, or internal auth:api routes.

Use the new opt-in guard when another FSA system calls your Laravel API with an existing FSA SSO JWT:

The package validates the bearer token through JWKS using EdDSA, resolves the local user from sub, and lets your application keep full control over authorization.

Environment

Auth Modes

jwt is the default mode. It preserves the current behavior:

introspection is opt-in. Use it when the upstream token is opaque or when the upstream claim shape is not a locally verifiable JWT:

For older installs, FSA_SSO_USE_INTROSPECTION=true still maps to introspection mode when FSA_SSO_API_AUTH_MODE is not set.

Debug Logging

When the application is not running in production, auth rejections are logged with a structured reason and a SHA-256 token hash. Production logging stays off unless you opt in:

The package never logs the raw bearer token. Typical reasons include malformed token, unsupported algorithm, JWKS fetch failure, key parse failure, issuer mismatch, audience mismatch, missing required claim, inactive token, and user resolution failure.

Claim Mapping

Claim names are configurable per auth mode consumer. The defaults match the current package behavior exactly:

This is useful when introspection responses or partner-issued payloads use different field names while you still want the guard to populate:

Guard Registration

The package registers the fsa-sso-api driver. If you prefer to declare the guard explicitly in your application, use:

Route Examples

Sensitive endpoints can also confirm active=true through introspection:

The optional fsa-sso.introspect middleware remains compatible in both auth modes. In jwt mode it adds an active-token check after local verification. In introspection mode it reuses the same introspection endpoint and cache strategy as the guard.

Migration Example


๐Ÿ›ฃ๏ธ Package API Endpoints

The package auto-registers these routes under the configured prefix (auth/sso by default):

Method Path Description
GET /auth/sso/initiate Returns the FSA SSO login URL
POST /auth/sso/verify Verifies JWT, upserts user, returns user + claims
POST /auth/sso/introspect Proxies bearer token to FSA introspect API
POST /auth/sso/revoke Proxies bearer token to FSA revoke API

The package also auto-registers web routes (enabled by default):

Method Path Route Name Description
GET /fsa-sso/loginUrl fsaSsoLoginUrl Redirects browser to FSA login URL
GET /sso/callback-success fsaSsoCallbackSuccess Callback that verifies token, logs in user, and redirects
GET /fsa-sso/callback fsaSsoCallback Fallback callback path

๐Ÿงช Integration Guide (Laravel + Inertia)

This package now handles the common web flow internally.

Step 1 โ€” Configure Callback URL in FSA Admin

Register the callback URL in FSA SSO admin:

No custom app controller or app-level web route is required when FSA_SSO_ENABLE_WEB_ROUTES=true.

Using Different Callback URI Per Application

Each application can use its own callback path and route names while sharing the same package.

Example for another app:

Then register this exact URL in FSA admin for that application:

Notes:

Step 2 โ€” Confirm the Login Page Is Rendered by Inertia

Step 3 โ€” Add the "Sign in with FSA SSO" Button (React / Inertia)

Use the generated Wayfinder route helper from @/routes. Call .url() when assigning it to a native <a href>.


๐Ÿ”„ Complete Authentication Flow


๐Ÿ›ก๏ธ Protecting Routes with the Middleware

Use the fsa-sso.auth middleware to protect API routes that require a valid FSA SSO bearer token:

The middleware:


๐Ÿงฉ Using the Facade Directly


๐Ÿ” Security


โš™๏ธ Configuration Reference

All options are in config/fsa-sso.php after publishing:

Key Default Description
route_prefix auth/sso URL prefix for package routes
route_middleware ['api'] Middleware applied to package routes
web_routes_enabled true Enable package-managed web login/callback routes
web_route_middleware ['web'] Middleware applied to package web routes
web_login_path fsa-sso/loginUrl Login redirect endpoint path
web_callback_path sso/callback-success Primary callback endpoint path
web_fallback_callback_path fsa-sso/callback Secondary callback endpoint path
web_login_route_name fsaSsoLoginUrl Route name for login redirect endpoint
web_callback_route_name fsaSsoCallbackSuccess Route name for primary callback endpoint
web_fallback_callback_route_name fsaSsoCallback Route name for fallback callback endpoint
web_guard web Auth guard used for session login in callback
web_intended_route dashboard Intended route name used after successful callback
web_failure_redirect /login Redirect target when callback fails in browser requests
frontend_url http://localhost:4040 FSA SSO login portal URL
api_base_url http://localhost:3000 FSA SSO backend API base URL
jwks_url http://localhost:3000/.well-known/jwks.json JWKS endpoint
issuer http://localhost:3000 Expected iss claim
audience http://localhost:3000 Expected aud claim
client_code (required) Your FSA portal client code
jwks_cache_ttl_seconds 600 JWKS cache duration in seconds
user_model App\Models\User User model to upsert
columns see config Maps JWT claims โ†’ user column names
api_auth.mode jwt Guard auth mode: jwt or introspection
api_auth.debug_logging false Force structured auth failure logs in production
api_auth.claims see config Claim-name map used by the fsa-sso-api guard
return_access_token false Include raw token in verify response
include_claims_in_response true Include JWT claims in verify response

Backward Compatibility


โš ๏ธ Common Mistakes

Symptom Cause Fix
Missing authentication token FSA SSO sends authToken param Ensure resolveToken() checks authToken first
Mass assignment error on sso_id Missing $fillable entries Add SSO columns to User::$fillable
Callback route is not available Package web routes were disabled Set FSA_SSO_ENABLE_WEB_ROUTES=true or register your own routes/controllers
Login URL not working Wrong URL format Correct: /auth/login?client_code=...
Client code mismatch Env vs portal mismatch FSA_SSO_CLIENT_CODE must match FSA admin exactly
Redirects back to login after callback Invalid user model class value (often double-escaped in .env) Set FSA_SSO_USER_MODEL=App\Models\User and clear config cache
JWT verification fails ext-sodium not enabled Enable the PHP sodium extension in php.ini

๐Ÿงช Testing

The package includes standalone tests using Pest + Orchestra Testbench.

Run inside the package directory:


Support Me

If you find this package useful, consider supporting my work:

๐Ÿ“„ License

The MIT License (MIT). Please see License File for more information.


Built with โค๏ธ by Puthea Khem


All versions of fsa-sso with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
firebase/php-jwt Version ^7.1
illuminate/contracts Version ^10.0|^11.0|^12.0|^13.0
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
illuminate/http Version ^10.0|^11.0|^12.0|^13.0
illuminate/database Version ^10.0|^11.0|^12.0|^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package putheakhem/fsa-sso contains the following files

Loading the files please wait ...