simplesamlphp/simplesamlphp-assets-base
Shared base asset package for SimpleSAMLphp. Contains common front-end files used by the main SimpleSAMLphp repository (e.g., CSS/JS/images) to keep assets versioned and distributed separately.
Install the Package Require the package via Composer (though note its minimal maturity):
composer require simplesamlphp/simplesamlphp-assets-base
Extract Assets
Copy the static assets to your Laravel project’s public directory:
mkdir -p public/simplesaml
cp -r vendor/simplesamlphp/simplesamlphp-assets-base/public/simplesaml/* public/simplesaml/
Alternative: Symlink for development:
ln -s vendor/simplesamlphp/simplesamlphp-assets-base/public/simplesaml public/simplesaml
First Use Case: SAML Login Page
Create a Blade template (e.g., resources/views/auth/saml.blade.php) and include the assets:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="{{ asset('simplesaml/css/simplesaml.css') }}">
<!-- Optional: Include SimpleSAMLphp’s JS if needed -->
<script src="{{ asset('simplesaml/js/simplesaml.js') }}"></script>
</head>
<body>
@include('simplesaml.templates.login')
</body>
</html>
Route the SAML Flow
Add a route in routes/web.php to handle SAML requests:
Route::get('/saml/login', [SamlController::class, 'showLogin'])->name('saml.login');
Note: You’ll need a SamlController to proxy requests to SimpleSAMLphp (see Implementation Patterns).
public/simplesaml/ (simplest for small projects).
<!-- resources/views/layouts/app.blade.php -->
@stack('saml-assets')
@push('saml-assets')
<link rel="stylesheet" href="{{ asset('simplesaml/css/simplesaml.css') }}">
@endpush
// webpack.mix.js
mix.copy('public/simplesaml/css', 'public/dist/simplesaml/css');
mix.copy('public/simplesaml/js', 'public/dist/simplesaml/js');
Run:
npm run dev
Since SimpleSAMLphp is a standalone PHP app, use Laravel as a reverse proxy for SAML flows:
// app/Http/Controllers/SamlController.php
public function showLogin()
{
// Proxy to SimpleSAMLphp’s login endpoint
return redirect()->to('http://simplesamlphp.example.com/simplesaml/module.php/core/authenticate.php?as=your-sp-entity-id');
}
Alternative: Use league/oauth2-saml for lightweight SAML handling in Laravel.
Override SimpleSAMLphp’s CSS/JS by extending its files:
/* resources/css/simplesaml-overrides.css */
.saml-login-button {
background-color: #627eea; /* Custom color */
}
Load overrides after the original assets:
<link rel="stylesheet" href="{{ asset('simplesaml/css/simplesaml.css') }}">
<link rel="stylesheet" href="{{ asset('css/simplesaml-overrides.css') }}">
For SP-initiated SAML flows, pass dynamic data via query params:
// Example: Customize login page based on SP
Route::get('/saml/login/{sp}', [SamlController::class, 'showLogin'])->name('saml.login.sp');
<!-- resources/views/auth/saml.blade.php -->
<input type="hidden" id="sp-entity-id" value="{{ $sp }}">
<script src="{{ asset('simplesaml/js/simplesaml.js') }}?sp={{ $sp }}"></script>
Laravel + SimpleSAMLphp Hybrid Setup
User → Laravel App → SimpleSAMLphp (Auth) → Laravel (Post-Auth Redirect)
authsources.php to point to Laravel’s routes:
'default-sp' => [
'saml:SP',
'entityID' => 'https://your-laravel-app.com/saml/metadata',
'idp' => 'https://simplesamlphp.example.com/simplesaml/idp/metadata.php',
],
Metadata Handling
use SimpleSAML\Metadata\SP;
$sp = new SP([
'entityID' => 'https://your-laravel-app.com/saml',
'AssertionConsumerService' => [
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST',
'Location' => route('saml.ac'),
'index' => 0,
],
]);
public/simplesaml/metadata/saml20-sp-remote.php.Asset Versioning Append a version hash to asset paths to avoid cache issues:
<link rel="stylesheet" href="{{ asset('simplesaml/css/simplesaml.css?v=' . filemtime(public_path('simplesaml/css/simplesaml.css')) }}">
Debugging SAML Flows
config.php:
'debug' => 1,
'logging' => [
'level' => 'debug',
'handlers' => ['file', 'syslog'],
],
tail -f storage/logs/laravel.log | grep SAML
Asset Path Hardcoding
/simplesaml/. Override in Laravel’s app.blade.php:
<base href="{{ url('/') }}">
.htaccess:
RewriteRule ^simplesaml/(.*)$ /public/simplesaml/$1 [L]
jQuery/Bootstrap Conflicts
// webpack.mix.js
mix.disableSuccessNotifications();
mix.webpackConfig({
externals: {
jquery: 'jQuery',
},
});
SAML Session Management
file or database (not cookie).session setting in config.php matches:
'session' => [
'type' => 'files',
'handler' => 'user',
],
CSRF Token Mismatches
// app/Http/Middleware/VerifyCsrfToken.php
protected $except = [
'saml/*',
];
Asset Caching
Cache-Control: max-age=31536000) can break SAML flows if assets update. Use:
<link rel="stylesheet" href="{{ asset('simplesaml/css/simplesaml.css') }}" data-turbo-track="reload">
Check Asset Loading
F12) and verify:
404 errors for simplesaml.css/simplesaml.js.SAML Debugging
// config.php
'debug' => 1,
var/log/simplesaml.log
How can I help you explore Laravel packages today?