Code Monkey home page Code Monkey logo

Comments (6)

breart avatar breart commented on June 18, 2024 2

Totally understand the problem @nicolus. I'm currently working on the next major version and trying to solve this problem via "resolvers". You'll be able to either extend existing one or create your own. You can check out implementation here.

Let me know if that would solve the problem.

from laravel-saml2.

breart avatar breart commented on June 18, 2024

So to be clear, do you want to be able to adjust any configuration?

from laravel-saml2.

kw-pr avatar kw-pr commented on June 18, 2024

Yes, I would need to have individual configuration. I do have 2 onelogin/php-saml systems at the moment and about to add a 3. The first is connection to a Active Directory. the other two are for two SAP systems.

from laravel-saml2.

nicolus avatar nicolus commented on June 18, 2024

@brezzhnev @kw-pr : I think this is related to #43

And as I said there, it would be useful indeed to have a way to override any setting for a specific IdP (which was the case with aacotroneo/laravel-saml2.

What I ended up doing in the meantime is store the settings and create a new middleware that looks like this :

<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Config;
use Slides\Saml2\Repositories\TenantRepository;

class OverrideSamlSpConfig
{
    public function __construct(protected TenantRepository $tenants)
    {
    }

    public function handle(Request $request, Closure $next)
    {
        if ($uuid = $request->route('uuid')) {
            $config = $this->tenants->findByUUID($uuid)->metadata['saml2_config'] ?? [];

            foreach(Arr::dot($config) as $path => $value) {
                Config::set('saml2.' . $path, $value);
            }
        }

        return $next($request);
    }
}

That I include in the 'saml' middlewares in App\Http\Kernel :

'saml' => [
    \Illuminate\Session\Middleware\StartSession::class,
    \App\Http\Middleware\OverrideSamlSpConfig::class,
],

You also need to make sure that it's loaded before the resolver middleware with $middlewarePriority in the same Kernel file :

protected $middlewarePriority = [
    \App\Http\Middleware\AuthenticateWithBearerToken::class,
    \App\Http\Middleware\Authenticate::class,
    \App\Http\Middleware\AddLogContext::class,
    \App\Http\Middleware\OverrideSamlSpConfig::class,
    \Slides\Saml2\Http\Middleware\ResolveTenant::class,
];

Then you can add the config in your idp metadata column like so :

{
  "saml2_config": {
    "security": {
      "requestedAuthnContext": false
    }
  }
}

Hope that can help someone.

from laravel-saml2.

nicolus avatar nicolus commented on June 18, 2024

So the idea is that I would make my own classes that implement ResolvesIdentityProvider or ResolvesIdpConfig and then bind them in my AppServiceProvider so they replace the default ones ?

If so, that sounds perfect, thanks !

from laravel-saml2.

breart avatar breart commented on June 18, 2024

Yeah, almost like that, but instead of binding another dependency in the service provider, you would need to change the class reference using resolvers.config in the config/saml2.php

I thought that would be easier, but DI is also an option to consider.

from laravel-saml2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.